Skip to content

Update with forthcoming numpy changes #6

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 20, 2018
Merged
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
21 changes: 14 additions & 7 deletions mkl_fft/_pydfti.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

import numpy as np
cimport numpy as cnp
from numpy.core.multiarray_tests import internal_overlap
try:
from numpy.core.multiarray_tests import internal_overlap
except ModuleNotFoundError:
# Module has been renamed in NumPy 1.15
from numpy.core._multiarray_tests import internal_overlap

from libc.string cimport memcpy

Expand Down Expand Up @@ -101,12 +105,12 @@ cdef int _datacopied(cnp.ndarray arr, object orig):
Strict check for `arr` not sharing any data with `original`,
under the assumption that arr = asarray(original)
"""
if arr is orig:
return 0
if not cnp.PyArray_Check(orig) and PyObject_HasAttrString(orig, '__array__'):
return 0
if isinstance(orig, np.ndarray) and (arr is (<cnp.ndarray> orig)):
return 0
arr_obj = <object> arr
return 1 if arr_obj.base is None else 0
return 1 if (arr_obj.base is None) else 0


def fft(x, n=None, axis=-1, overwrite_x=False):
Expand Down Expand Up @@ -808,7 +812,7 @@ def rfftn_numpy(x, s=None, axes=None):
no_trim = (s is None) and (axes is None)
s, axes = _cook_nd_args(a, s, axes)
la = axes[-1]
# trim array, so that rfft_numpy avoid doing
# trim array, so that rfft_numpy avoids doing
# unnecessary computations
if not no_trim:
a = _trim_array(a, s, axes)
Expand Down Expand Up @@ -843,15 +847,18 @@ def irfftn_numpy(x, s=None, axes=None):
a = _fix_dimensions(a, s, axes)
ovr_x = True if _datacopied(<cnp.ndarray> a, x) else False
if len(set(axes)) == len(axes) and len(axes) == a.ndim and len(axes) > 2:
# due to need to write into a, we must copy
if not ovr_x:
a = a.copy()
ovr_x = True
ss, aa = _remove_axis(s, axes, la)
ind = [slice(None,None,1),] * len(s)
for ii in range(a.shape[la]):
ind[la] = ii
tind = tuple(ind)
a[tind] = _fftnd_impl(
a[tind], shape=ss, axes=aa,
overwrite_x=ovr_x, direction=-1)
ovr_x = True
overwrite_x=True, direction=-1)
else:
for ii in range(len(axes)-1):
a = ifft(a, s[ii], axes[ii], overwrite_x=ovr_x)
Expand Down