Skip to content

Commit

Permalink
fix shape equality check in solver
Browse files Browse the repository at this point in the history
The proper way to compare shapes of `evaluable.Array` instances is using
`evaluable.equalshape`. This patch replaces two `shape1 == shape2` checks with
`evaluable.equalshape(shape1, shape2)` in the `solver` module.
  • Loading branch information
joostvanzwieten committed Aug 18, 2021
1 parent 284655f commit 6066e87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nutils/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def __init__(self, target, residual:integraltuple, inertia:optionalintegraltuple
if len(residual) != len(inertia):
raise Exception('length of residual and inertia do no match')
for inert, res in zip(inertia, residual):
if inert and inert.shape != res.shape:
if inert and not evaluable.equalshape(inert.shape, res.shape):
raise ValueError('expected `inertia` with shape {} but got {}'.format(res.shape, inert.shape))
self.target = target
self.timesteptarget = '_pseudotime_timestep'
Expand Down Expand Up @@ -704,7 +704,7 @@ def __init__(self, target, residual:integraltuple, inertia:optionalintegraltuple
if len(residual) != len(inertia):
raise Exception('length of residual and inertia do no match')
for inert, res in zip(inertia, residual):
if inert and inert.shape != res.shape:
if inert and not evaluable.equalshape(inert.shape, res.shape):
raise ValueError('expected `inertia` with shape {} but got {}'.format(res.shape, inert.shape))
self.target = target
self.newtonargs = newtonargs
Expand Down

0 comments on commit 6066e87

Please sign in to comment.