From 8c3939f6c97a8fff0b12e310f5e1cfee6a6ac06e Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Tue, 2 Dec 2025 08:53:41 +0100 Subject: [PATCH 1/4] clean up one test --- src/silx/conftest.py | 8 +++++++- src/silx/io/test/test_nxdata.py | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/silx/conftest.py b/src/silx/conftest.py index 0a6a84e6d0..7be088750e 100644 --- a/src/silx/conftest.py +++ b/src/silx/conftest.py @@ -77,12 +77,18 @@ def pytest_configure(config): "ignore:Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.:UserWarning", # Remove __array__ ignore once h5py v3.12 is released "ignore:__array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.:DeprecationWarning", - "ignore::pyopencl.RepeatedKernelRetrieval", # Deprecated pyparsing usage in matplotlib: https://github.com/matplotlib/matplotlib/issues/30617 "ignore::DeprecationWarning:matplotlib._fontconfig_pattern", "ignore::DeprecationWarning:matplotlib._mathtext", "ignore::DeprecationWarning:pyparsing.util", ) +try: + import pyopencl +except: + pass +else: + if "RepeatedKernelRetrieval" in dir(pyopencl): + _FILTERWARNINGS = _FILTERWARNINGS + ("ignore::pyopencl.RepeatedKernelRetrieval",) def pytest_collection_modifyitems(items): diff --git a/src/silx/io/test/test_nxdata.py b/src/silx/io/test/test_nxdata.py index baec00c269..e7e77a1897 100644 --- a/src/silx/io/test/test_nxdata.py +++ b/src/silx/io/test/test_nxdata.py @@ -24,9 +24,10 @@ __authors__ = ["P. Knobel"] __license__ = "MIT" -__date__ = "24/03/2020" +__date__ = "02/12/2025" +import os import tempfile import unittest @@ -490,6 +491,12 @@ def setUp(self): tmp.file.close() self.h5fname = tmp.name + def tearDown(self): + try: + os.unlink(self.h5fname) + except Exception as err: + print(f"{type(err).__name__}: {err}\nWhile deleting `{self.h5fname}`") + def testSimpleSave(self): sig = numpy.array([0, 1, 2]) a0 = numpy.array([2, 3, 4]) From b303c418d886b8dc191297d3199fc95ee396fbeb Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Wed, 3 Dec 2025 11:25:25 +0100 Subject: [PATCH 2/4] Update src/silx/conftest.py Co-authored-by: Thomas VINCENT --- src/silx/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/silx/conftest.py b/src/silx/conftest.py index 7be088750e..c51e1ebcc2 100644 --- a/src/silx/conftest.py +++ b/src/silx/conftest.py @@ -84,7 +84,7 @@ def pytest_configure(config): ) try: import pyopencl -except: +except Exception: pass else: if "RepeatedKernelRetrieval" in dir(pyopencl): From b94f2eb58ce3b15695f542be0d73d1381cb3545a Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Wed, 3 Dec 2025 11:35:47 +0100 Subject: [PATCH 3/4] reformat code --- src/silx/conftest.py | 4 +++- src/silx/io/test/test_nxdata.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/silx/conftest.py b/src/silx/conftest.py index c51e1ebcc2..f1fbe472d7 100644 --- a/src/silx/conftest.py +++ b/src/silx/conftest.py @@ -88,7 +88,9 @@ def pytest_configure(config): pass else: if "RepeatedKernelRetrieval" in dir(pyopencl): - _FILTERWARNINGS = _FILTERWARNINGS + ("ignore::pyopencl.RepeatedKernelRetrieval",) + _FILTERWARNINGS = _FILTERWARNINGS + ( + "ignore::pyopencl.RepeatedKernelRetrieval", + ) def pytest_collection_modifyitems(items): diff --git a/src/silx/io/test/test_nxdata.py b/src/silx/io/test/test_nxdata.py index e7e77a1897..bc7d19f217 100644 --- a/src/silx/io/test/test_nxdata.py +++ b/src/silx/io/test/test_nxdata.py @@ -495,7 +495,7 @@ def tearDown(self): try: os.unlink(self.h5fname) except Exception as err: - print(f"{type(err).__name__}: {err}\nWhile deleting `{self.h5fname}`") + print(f"{type(err).__name__}: {err}\nWhile deleting `{self.h5fname}`") def testSimpleSave(self): sig = numpy.array([0, 1, 2]) From 56a16f5ac969606ea9257da7e6748026de9d63c3 Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Mon, 8 Dec 2025 08:54:41 +0100 Subject: [PATCH 4/4] Check pyopencl version before filtering warnings --- src/silx/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/silx/conftest.py b/src/silx/conftest.py index f1fbe472d7..ca1173e110 100644 --- a/src/silx/conftest.py +++ b/src/silx/conftest.py @@ -87,7 +87,8 @@ def pytest_configure(config): except Exception: pass else: - if "RepeatedKernelRetrieval" in dir(pyopencl): + pyopen_version = tuple(int(i) for i in pyopencl.__version__.split(".")[:2]) + if pyopen_version >= (2025, 2): _FILTERWARNINGS = _FILTERWARNINGS + ( "ignore::pyopencl.RepeatedKernelRetrieval", )