[ell] fix crash when ccw=None but spacing is non-scalar
This commit is contained in:
parent
32744512e0
commit
6fd73b9d46
2 changed files with 15 additions and 1 deletions
|
|
@ -84,7 +84,7 @@ def ell(
|
|||
raise BuildError('Empty port list passed to `ell()`')
|
||||
|
||||
if ccw is None:
|
||||
if spacing is not None and not numpy.isclose(spacing, 0):
|
||||
if spacing is not None and not numpy.allclose(spacing, 0):
|
||||
raise BuildError('Spacing must be 0 or None when ccw=None')
|
||||
spacing = 0
|
||||
elif spacing is None:
|
||||
|
|
|
|||
|
|
@ -129,3 +129,17 @@ def test_dead_plug_best_effort() -> None:
|
|||
# P2 rot pi + transform rot -pi = 0
|
||||
assert b.ports['B'].rotation is not None
|
||||
assert_allclose(b.ports['B'].rotation, 0, atol=1e-10)
|
||||
|
||||
|
||||
def test_ell_handles_array_spacing_when_ccw_none() -> None:
|
||||
ports = {
|
||||
'A': Port((0, 0), 0),
|
||||
'B': Port((0, 1), 0),
|
||||
}
|
||||
|
||||
scalar = ell(ports, None, 'min_extension', 5, spacing=0)
|
||||
array_zero = ell(ports, None, 'min_extension', 5, spacing=numpy.array([0, 0]))
|
||||
assert scalar == array_zero
|
||||
|
||||
with pytest.raises(BuildError, match='Spacing must be 0 or None'):
|
||||
ell(ports, None, 'min_extension', 5, spacing=numpy.array([1, 0]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue