Skip to content

Commit

Permalink
move error check before return in map_product
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl committed Jan 12, 2022
1 parent 1e3448a commit 415307f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pymbolic/geometric_algebra/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ def map_product(self, expr):
nabla_finder.setdefault(
ncomp.nabla_id, set()).add((child_idx, ncomp.ambient_axis))

if nabla_finder and not any(d_source_nabla_ids_per_child):
raise ValueError(f"no derivative source found to resolve in '{expr}'"
" -- did you forget to wrap the term that should have its "
"derivative taken in 'Derivative()(term)'?")

if not has_d_source_nablas:
rec_children = [self.rec(child) for child in expr.children]
if all(rec_child is child
Expand All @@ -280,11 +285,6 @@ def map_product(self, expr):

# }}}

if nabla_finder and not any(d_source_nabla_ids_per_child):
raise ValueError(f"no derivative source found to resolve in '{expr}'"
" -- did you forget to wrap the term that should have its "
"derivative taken in 'Derivative()(term)'?")

# a list of lists, the outer level presenting a sum, the inner a product
result = [list(expr.children)]

Expand Down

0 comments on commit 415307f

Please sign in to comment.