Skip to content

Commit 319832f

Browse files
Adapt to NumPy 1.25
Changes to avoid using functions removed in NumPy 1.25 Avoid raising ValueError from noexcept capsule destructor.
1 parent 7110797 commit 319832f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

mkl_fft/_pydfti.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#cython: language_level=3
2828

2929
# imports
30+
import sys
3031
import numpy as np
3132
from numpy.core._multiarray_tests import internal_overlap
3233
from threading import local as threading_local
@@ -48,13 +49,14 @@ cdef void _capsule_destructor(object caps) noexcept:
4849
cdef DftiCache *_cache = NULL
4950
cdef int status = 0
5051
if (caps is None):
51-
print("Nothing to destroy")
52+
print("CapsuleDestructorInternalError: Nothing to destroy", file=sys.stderr)
5253
return
5354
_cache = <DftiCache *>cpython.pycapsule.PyCapsule_GetPointer(caps, capsule_name)
5455
status = _free_dfti_cache(_cache)
5556
PyMem_Free(_cache)
5657
if (status != 0):
57-
raise ValueError("Internal Error: Freeing DFTI Cache returned with error = {}".format(status))
58+
print("CapsuleDestructorInternalError: Freeing DFTI Cache "
59+
f"returned with error code = '{status}'", file=sys.stderr)
5860

5961

6062
def _tls_dfti_cache_capsule():

mkl_fft/tests/test_fft1d.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (c) 2017-2019, Intel Corporation
2+
# Copyright (c) 2017-2023, Intel Corporation
33
#
44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions are met:
@@ -26,7 +26,7 @@
2626

2727
import numpy as np
2828
from numpy.testing import (
29-
TestCase, run_module_suite, assert_, assert_raises, assert_equal,
29+
TestCase, assert_, assert_raises, assert_equal,
3030
assert_warns, assert_allclose)
3131
from numpy import random as rnd
3232
import sys
@@ -387,5 +387,3 @@ def test5(self):
387387
f2 = mkl_fft.rfft(f1, axis=a, overwrite_x=ovwr_x)
388388
assert_allclose(f2, self.t3.astype(dt), atol=atol)
389389

390-
if __name__ == "__main__":
391-
run_module_suite(argv = sys.argv)

mkl_fft/tests/test_fftnd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (c) 2017-2019, Intel Corporation
2+
# Copyright (c) 2017-2023, Intel Corporation
33
#
44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions are met:
@@ -26,7 +26,7 @@
2626

2727
import numpy as np
2828
from numpy.testing import (
29-
TestCase, run_module_suite, assert_, assert_raises, assert_equal,
29+
TestCase, assert_, assert_raises, assert_equal,
3030
assert_warns, assert_allclose)
3131
from numpy import random as rnd
3232
import sys

0 commit comments

Comments
 (0)