Skip to content

Commit

Permalink
Merge pull request #4108 from t20100/fix-ci
Browse files Browse the repository at this point in the history
Dependencies: Fixed numpy v2 support on Windows; Continous integration: Added tests with numpy v2; Fixed test by using PySide<6.7
  • Loading branch information
payno authored Apr 16, 2024
2 parents 933602f + 7559f0a commit 1675965
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 101 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
6 changes: 3 additions & 3 deletions ci/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ci/requirements-pinned.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
--trusted-host www.silx.org
--find-links http://www.silx.org/pub/wheelhouse/

numpy<2 # Until all dependencies supports numpy v2
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
Expand Down
4 changes: 2 additions & 2 deletions src/silx/gui/plot/items/core.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/silx/math/fit/filters.pyx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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__"):
Expand All @@ -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


Expand Down
6 changes: 3 additions & 3 deletions src/silx/math/fit/filters/include/filters.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */

Expand Down
12 changes: 6 additions & 6 deletions src/silx/math/fit/filters/src/strip.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -38,7 +38,7 @@

#include <stdio.h>

/* 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.
Expand All @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions src/silx/math/fit/filters_wrapper.pxd
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
126 changes: 61 additions & 65 deletions src/silx/math/medianfilter/medianfilter.pyx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}

Expand Down Expand Up @@ -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](<long*> & input_buffer[0,0],
<long*> & output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)
median_filter.median_filter[int64_t](& input_buffer[0,0],
& output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)

@cython.cdivision(True)
@cython.boundscheck(False)
Expand All @@ -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](<uint64*> & input_buffer[0,0],
<uint64*> & output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)
median_filter.median_filter[uint64_t](& input_buffer[0,0],
& output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)


@cython.cdivision(True)
Expand All @@ -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](<int*> & input_buffer[0,0],
<int*> & output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)
median_filter.median_filter[int32_t](& input_buffer[0,0],
& output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)


@cython.cdivision(True)
Expand All @@ -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](<uint32*> & input_buffer[0,0],
<uint32*> & output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)
median_filter.median_filter[uint32_t](& input_buffer[0,0],
& output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)


@cython.cdivision(True)
Expand All @@ -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](<short*> & input_buffer[0,0],
<short*> & output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)
median_filter.median_filter[int16_t](& input_buffer[0,0],
& output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)


@cython.cdivision(True)
Expand All @@ -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](<uint16*> & input_buffer[0, 0],
<uint16*> & output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)
median_filter.median_filter[uint16_t](& input_buffer[0, 0],
& output_buffer[0, 0],
<int*>&kernel_size[0],
<int*>buffer_shape,
y,
0,
image_dim,
conditional,
mode,
cval)

0 comments on commit 1675965

Please sign in to comment.