SINTEF / Splipy

Spline modelling made easy.
GNU General Public License v3.0
102 stars 18 forks source link

Curve_factory.circle crashes with center keyword #57

Closed VikingScientist closed 6 years ago

VikingScientist commented 6 years ago
from splipy import curve_factory
my_circle = curve_factory.circle(r=3, center=(2,0))

Error output

  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/Splipy-1.2.0-py3.5-linux-x86_64.egg/splipy/curve_factory.py", line 174, in circle
    return flip_and_move_plane_geometry(result, center, normal)
  File "/usr/local/lib/python3.5/dist-packages/Splipy-1.2.0-py3.5-linux-x86_64.egg/splipy/utils/__init__.py", line 126, in flip_and_move_plane_geometry
    if not np.allclose(center, np.array([0,0,0])):
  File "/usr/local/lib/python3.5/dist-packages/numpy/core/numeric.py", line 2256, in allclose
    res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan))
  File "/usr/local/lib/python3.5/dist-packages/numpy/core/numeric.py", line 2335, in isclose
    return within_tol(x, y, atol, rtol)
  File "/usr/local/lib/python3.5/dist-packages/numpy/core/numeric.py", line 2321, in within_tol
    return less_equal(abs(x-y), atol + rtol * abs(y))
ValueError: operands could not be broadcast together with shapes (2,) (3,) 
TheBB commented 6 years ago

I'm pretty sure np.allclose broadcasts internally, so you can just write np.allclose(center, 0)

VikingScientist commented 6 years ago

If you have the time, feel free to attack this, as well as #55 :muscle: :smirk:

TheBB commented 6 years ago

I guess I did have the time. :-P