Skip to content

Bugfix/remove axes #38

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

Merged
merged 2 commits into from
Apr 16, 2019
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
6 changes: 4 additions & 2 deletions mkl_fft/_pydfti.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,9 @@ def _remove_axis(s, axes, axis_to_remove):
a2r = lens + axis_to_remove if axis_to_remove < 0 else axis_to_remove

ss = s[:a2r] + s[a2r+1:]
aa = axes_normalized[:a2r] + tuple(ai - 1 for ai in axes_normalized[a2r+1:])
pivot = axes_normalized[a2r]
aa = tuple(ai if ai < pivot else ai - 1 for ai in axes_normalized[:a2r]) + \
tuple(ai if ai < pivot else ai - 1 for ai in axes_normalized[a2r+1:])
return ss, aa


Expand Down Expand Up @@ -938,7 +940,7 @@ def rfftn_numpy(x, s=None, axes=None):
ss[-1] = a.shape[la]
a = _fix_dimensions(a, tuple(ss), axes)
if len(set(axes)) == len(axes) and len(axes) == a.ndim and len(axes) > 2:
ss, aa = _remove_axis(s, axes, la)
ss, aa = _remove_axis(s, axes, -1)
ind = [slice(None,None,1),] * len(s)
for ii in range(a.shape[la]):
ind[la] = ii
Expand Down
10 changes: 10 additions & 0 deletions mkl_fft/tests/test_fftnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,13 @@ def test_cf_contig(self):
f1 = mkl_fft.fft(d_ccont, axis=a)
f2 = mkl_fft.fft(d_fcont, axis=a)
assert_allclose(f1, f2, rtol=r_tol, atol=a_tol)

def test_rfftn_numpy(self):
"""Test that rfftn_numpy works as expected"""
axes = [(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]
for x in [self.ad, self.af]:
for a in axes:
r_tol, a_tol = _get_rtol_atol(x)
rfft_tr = mkl_fft.rfftn_numpy(np.transpose(x, a))
tr_rfft = np.transpose(mkl_fft.rfftn_numpy(x, axes=a), a)
assert_allclose(rfft_tr, tr_rfft, rtol=r_tol, atol=a_tol)