From 529fcbaa3933897c36a815ec717b76976440e757 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 12 Apr 2024 16:58:28 +0200 Subject: [PATCH 1/8] Use PySide<6.7 when it's causing issues --- .github/workflows/ci.yml | 12 ++---------- ci/appveyor.yml | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec47d3866b..fca5c8ae4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: os: macos-latest python-version: "3.9" BUILD_OPTION: --wheel - QT_BINDING: PySide6 + QT_BINDING: "PySide6<6.7" RUN_TESTS_OPTIONS: --qt-binding=PySide6 --no-opencl --low-mem - name-suffix: "PyQt6 wheel" @@ -120,15 +120,7 @@ jobs: fi pip install --pre -r requirements.txt pip uninstall -y PyQt5 PyQt6 PySide6 - if [ "${{ matrix.QT_BINDING }}" == "PyQt5" ]; then - pip install --pre pyqt5; - fi - if [ "${{ matrix.QT_BINDING }}" == "PySide6" ]; then - pip install --pre pyside6; - fi - if [ "${{ matrix.QT_BINDING }}" == "PyQt6" ]; then - pip install --pre pyqt6; - fi + pip install --pre "${{ matrix.QT_BINDING }}" - name: Install pytest run: | diff --git a/ci/appveyor.yml b/ci/appveyor.yml index 6015b2612e..72aa667bb6 100644 --- a/ci/appveyor.yml +++ b/ci/appveyor.yml @@ -32,7 +32,7 @@ environment: # Python 3.12 - PYTHON_DIR: "C:\\Python312-x64" - QT_BINDING: "PySide6" + QT_BINDING: "PySide6<6.7" WITH_GL_TEST: True PIP_OPTIONS: "-q --pre" @@ -120,7 +120,7 @@ before_test: test_script: # Run tests with selected Qt binding and without OpenCL - echo "WITH_GL_TEST=%WITH_GL_TEST%" - - "python run_tests.py --installed -v --no-opencl --low-mem --qt-binding=%QT_BINDING%" + - "python run_tests.py --installed -v --no-opencl --low-mem" after_test: # Leave test virtualenv From a56a64425264e624084ecf9c68add01dc6a3e0a6 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 12 Apr 2024 16:58:50 +0200 Subject: [PATCH 2/8] remove numpy<2 pinning --- ci/requirements-pinned.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/requirements-pinned.txt b/ci/requirements-pinned.txt index d8f0519f06..415417b184 100644 --- a/ci/requirements-pinned.txt +++ b/ci/requirements-pinned.txt @@ -2,8 +2,6 @@ --trusted-host www.silx.org --find-links http://www.silx.org/pub/wheelhouse/ -numpy<2 # Until all dependencies supports numpy v2 - # Pinpoint pyopencl on Windows to latest wheel available in www.silx.org # downloaded from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl # Anyway, we don't test OpenCL on appveyor From 389afbf2c139fd23f5f72332ab6d435ad70f3766 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 12 Apr 2024 17:11:10 +0200 Subject: [PATCH 3/8] Use pint from git to support numpy 2 --- ci/requirements-pinned.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/requirements-pinned.txt b/ci/requirements-pinned.txt index 415417b184..ce42eb451f 100644 --- a/ci/requirements-pinned.txt +++ b/ci/requirements-pinned.txt @@ -2,6 +2,9 @@ --trusted-host www.silx.org --find-links http://www.silx.org/pub/wheelhouse/ +numpy<2; python_version <= '3.10' +git+https://github.com/hgrecco/pint@f2e4081; python_version >= '3.10' + # Pinpoint pyopencl on Windows to latest wheel available in www.silx.org # downloaded from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl # Anyway, we don't test OpenCL on appveyor From f794b3db82900c3028b6814ac290c2bf164d432f Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 12 Apr 2024 18:58:57 +0200 Subject: [PATCH 4/8] change quotes --- ci/appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/appveyor.yml b/ci/appveyor.yml index 72aa667bb6..f5ff3ea027 100644 --- a/ci/appveyor.yml +++ b/ci/appveyor.yml @@ -96,7 +96,7 @@ before_test: # Install selected Qt binding - "pip uninstall -y PyQt5 PySide6 PyQt6" - - "pip install %PIP_OPTIONS% %QT_BINDING%" + - pip install %PIP_OPTIONS% "%QT_BINDING%" # Install pytest - "pip install %PIP_OPTIONS% pytest" From 5376f9e0a7c0f40b4b2f12d04445189dc8418ff4 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Mon, 15 Apr 2024 16:22:03 +0200 Subject: [PATCH 5/8] Fix numpy 2 array copy=False compatibility (this one was missed) --- src/silx/gui/plot/items/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/silx/gui/plot/items/core.py b/src/silx/gui/plot/items/core.py index 2b6ba818af..236a3caad3 100644 --- a/src/silx/gui/plot/items/core.py +++ b/src/silx/gui/plot/items/core.py @@ -1,6 +1,6 @@ # /*########################################################################## # -# Copyright (c) 2017-2023 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 @@ -1552,7 +1552,7 @@ def _filterNegativeValues( return None # Convert data to array to avoid specific case for complex scalar - if numpy.all(numpy.array(data, copy=False) >= 0): + if numpy.all(numpy.asarray(data) >= 0): return data return numpy.clip(data, 0, None) # Also works for scalars From 3e89f137acc7caee66bff66b6c56c67640f77134 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Tue, 16 Apr 2024 16:13:05 +0200 Subject: [PATCH 6/8] Use int instead of long to avoid type issues with numpy 2 on Windows --- src/silx/math/fit/filters.pyx | 9 ++++----- src/silx/math/fit/filters/include/filters.h | 6 +++--- src/silx/math/fit/filters/src/strip.c | 12 ++++++------ src/silx/math/fit/filters_wrapper.pxd | 10 +++++----- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/silx/math/fit/filters.pyx b/src/silx/math/fit/filters.pyx index 7d2e383535..574342d5b9 100644 --- a/src/silx/math/fit/filters.pyx +++ b/src/silx/math/fit/filters.pyx @@ -1,5 +1,5 @@ #/*########################################################################## -# Copyright (C) 2016-2018 European Synchrotron Radiation Facility +# Copyright (C) 2016-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 @@ -96,7 +96,7 @@ def strip(data, w=1, niterations=1000, factor=1.0, anchors=None): cdef: double[::1] input_c double[::1] output - long[::1] anchors_c + int[::1] anchors_c if not isinstance(data, numpy.ndarray): if not hasattr(data, "__len__"): @@ -115,16 +115,15 @@ def strip(data, w=1, niterations=1000, factor=1.0, anchors=None): dtype=numpy.float64) if anchors is not None and len(anchors): - # numpy.int_ is the same as C long (http://docs.scipy.org/doc/numpy/user/basics.types.html) anchors_c = numpy.asarray(anchors, - dtype=numpy.int_, + dtype=numpy.intc, order='C') len_anchors = anchors_c.size else: # Make a dummy length-1 array, because if I use shape=(0,) I get the error # IndexError: Out of bounds on buffer access (axis 0) anchors_c = numpy.empty(shape=(1,), - dtype=numpy.int_) + dtype=numpy.intc) len_anchors = 0 diff --git a/src/silx/math/fit/filters/include/filters.h b/src/silx/math/fit/filters/include/filters.h index 1ee9a9528b..6016bb94e9 100644 --- a/src/silx/math/fit/filters/include/filters.h +++ b/src/silx/math/fit/filters/include/filters.h @@ -1,5 +1,5 @@ /*########################################################################## -# Copyright (C) 2016 European Synchrotron Radiation Facility +# Copyright (C) 2016-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 @@ -30,8 +30,8 @@ void snip1d(double *data, int size, int width); void snip2d(double *data, int nrows, int ncolumns, int width); void snip3d(double *data, int nx, int ny, int nz, int width); -int strip(double* input, long len_input, double c, long niter, int deltai, - long* anchors, long len_anchors, double* output); +int strip(double* input, int len_input, double c, int niter, int deltai, + int* anchors, int len_anchors, double* output); /* Smoothing functions */ diff --git a/src/silx/math/fit/filters/src/strip.c b/src/silx/math/fit/filters/src/strip.c index dec07422d6..ba4d64a7ae 100644 --- a/src/silx/math/fit/filters/src/strip.c +++ b/src/silx/math/fit/filters/src/strip.c @@ -1,5 +1,5 @@ #/*########################################################################## -# Copyright (c) 2004-2016 European Synchrotron Radiation Facility +# Copyright (c) 2004-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,7 +38,7 @@ #include -/* strip(double* input, double c, long niter, double* output) +/* strip(double* input, double c, int niter, double* output) The strip background is probably PyMca's most popular background model. @@ -62,12 +62,12 @@ - output: output array */ -int strip(double* input, long len_input, - double c, long niter, int deltai, - long* anchors, long len_anchors, +int strip(double* input, int len_input, + double c, int niter, int deltai, + int* anchors, int len_anchors, double* output) { - long iter_index, array_index, anchor_index, anchor; + int iter_index, array_index, anchor_index, anchor; int anchor_nearby_flag; double t_mean; diff --git a/src/silx/math/fit/filters_wrapper.pxd b/src/silx/math/fit/filters_wrapper.pxd index e09de325f7..b1ba2d8887 100644 --- a/src/silx/math/fit/filters_wrapper.pxd +++ b/src/silx/math/fit/filters_wrapper.pxd @@ -1,5 +1,5 @@ #/*########################################################################## -# Copyright (C) 2016 European Synchrotron Radiation Facility +# Copyright (C) 2016-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 @@ -44,12 +44,12 @@ cdef extern from "filters.h": int width) int strip(double* input, - long len_input, + int len_input, double c, - long niter, + int niter, int deltai, - long* anchors, - long len_anchors, + int* anchors, + int len_anchors, double* output) int SavitskyGolay(double* input, From 23a4d0fb219495a953a2e01003be8ed87357af1c Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Tue, 16 Apr 2024 16:14:04 +0200 Subject: [PATCH 7/8] Use signed type to avoid issues on Windows with numpy2 --- src/silx/math/medianfilter/medianfilter.pyx | 126 ++++++++++---------- 1 file changed, 61 insertions(+), 65 deletions(-) diff --git a/src/silx/math/medianfilter/medianfilter.pyx b/src/silx/math/medianfilter/medianfilter.pyx index ce30225666..4db645f004 100644 --- a/src/silx/math/medianfilter/medianfilter.pyx +++ b/src/silx/math/medianfilter/medianfilter.pyx @@ -1,6 +1,6 @@ # /*########################################################################## # -# Copyright (c) 2015-2018 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 @@ -39,10 +39,6 @@ import numbers from libc.stdint cimport int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t -ctypedef unsigned long uint64 -ctypedef unsigned int uint32 -ctypedef unsigned short uint16 - MODES = {'nearest': 0, 'reflect': 1, 'mirror': 2, 'shrink': 3, 'constant': 4} @@ -329,16 +325,16 @@ def _median_filter_int64(int64_t[:, ::1] input_buffer not None, buffer_shape[1] = input_buffer.shape[1] for y in prange(input_buffer.shape[0], nogil=True): - median_filter.median_filter[long]( & input_buffer[0,0], - & output_buffer[0, 0], - &kernel_size[0], - buffer_shape, - y, - 0, - image_dim, - conditional, - mode, - cval) + median_filter.median_filter[int64_t](& input_buffer[0,0], + & output_buffer[0, 0], + &kernel_size[0], + buffer_shape, + y, + 0, + image_dim, + conditional, + mode, + cval) @cython.cdivision(True) @cython.boundscheck(False) @@ -359,16 +355,16 @@ def _median_filter_uint64(uint64_t[:, ::1] input_buffer not None, buffer_shape[1] = input_buffer.shape[1] for y in prange(input_buffer.shape[0], nogil=True): - median_filter.median_filter[uint64]( & input_buffer[0,0], - & output_buffer[0, 0], - &kernel_size[0], - buffer_shape, - y, - 0, - image_dim, - conditional, - mode, - cval) + median_filter.median_filter[uint64_t](& input_buffer[0,0], + & output_buffer[0, 0], + &kernel_size[0], + buffer_shape, + y, + 0, + image_dim, + conditional, + mode, + cval) @cython.cdivision(True) @@ -390,16 +386,16 @@ def _median_filter_int32(int32_t[:, ::1] input_buffer not None, buffer_shape[1] = input_buffer.shape[1] for y in prange(input_buffer.shape[0], nogil=True): - median_filter.median_filter[int]( & input_buffer[0,0], - & output_buffer[0, 0], - &kernel_size[0], - buffer_shape, - y, - 0, - image_dim, - conditional, - mode, - cval) + median_filter.median_filter[int32_t](& input_buffer[0,0], + & output_buffer[0, 0], + &kernel_size[0], + buffer_shape, + y, + 0, + image_dim, + conditional, + mode, + cval) @cython.cdivision(True) @@ -421,16 +417,16 @@ def _median_filter_uint32(uint32_t[:, ::1] input_buffer not None, buffer_shape[1] = input_buffer.shape[1] for y in prange(input_buffer.shape[0], nogil=True): - median_filter.median_filter[uint32]( & input_buffer[0,0], - & output_buffer[0, 0], - &kernel_size[0], - buffer_shape, - y, - 0, - image_dim, - conditional, - mode, - cval) + median_filter.median_filter[uint32_t](& input_buffer[0,0], + & output_buffer[0, 0], + &kernel_size[0], + buffer_shape, + y, + 0, + image_dim, + conditional, + mode, + cval) @cython.cdivision(True) @@ -452,16 +448,16 @@ def _median_filter_int16(int16_t[:, ::1] input_buffer not None, buffer_shape[1] = input_buffer.shape[1] for y in prange(input_buffer.shape[0], nogil=True): - median_filter.median_filter[short]( & input_buffer[0,0], - & output_buffer[0, 0], - &kernel_size[0], - buffer_shape, - y, - 0, - image_dim, - conditional, - mode, - cval) + median_filter.median_filter[int16_t](& input_buffer[0,0], + & output_buffer[0, 0], + &kernel_size[0], + buffer_shape, + y, + 0, + image_dim, + conditional, + mode, + cval) @cython.cdivision(True) @@ -484,13 +480,13 @@ def _median_filter_uint16( buffer_shape[1] = input_buffer.shape[1] for y in prange(input_buffer.shape[0], nogil=True): - median_filter.median_filter[uint16]( & input_buffer[0, 0], - & output_buffer[0, 0], - &kernel_size[0], - buffer_shape, - y, - 0, - image_dim, - conditional, - mode, - cval) + median_filter.median_filter[uint16_t](& input_buffer[0, 0], + & output_buffer[0, 0], + &kernel_size[0], + buffer_shape, + y, + 0, + image_dim, + conditional, + mode, + cval) From 7559f0aea8fb1d1d12554547b2d8305418241c19 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Tue, 16 Apr 2024 16:34:54 +0200 Subject: [PATCH 8/8] Use python3.11 on macos --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fca5c8ae4f..d7810918ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: RUN_TESTS_OPTIONS: --qt-binding=PyQt6 --no-opengl --low-mem - name-suffix: "PyQt6 wheel" os: macos-latest - python-version: "3.10" + python-version: "3.11" BUILD_OPTION: --wheel QT_BINDING: PyQt6 RUN_TESTS_OPTIONS: --qt-binding=PyQt6 --no-opencl --low-mem