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 authored and inducer committed Feb 11, 2022
1 parent d07449f commit 4cbb052
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 4cbb052

Please sign in to comment.