Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -27913,6 +27913,14 @@
"lineCount": 1
}
},
{
"code": "reportAbstractUsage",
"range": {
"startColumn": 19,
"endColumn": 18,
"lineCount": 4
}
},
{
"code": "reportCallIssue",
"range": {
Expand Down Expand Up @@ -28041,6 +28049,14 @@
"lineCount": 1
}
},
{
"code": "reportAbstractUsage",
"range": {
"startColumn": 19,
"endColumn": 18,
"lineCount": 4
}
},
{
"code": "reportCallIssue",
"range": {
Expand Down
2 changes: 1 addition & 1 deletion pytential/symbolic/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def _prepare_expr(places: GeometryCollection,

# FIXME: There's some mismatch between OperandTc and a conditional union
# type that I was too impatient to figure out in detail.
expr = componentwise(flatten, expr) # pyright: ignore[reportAssignmentType]
expr = flatten(expr)
auto_source, auto_target = _prepare_auto_where(auto_where, places=places)
expr = componentwise( # pyright: ignore[reportAssignmentType]
ToTargetTagger(
Expand Down
13 changes: 11 additions & 2 deletions pytential/symbolic/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,17 @@ class FlattenMapper(FlattenMapperBase, IdentityMapper):
pass


def flatten(expr: ArithmeticExpression):
return FlattenMapper().rec_arith(expr)
def flatten(expr: pp.OperandTc) -> pp.OperandTc:
from pymbolic.geometric_algebra import MultiVector, componentwise
from pytools.obj_array import ObjectArray

def func(expr_i: ArithmeticExpression) -> ArithmeticExpression:
return FlattenMapper().rec_arith(expr_i)

if isinstance(expr, (ObjectArray, MultiVector)):
return componentwise(func, expr)
else:
return cast("pp.OperandTc", func(expr))

# }}}

Expand Down
Loading