Skip to content

Commit aa9e5bc

Browse files
authored
replace deprecated macros (#193)
1 parent 7b7dd8b commit aa9e5bc

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

mkl_fft/_pydfti.pyx

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ cdef cnp.ndarray _pad_array(
203203
b_shape[axis] = n
204204

205205
# allocating temporary buffer
206-
x_arr_is_fortran = cnp.PyArray_CHKFLAGS(x_arr, cnp.NPY_F_CONTIGUOUS)
206+
x_arr_is_fortran = cnp.PyArray_CHKFLAGS(x_arr, cnp.NPY_ARRAY_F_CONTIGUOUS)
207207
b_arr = <cnp.ndarray> cnp.PyArray_EMPTY(
208208
b_ndim, b_shape, <cnp.NPY_TYPES> b_type, x_arr_is_fortran
209209
) # 0 for C-contiguous
@@ -249,9 +249,12 @@ cdef cnp.ndarray _process_arguments(
249249

250250
# convert x to ndarray, ensure that strides are multiples of itemsize
251251
x_arr = PyArray_CheckFromAny(
252-
x, NULL, 0, 0,
253-
cnp.NPY_ELEMENTSTRIDES | cnp.NPY_ENSUREARRAY | cnp.NPY_NOTSWAPPED,
254-
NULL)
252+
x, NULL, 0, 0,
253+
cnp.NPY_ARRAY_ELEMENTSTRIDES |
254+
cnp.NPY_ARRAY_ENSUREARRAY |
255+
cnp.NPY_ARRAY_NOTSWAPPED,
256+
NULL
257+
)
255258

256259
if (<void *> x_arr) is NULL:
257260
raise ValueError("An input argument x is not an array-like object")
@@ -319,7 +322,7 @@ cdef cnp.ndarray _allocate_result(
319322
f_shape[axis_] = n_
320323

321324
# allocating output buffer
322-
x_arr_is_fortran = cnp.PyArray_CHKFLAGS(x_arr, cnp.NPY_F_CONTIGUOUS)
325+
x_arr_is_fortran = cnp.PyArray_CHKFLAGS(x_arr, cnp.NPY_ARRAY_F_CONTIGUOUS)
323326
f_arr = <cnp.ndarray> cnp.PyArray_EMPTY(
324327
f_ndim, f_shape, <cnp.NPY_TYPES> f_type, x_arr_is_fortran
325328
) # 0 for C-contiguous
@@ -419,7 +422,9 @@ def _c2c_fft1d_impl(
419422
# so we cast to complex double and operate in place
420423
try:
421424
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
422-
x_arr, cnp.NPY_CDOUBLE, cnp.NPY_BEHAVED | cnp.NPY_ENSURECOPY)
425+
x_arr, cnp.NPY_CDOUBLE,
426+
cnp.NPY_ARRAY_BEHAVED | cnp.NPY_ARRAY_ENSURECOPY
427+
)
423428
except:
424429
raise ValueError(
425430
"First argument must be a complex "
@@ -601,9 +606,9 @@ def _r2c_fft1d_impl(
601606
else:
602607
# we must cast the input to doubles and allocate the output,
603608
try:
604-
requirement = cnp.NPY_BEHAVED | cnp.NPY_ENSURECOPY
609+
requirement = cnp.NPY_ARRAY_BEHAVED | cnp.NPY_ARRAY_ENSURECOPY
605610
if x_type is cnp.NPY_LONGDOUBLE:
606-
requirement = requirement | cnp.NPY_FORCECAST
611+
requirement = requirement | cnp.NPY_ARRAY_FORCECAST
607612
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
608613
x_arr, cnp.NPY_DOUBLE, requirement)
609614
x_type = cnp.PyArray_TYPE(x_arr)
@@ -705,11 +710,11 @@ def _c2r_fft1d_impl(
705710
# so we cast to complex double and operate in place
706711
if x_type is cnp.NPY_FLOAT:
707712
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
708-
x_arr, cnp.NPY_CFLOAT, cnp.NPY_BEHAVED
713+
x_arr, cnp.NPY_CFLOAT, cnp.NPY_ARRAY_BEHAVED
709714
)
710715
else:
711716
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
712-
x_arr, cnp.NPY_CDOUBLE, cnp.NPY_BEHAVED
717+
x_arr, cnp.NPY_CDOUBLE, cnp.NPY_ARRAY_BEHAVED
713718
)
714719
x_type = cnp.PyArray_TYPE(x_arr)
715720
in_place = 1
@@ -788,9 +793,12 @@ def _direct_fftnd(
788793

789794
# convert x to ndarray, ensure that strides are multiples of itemsize
790795
x_arr = PyArray_CheckFromAny(
791-
x, NULL, 0, 0,
792-
cnp.NPY_ELEMENTSTRIDES | cnp.NPY_ENSUREARRAY | cnp.NPY_NOTSWAPPED,
793-
NULL)
796+
x, NULL, 0, 0,
797+
cnp.NPY_ARRAY_ELEMENTSTRIDES |
798+
cnp.NPY_ARRAY_ENSUREARRAY |
799+
cnp.NPY_ARRAY_NOTSWAPPED,
800+
NULL
801+
)
794802

795803
if <void *> x_arr is NULL:
796804
raise ValueError("An input argument x is not an array-like object")
@@ -808,7 +816,9 @@ def _direct_fftnd(
808816
pass
809817
else:
810818
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
811-
x_arr, cnp.NPY_CDOUBLE, cnp.NPY_BEHAVED | cnp.NPY_ENSURECOPY)
819+
x_arr, cnp.NPY_CDOUBLE,
820+
cnp.NPY_ARRAY_BEHAVED | cnp.NPY_ARRAY_ENSURECOPY
821+
)
812822
x_type = cnp.PyArray_TYPE(x_arr)
813823
assert x_type == cnp.NPY_CDOUBLE
814824
in_place = 1
@@ -1003,7 +1013,9 @@ def _rr_fft1d_impl(x, n=None, axis=-1, overwrite_x=False, double fsc=1.0):
10031013
else:
10041014
try:
10051015
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
1006-
x_arr, cnp.NPY_DOUBLE, cnp.NPY_BEHAVED | cnp.NPY_ENSURECOPY)
1016+
x_arr, cnp.NPY_DOUBLE,
1017+
cnp.NPY_ARRAY_BEHAVED | cnp.NPY_ARRAY_ENSURECOPY
1018+
)
10071019
except:
10081020
raise TypeError("1st argument must be a real sequence")
10091021
x_type = cnp.PyArray_TYPE(x_arr)
@@ -1065,7 +1077,9 @@ def _rr_ifft1d_impl(x, n=None, axis=-1, overwrite_x=False, double fsc=1.0):
10651077
# so we cast to complex double and operate in place
10661078
try:
10671079
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
1068-
x_arr, cnp.NPY_DOUBLE, cnp.NPY_BEHAVED | cnp.NPY_ENSURECOPY)
1080+
x_arr, cnp.NPY_DOUBLE,
1081+
cnp.NPY_ARRAY_BEHAVED | cnp.NPY_ARRAY_ENSURECOPY
1082+
)
10691083
except:
10701084
raise ValueError(
10711085
"First argument should be a real "

0 commit comments

Comments
 (0)