From a9abc136234c80aca489fbd4fc6e0b2f57039409 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Tue, 9 Apr 2024 10:08:23 +0200 Subject: [PATCH 1/5] remove try import scipy.misc.ascent --- src/silx/math/fft/test/test_fft.py | 7 ++----- .../math/medianfilter/test/test_medianfilter.py | 7 ++----- src/silx/opencl/sift/match.py | 7 ++----- src/silx/opencl/sift/plan.py | 7 ++----- src/silx/opencl/sift/test/test_align.py | 8 ++------ src/silx/opencl/sift/test/test_convol.py | 8 ++------ src/silx/opencl/sift/test/test_image_setup.py | 8 ++------ src/silx/opencl/sift/test/test_keypoints.py | 7 ++----- src/silx/opencl/sift/test/test_matching.py | 7 ++----- src/silx/opencl/sift/test/test_preproc.py | 7 ++----- src/silx/opencl/sift/test/test_transform.py | 8 ++------ src/silx/opencl/test/test_convolution.py | 8 ++------ src/silx/opencl/test/test_medfilt.py | 13 +++++-------- 13 files changed, 29 insertions(+), 73 deletions(-) diff --git a/src/silx/math/fft/test/test_fft.py b/src/silx/math/fft/test/test_fft.py index abe7842ac3..3379396a03 100644 --- a/src/silx/math/fft/test/test_fft.py +++ b/src/silx/math/fft/test/test_fft.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # /*########################################################################## # -# Copyright (c) 2018-2022 European Synchrotron Radiation Facility +# Copyright (c) 2018-2024 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -33,10 +33,7 @@ from tempfile import TemporaryDirectory try: - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent __have_scipy = True except ImportError: __have_scipy = False diff --git a/src/silx/math/medianfilter/test/test_medianfilter.py b/src/silx/math/medianfilter/test/test_medianfilter.py index 62b1338498..bf0ccb9f0c 100644 --- a/src/silx/math/medianfilter/test/test_medianfilter.py +++ b/src/silx/math/medianfilter/test/test_medianfilter.py @@ -1,5 +1,5 @@ # ########################################################################## -# Copyright (C) 2017-2022 European Synchrotron Radiation Facility +# Copyright (C) 2017-2024 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -38,10 +38,7 @@ except: scipy = None else: - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent import scipy.ndimage import logging diff --git a/src/silx/opencl/sift/match.py b/src/silx/opencl/sift/match.py index 85d19d4ab4..806964e444 100644 --- a/src/silx/opencl/sift/match.py +++ b/src/silx/opencl/sift/match.py @@ -4,7 +4,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2022 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -342,10 +342,7 @@ def match_py(nkp1, nkp2, raw_results=False): def demo(): - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent from .plan import SiftPlan img1 = ascent() diff --git a/src/silx/opencl/sift/plan.py b/src/silx/opencl/sift/plan.py index 770b412821..4b9e06143a 100644 --- a/src/silx/opencl/sift/plan.py +++ b/src/silx/opencl/sift/plan.py @@ -4,7 +4,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2023 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -1062,10 +1062,7 @@ def count_kp(self, output): def demo(): # Prepare debugging - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent img = ascent() s = SiftPlan(template=img) diff --git a/src/silx/opencl/sift/test/test_align.py b/src/silx/opencl/sift/test/test_align.py index 8b48a0f1c3..82170cd105 100755 --- a/src/silx/opencl/sift/test/test_align.py +++ b/src/silx/opencl/sift/test/test_align.py @@ -3,7 +3,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2022 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -46,11 +46,7 @@ scipy = None else: import scipy.ndimage - - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent from ...common import ocl diff --git a/src/silx/opencl/sift/test/test_convol.py b/src/silx/opencl/sift/test/test_convol.py index 84fd593b95..44a0dd5e13 100755 --- a/src/silx/opencl/sift/test/test_convol.py +++ b/src/silx/opencl/sift/test/test_convol.py @@ -3,7 +3,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2022 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -47,11 +47,7 @@ scipy = None else: import scipy.ndimage - - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent import unittest from silx.opencl import ocl diff --git a/src/silx/opencl/sift/test/test_image_setup.py b/src/silx/opencl/sift/test/test_image_setup.py index 3855f0cfe8..e19280fb48 100644 --- a/src/silx/opencl/sift/test/test_image_setup.py +++ b/src/silx/opencl/sift/test/test_image_setup.py @@ -3,7 +3,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2022 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -45,11 +45,7 @@ scipy = None else: import scipy.ndimage - - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent from .test_image_functions import ( my_gradient, diff --git a/src/silx/opencl/sift/test/test_keypoints.py b/src/silx/opencl/sift/test/test_keypoints.py index 36d23a6187..2d58bd08a9 100755 --- a/src/silx/opencl/sift/test/test_keypoints.py +++ b/src/silx/opencl/sift/test/test_keypoints.py @@ -3,7 +3,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2022 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -50,10 +50,7 @@ except ImportError: scipy = None else: - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent # for Python implementation of tested functions from .test_image_functions import ( diff --git a/src/silx/opencl/sift/test/test_matching.py b/src/silx/opencl/sift/test/test_matching.py index 72fe231873..47887bc2c4 100755 --- a/src/silx/opencl/sift/test/test_matching.py +++ b/src/silx/opencl/sift/test/test_matching.py @@ -3,7 +3,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2022 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -46,10 +46,7 @@ except ImportError: scipy = None else: - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent # for Python implementation of tested functions diff --git a/src/silx/opencl/sift/test/test_preproc.py b/src/silx/opencl/sift/test/test_preproc.py index fe1e667372..e0fc11f529 100755 --- a/src/silx/opencl/sift/test/test_preproc.py +++ b/src/silx/opencl/sift/test/test_preproc.py @@ -3,7 +3,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2022 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -46,10 +46,7 @@ except ImportError: scipy = None else: - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent import math from silx.opencl import ocl, kernel_workgroup_size diff --git a/src/silx/opencl/sift/test/test_transform.py b/src/silx/opencl/sift/test/test_transform.py index 98b64896bf..084e485515 100755 --- a/src/silx/opencl/sift/test/test_transform.py +++ b/src/silx/opencl/sift/test/test_transform.py @@ -3,7 +3,7 @@ # Project: Sift implementation in Python + OpenCL # https://github.com/silx-kit/silx # -# Copyright (C) 2013-2022 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -50,11 +50,7 @@ scipy = None else: import scipy.ndimage - - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent from silx.opencl import ocl, kernel_workgroup_size diff --git a/src/silx/opencl/test/test_convolution.py b/src/silx/opencl/test/test_convolution.py index 86716f47cf..2278ec4951 100644 --- a/src/silx/opencl/test/test_convolution.py +++ b/src/silx/opencl/test/test_convolution.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # /*########################################################################## # -# Copyright (c) 2019-2022 European Synchrotron Radiation Facility +# Copyright (c) 2019-2024 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -41,11 +41,7 @@ try: from scipy.ndimage import convolve, convolve1d - - try: - from scipy.misc import ascent - except: - from scipy.datasets import ascent + from scipy.datasets import ascent scipy_convolve = convolve scipy_convolve1d = convolve1d diff --git a/src/silx/opencl/test/test_medfilt.py b/src/silx/opencl/test/test_medfilt.py index 2ef4490d73..46c75ad3da 100644 --- a/src/silx/opencl/test/test_medfilt.py +++ b/src/silx/opencl/test/test_medfilt.py @@ -31,7 +31,7 @@ __authors__ = ["Jérôme Kieffer"] __contact__ = "jerome.kieffer@esrf.eu" __license__ = "MIT" -__copyright__ = "2013-2022 European Synchrotron Radiation Facility, Grenoble, France" +__copyright__ = "2013-2024 European Synchrotron Radiation Facility, Grenoble, France" __date__ = "09/05/2023" @@ -58,15 +58,12 @@ Result = namedtuple("Result", ["size", "error", "sp_time", "oc_time"]) try: - from scipy.misc import ascent + from scipy.datasets import ascent except: - try: - from scipy.datasets import ascent - except: - def ascent(): - """Dummy image from random data""" - return numpy.random.random((512, 512)) + def ascent(): + """Dummy image from random data""" + return numpy.random.random((512, 512)) try: From 3255ecf2441b6d492b45ff256fdc90246a3e7292 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Tue, 9 Apr 2024 10:11:32 +0200 Subject: [PATCH 2/5] Add scipy>=1.10 to test extras_require --- setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 72432a26a4..6b9f7ac33f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # /*########################################################################## # -# Copyright (c) 2015-2023 European Synchrotron Radiation Facility +# Copyright (c) 2015-2024 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -188,7 +188,14 @@ def get_project_configuration(): "Pillow", ] - test_requires = ["pytest", "pytest-xvfb", "pytest-mock", "bitshuffle"] + test_requires = [ + "pytest", + "pytest-xvfb", + "pytest-mock", + "bitshuffle", + "scipy>=1.10", + "pooch", + ] doc_requires = { "nbsphinx", From d56fe1956d04fb71b96894a7529c82ad28adfe39 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Tue, 9 Apr 2024 11:10:41 +0200 Subject: [PATCH 3/5] Add pooch to requirements file --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index f49821371b..9d4240b3d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,6 +25,7 @@ matplotlib >= 3.1.0 # For silx.gui.plot PyOpenGL # For silx.gui.plot3d python-dateutil # For silx.gui.plot scipy # For silx.math.fit demo, silx.image.sift demo, silx.image.sift.test +pooch # For scipy.datasets.ascent Pillow # For silx.opencl.image.test pint # For silx.io.dictdump PyQt5 # PySide6, PyQt6>=6.3 # For silx.gui From 4f8f026e6979fcaaa24c0bc9dd1c319af7b6374c Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Tue, 9 Apr 2024 11:12:09 +0200 Subject: [PATCH 4/5] Add pooch to packaging dependencies --- package/debian12/control | 1 + 1 file changed, 1 insertion(+) diff --git a/package/debian12/control b/package/debian12/control index 8f8c83ce0a..4d905712eb 100644 --- a/package/debian12/control +++ b/package/debian12/control @@ -22,6 +22,7 @@ Build-Depends: cython3 (>= 0.23.2), python3-opengl, python3-packaging, python3-pil, + python3-pooch, python3-pydata-sphinx-theme, python3-pyopencl, python3-pyqt5.qtopengl, From 24850fb2e58efe3cffd0f2294d9c8bc4233bbd72 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 12 Apr 2024 09:31:34 +0200 Subject: [PATCH 5/5] Fix dtype issue --- src/silx/math/medianfilter/test/test_medianfilter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/silx/math/medianfilter/test/test_medianfilter.py b/src/silx/math/medianfilter/test/test_medianfilter.py index bf0ccb9f0c..ca8d62e2a1 100644 --- a/src/silx/math/medianfilter/test/test_medianfilter.py +++ b/src/silx/math/medianfilter/test/test_medianfilter.py @@ -714,7 +714,7 @@ def testRandomMatrice(self): def testAscent(self): """Test vs scipy with""" - img = ascent() + img = ascent().astype(numpy.int64) kernels = [(3, 1), (3, 5), (5, 9), (9, 3)] modesToTest = _getScipyAndSilxCommonModes()