Skip to content

Commit fed6925

Browse files
authored
Remove use of numpy.testing.suppress_warnings in tests (#2529)
NumPy is going to deprecate use of `numpy.testing.suppress_warnings` and to fully migrate to `warnings` module internally which is tread-safe. This PR updates the tests and replaces the use of `numpy.testing.suppress_warnings` with appropriate calls from the `warnings` module.
1 parent e2c0469 commit fed6925

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
* Bumped oneMKL version up to `v0.8` [#2514](https://github.com/IntelPython/dpnp/pull/2514)
2828
* Removed the use of class template argument deduction for alias template to conform to the C++17 standard [#2517](https://github.com/IntelPython/dpnp/pull/2517)
2929
* Changed th order of individual FFTs over `axes` for `dpnp.fft.irfftn` to be in forward order [#2524](https://github.com/IntelPython/dpnp/pull/2524)
30+
* Replaced the use of `numpy.testing.suppress_warnings` with appropriate calls from the warnings module [#2529](https://github.com/IntelPython/dpnp/pull/2529)
3031

3132
### Deprecated
3233

dpnp/tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,8 @@ def allow_fall_back_on_numpy(monkeypatch):
183183

184184
@pytest.fixture
185185
def suppress_complex_warning():
186-
sup = numpy.testing.suppress_warnings("always")
187-
sup.filter(ComplexWarning)
188-
with sup:
186+
with warnings.catch_warnings():
187+
warnings.simplefilter("ignore", ComplexWarning)
189188
yield
190189

191190

dpnp/tests/test_linalg.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import dpctl
24
import dpctl.tensor as dpt
35
import numpy
@@ -10,7 +12,6 @@
1012
assert_equal,
1113
assert_raises,
1214
assert_raises_regex,
13-
suppress_warnings,
1415
)
1516

1617
import dpnp
@@ -847,8 +848,8 @@ def check_einsum_sums(self, dtype, do_opt=False):
847848
)
848849

849850
# Suppress the complex warnings for the 'as f8' tests
850-
with suppress_warnings() as sup:
851-
sup.filter(numpy.exceptions.ComplexWarning)
851+
with warnings.catch_warnings():
852+
warnings.simplefilter("ignore", numpy.exceptions.ComplexWarning)
852853

853854
# matvec(a,b) / a.dot(b) where a is matrix, b is vector
854855
for n in range(1, 17):

0 commit comments

Comments
 (0)