Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: use special.sindg in ndimage.rotate #12721

Merged
merged 1 commit into from
Aug 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scipy/ndimage/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import numpy
from numpy.core.multiarray import normalize_axis_index

from scipy import special
from . import _ni_support
from . import _nd_image
from ._ni_docstrings import docfiller
Expand Down Expand Up @@ -730,8 +731,7 @@ def rotate(input, angle, axes=(1, 0), reshape=True, output=None, order=3,

axes.sort()

angle_rad = numpy.deg2rad(angle)
c, s = numpy.cos(angle_rad), numpy.sin(angle_rad)
c, s = special.cosdg(angle), special.sindg(angle)

rot_matrix = numpy.array([[c, s],
[-s, c]])
Expand Down
5 changes: 5 additions & 0 deletions scipy/ndimage/tests/test_ndimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,11 @@ def test_rotate10(self):
out = ndimage.rotate(data, angle=12, reshape=False)
assert_array_almost_equal(out, expected)

def test_rotate_exact_180(self):
a = numpy.tile(numpy.arange(5), (5, 1))
b = ndimage.rotate(ndimage.rotate(a, 180), -180)
assert_equal(a, b)

def test_watershed_ift01(self):
data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
Expand Down