Skip to content

Commit

Permalink
Rename Basis{Function,Gradient} to drop 'Type' suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Feb 5, 2025
1 parent 8ba8754 commit 56027a0
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions modepy/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

import math
from abc import ABC, abstractmethod
from collections.abc import Callable, Hashable, Iterable, Sequence
Expand Down Expand Up @@ -747,8 +746,8 @@ def symbolicize_function(

# {{{ basis interface

BasisFunctionType: TypeAlias = Callable[[np.ndarray], np.ndarray]
BasisGradientType: TypeAlias = Callable[[np.ndarray], tuple[np.ndarray, ...]]
BasisFunction: TypeAlias = Callable[[np.ndarray], np.ndarray]
BasisGradient: TypeAlias = Callable[[np.ndarray], tuple[np.ndarray, ...]]


class BasisNotOrthonormal(Exception):
Expand Down Expand Up @@ -778,22 +777,22 @@ def mode_ids(self) -> tuple[Hashable, ...]:

@property
@abstractmethod
def functions(self) -> tuple[BasisFunctionType, ...]:
def functions(self) -> tuple[BasisFunction, ...]:
"""A tuple of (callable) basis functions of length matching
:attr:`mode_ids`. Each function takes a vector of :math:`(r, s, t)`
reference coordinates (depending on dimension) as input.
"""

@property
@abstractmethod
def gradients(self) -> tuple[BasisGradientType, ...]:
def gradients(self) -> tuple[BasisGradient, ...]:
"""A tuple of (callable) basis functions of length matching
:attr:`mode_ids`. Each function takes a vector of :math:`(r, s, t)`
reference coordinates (depending on dimension) as input.
Each function returns a tuple of derivatives, one per reference axis.
"""

def derivatives(self, axis: int) -> tuple[BasisFunctionType, ...]:
def derivatives(self, axis: int) -> tuple[BasisFunction, ...]:
"""
Returns a tuple of callable functions in the same order as
:meth:`functions` representing the same basis functions with a
Expand Down Expand Up @@ -909,14 +908,14 @@ def orthonormality_weight(self) -> float:
raise BasisNotOrthonormal

@property
def functions(self) -> tuple[BasisFunctionType, ...]:
def functions(self) -> tuple[BasisFunction, ...]:
return tuple(partial(monomial, mid) for mid in self.mode_ids)

@property
def gradients(self) -> tuple[BasisGradientType, ...]:
def gradients(self) -> tuple[BasisGradient, ...]:
return tuple(partial(grad_monomial, mid) for mid in self.mode_ids)

def derivatives(self, axis: int) -> tuple[BasisFunctionType, ...]:
def derivatives(self, axis: int) -> tuple[BasisFunction, ...]:
return tuple(
partial(diff_monomial, mid, axis)
for mid in self.mode_ids)
Expand Down Expand Up @@ -1039,7 +1038,7 @@ def part_flat_tuple(iterable: Iterable[tuple[bool, Hashable]]
for mode_index_tuple in self._mode_index_tuples)

@property
def functions(self) -> tuple[BasisFunctionType, ...]:
def functions(self) -> tuple[BasisFunction, ...]:
bases = [b.functions for b in self._bases]
return tuple(
_TensorProductBasisFunction(
Expand All @@ -1050,7 +1049,7 @@ def functions(self) -> tuple[BasisFunctionType, ...]:
for mid in self._mode_index_tuples)

@property
def gradients(self) -> tuple[BasisGradientType, ...]:
def gradients(self) -> tuple[BasisGradient, ...]:
from pytools import wandering_element
bases = [b.functions for b in self._bases]
grad_bases = [b.gradients for b in self._bases]
Expand All @@ -1066,7 +1065,7 @@ def gradients(self) -> tuple[BasisGradientType, ...]:
dims_per_function=self._dims_per_basis)
for mid in self._mode_index_tuples)

def derivatives(self, axis: int) -> tuple[BasisFunctionType, ...]:
def derivatives(self, axis: int) -> tuple[BasisFunction, ...]:
bases = [b.functions for b in self._bases]
return tuple(
_TensorProductBasisFunction(
Expand Down

0 comments on commit 56027a0

Please sign in to comment.