Skip to content

Commit a6049ac

Browse files
committed
Rename type aliases for consistency
1 parent b7cfd30 commit a6049ac

20 files changed

+268
-236
lines changed

doc/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
("https://immutabledict.corenting.fr/", None)
2929
}
3030
autodoc_type_aliases = {
31-
"ExpressionT": "ExpressionT",
32-
"ArithmeticExpressionT": "ArithmeticExpressionT",
31+
"ExpressionOrData": "ExpressionOrData",
32+
"ArithmeticExpression": "ArithmeticExpression",
3333
}
3434

3535
import sys

pymbolic/__init__.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,25 @@
6262
from .mapper.distributor import distribute as expand
6363
from .mapper.distributor import distribute
6464
from .mapper.flattener import flatten
65-
from .typing import NumberT, ScalarT, ArithmeticExpressionT, ExpressionT, BoolT
65+
from .typing import (
66+
Number, Scalar, ArithmeticExpression, ExpressionOrData, Bool,
67+
ArithmeticExpressionT, ExpressionT, BoolT, ScalarT)
68+
69+
70+
# TODO ExpressionT, ArithmeticExpressionT, BoolT, and ScalarT are deprecated and should
71+
# go away in 2H2025.
6672

6773

6874
__all__ = (
75+
"ArithmeticExpression",
6976
"ArithmeticExpressionT",
77+
"Bool",
7078
"BoolT",
7179
"Expression",
80+
"ExpressionOrData",
7281
"ExpressionT",
73-
"NumberT",
82+
"Number",
83+
"Scalar",
7484
"ScalarT",
7585
"Variable",
7686
"compile",

pymbolic/geometric_algebra/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from pytools import memoize, memoize_method
3434

3535
from pymbolic.primitives import expr_dataclass, is_zero
36-
from pymbolic.typing import ArithmeticExpressionT, T
36+
from pymbolic.typing import ArithmeticExpression, T
3737

3838

3939
__doc__ = """
@@ -293,7 +293,7 @@ def get_euclidean_space(n: int) -> Space:
293293
# }}}
294294

295295

296-
CoeffT = TypeVar("CoeffT", bound=ArithmeticExpressionT)
296+
CoeffT = TypeVar("CoeffT", bound=ArithmeticExpression)
297297

298298

299299
# {{{ blade product weights

pymbolic/geometric_algebra/primitives.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from typing import ClassVar
3131

3232
from pymbolic.primitives import Expression, Variable, expr_dataclass
33-
from pymbolic.typing import ExpressionT
33+
from pymbolic.typing import ExpressionOrData
3434

3535

3636
class MultiVectorVariable(Variable):
@@ -58,7 +58,7 @@ class Nabla(_GeometricCalculusExpression):
5858

5959
@expr_dataclass()
6060
class DerivativeSource(_GeometricCalculusExpression):
61-
operand: ExpressionT
61+
operand: ExpressionOrData
6262
nabla_id: Hashable
6363

6464

pymbolic/interop/ast.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
import pymbolic.primitives as p
3333
from pymbolic.mapper import CachedMapper
34-
from pymbolic.typing import ExpressionT
34+
from pymbolic.typing import ExpressionOrData
3535

3636

3737
__doc__ = r'''
@@ -263,7 +263,7 @@ def map_variable(self, expr) -> ast.expr:
263263
return ast.Name(id=expr.name)
264264

265265
def _map_multi_children_op(self,
266-
children: tuple[ExpressionT, ...],
266+
children: tuple[ExpressionOrData, ...],
267267
op_type: ast.operator) -> ast.expr:
268268
rec_children = [self.rec(child) for child in children]
269269
result = rec_children[-1]
@@ -435,7 +435,7 @@ def to_python_ast(expr) -> ast.expr:
435435
return PymbolicToASTMapper()(expr)
436436

437437

438-
def to_evaluatable_python_function(expr: ExpressionT,
438+
def to_evaluatable_python_function(expr: ExpressionOrData,
439439
fn_name: str
440440
) -> str:
441441
"""

pymbolic/interop/matchpy/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
)
5858

5959
import pymbolic.primitives as p
60-
from pymbolic.typing import ScalarT
60+
from pymbolic.typing import Scalar as PbScalar
6161

6262

6363
ExprT: TypeAlias = Expression
@@ -95,7 +95,7 @@ def __lt__(self, other):
9595

9696

9797
@op_dataclass
98-
class Scalar(_Constant[ScalarT]):
98+
class Scalar(_Constant[PbScalar]):
9999
_mapper_method: str = "map_scalar"
100100

101101

@@ -364,7 +364,7 @@ def match(subject: p.Expression,
364364
pattern: p.Expression,
365365
to_matchpy_expr: ToMatchpyT | None = None,
366366
from_matchpy_expr: FromMatchpyT | None = None
367-
) -> Iterator[Mapping[str, p.Expression | ScalarT]]:
367+
) -> Iterator[Mapping[str, p.Expression | PbScalar]]:
368368
from matchpy import Pattern, match
369369

370370
from .tofrom import FromMatchpyExpressionMapper, ToMatchpyExpressionMapper
@@ -387,8 +387,8 @@ def match_anywhere(subject: p.Expression,
387387
pattern: p.Expression,
388388
to_matchpy_expr: ToMatchpyT | None = None,
389389
from_matchpy_expr: FromMatchpyT | None = None
390-
) -> Iterator[tuple[Mapping[str, p.Expression | ScalarT],
391-
p.Expression | ScalarT]
390+
) -> Iterator[tuple[Mapping[str, p.Expression | PbScalar],
391+
p.Expression | PbScalar]
392392
]:
393393
from matchpy import Pattern, match_anywhere
394394

pymbolic/interop/matchpy/tofrom.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pymbolic.primitives as p
1313
from pymbolic.interop.matchpy.mapper import Mapper as BaseMatchPyMapper
1414
from pymbolic.mapper import Mapper as BasePymMapper
15+
from pymbolic.typing import Scalar as PbScalar
1516

1617

1718
# {{{ to matchpy
@@ -117,7 +118,7 @@ def map_star_wildcard(self, expr: p.StarWildcard) -> m.Wildcard:
117118
# {{{ from matchpy
118119

119120
class FromMatchpyExpressionMapper(BaseMatchPyMapper):
120-
def map_scalar(self, expr: m.Scalar) -> m.ScalarT:
121+
def map_scalar(self, expr: m.Scalar) -> PbScalar:
121122
return expr.value
122123

123124
def map_variable(self, expr: m.Variable) -> p.Variable:

0 commit comments

Comments
 (0)