Skip to content

numpy 2#2218

Draft
casperdcl wants to merge 19 commits into
masterfrom
numpy-2
Draft

numpy 2#2218
casperdcl wants to merge 19 commits into
masterfrom
numpy-2

Conversation

@casperdcl
Copy link
Copy Markdown
Member

@casperdcl casperdcl commented Sep 30, 2025

unsure about

upstream problems

  • test tomophantom with numpy>=2
  • test tigre with numpy>=2
  • test astra-toolbox CUDA with numpy>=2
  • test_CIL_CVXPy -> cvxpy -> scipy:
test_cil_vs_cvxpy_totalvariation_anisotropic (test_CIL_CVXPy.Test_CIL_vs_CVXPy.test_cil_vs_cvxpy_totalvariation_anisotropic) ... 
...
$CONDA_PREFIX/lib/python3.12/site-packages/scipy/sparse/_dia.py:140: UserWarning: result dtype changed due to the removal of value-based promotion from NumPy. Changed from int64 to int32.
  nnz += min(M+k,N)
...
$CONDA_PREFIX/lib/python3.12/site-packages/cvxpy/utilities/coeff_extractor.py:296: UserWarning: result dtype changed due to the removal of value-based promotion from NumPy. Changed from int32 to int64.
  P.row += offset

@casperdcl casperdcl self-assigned this Sep 30, 2025
@casperdcl casperdcl force-pushed the numpy-2 branch 4 times, most recently from 32b30db to 712e848 Compare October 1, 2025 13:37
@github-project-automation github-project-automation Bot moved this to Todo in CIL work Oct 1, 2025
@casperdcl casperdcl added the help wanted Extra attention is needed label Oct 1, 2025
@casperdcl casperdcl moved this from Todo to In Progress in CIL work Oct 1, 2025
@gfardell gfardell requested review from gfardell and paskino October 14, 2025 14:24
@gfardell gfardell moved this from In Progress to Priority review in CIL work Oct 14, 2025
Comment thread README.md Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/PD3O.py
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py
Comment thread Wrappers/Python/cil/optimisation/functions/Function.py Outdated
Comment thread Wrappers/Python/cil/optimisation/functions/Function.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that all the filters in this file return the same type as the input.

Comment thread Wrappers/Python/test/test_BlockDataContainer.py
Comment thread Wrappers/Python/test/test_functions.py Outdated
Comment thread Wrappers/Python/cil/framework/acquisition_data.py
Comment thread Wrappers/Python/cil/framework/block.py
Comment thread Wrappers/Python/cil/framework/data_container.py
Comment thread Wrappers/Python/cil/io/TIFF.py
Comment thread Wrappers/Python/cil/optimisation/algorithms/PDHG.py
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py
Comment thread Wrappers/Python/cil/optimisation/functions/Function.py
Comment thread Wrappers/Python/cil/optimisation/functions/LeastSquares.py Outdated
Comment thread Wrappers/Python/cil/optimisation/functions/LeastSquares.py
casperdcl and others added 11 commits May 28, 2026 15:37
Signed-off-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>
- fixes #2066
- fixes #2161
- fixes #1867
Set accelerated=False in IndicatorBox to fix issue SyneRBI/SIRF-SuperBuild#987

Signed-off-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>
Signed-off-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>

fix typo
Co-authored-by: Copilot <copilot@github.com>
Comment thread Wrappers/Python/test/test_DataProcessor.py
Comment thread Wrappers/Python/test/test_DataProcessor.py
dependencies:
- python >=3.10
- numpy >=1.23,<3
- numpy >=1.23,<2.4
Copy link
Copy Markdown
Member Author

@casperdcl casperdcl May 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see below, and discord

@gfardell
Copy link
Copy Markdown
Member

gfardell commented May 29, 2026

If run with numpy 2.4 we have a lot of TIGRE test failures due to numpy functionality that has been marked as deprecated, then removed in 2.4. This may be something we can address in our tigre wrappers, or it may need a contribution directly to Tigre to fix. I'll investigate more next week.

test_adjoint_weights (test_PluginsTigre_General.TestMechanics_tigre.test_adjoint_weights)
cil/plugins/tigre/ProjectionOperator.py:216:
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, 
and will error in future. Ensure you extract a single element from your array before 
performing this operation. (Deprecated NumPy 1.25.)

For now I've set the numpy version to <2.4 in the developer build environment, but we should discuss this futher before releasing.

The error it causes with 2.4 is:

  File "C:\Users\...\CIL\Wrappers\Python\cil\plugins\tigre\ProjectionOperator.py", line 178, in __call_Ax
    return Ax(data, self.tigre_geom, self.tigre_geom.angles,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Python/tigre/utilities/cuda_interface/_Ax.pyx", line 41, in _Ax._Ax_ext
  File "Python/tigre/utilities/cuda_interface/_types.pxd", line 158, in tigre.utilities.cuda_interface._types.convert_to_c_geometry
TypeError: only 0-dimensional arrays can be converted to Python scalars

FYI @AnderBiguri

@gfardell
Copy link
Copy Markdown
Member

gfardell commented May 29, 2026

Full test matrix doesn't caputre this as cuda tests are only run with one set of dependencies.
https://github.com/TomographicImaging/CIL/actions/runs/26634706380

@AnderBiguri
Copy link
Copy Markdown

@gfardell yup, a lot of numpy issues with the new casting. I think I have tackled quite a lot of them in master already, but have not done a decent unit-test run... I would appreciate help if you find issues, I think in 99.99% of the cases its just changing a line for casting.

lauramurgatroyd and others added 3 commits May 29, 2026 14:25
Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
@lauramurgatroyd
Copy link
Copy Markdown
Member

lauramurgatroyd commented May 29, 2026

I tested the CIL-Demos on this branch with numpy v2.3.5 and the other requirements listed on this PR (updated tigre etc)
and they all worked!
The only changes in print statements I noticed were:

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

Status: Blocked

Development

Successfully merging this pull request may close these issues.

show_geometry fails with numpy2 support numpy v2

5 participants