Skip to content
Draft

numpy 2 #2218

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
runs-on: [self-hosted, python, cuda]
strategy:
matrix:
python-version: [3.11]
numpy-version: [1.25]
python-version: [3.12]
numpy-version: [1.26]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with: {fetch-depth: 0, submodules: recursive}
- id: reqs
name: set requirements
Expand Down Expand Up @@ -67,12 +67,12 @@ jobs:
matrix:
include:
- {python-version: '3.10', numpy-version: 1.23}
- {python-version: 3.12, numpy-version: 1.26}
- {python-version: 3.12, numpy-version: 2}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with: {fetch-depth: 0, submodules: recursive}
- name: set requirements
run: sed -ri -e '/ python /d' -e 's/(.* numpy) .*/\1=${{ matrix.numpy-version }}/' -e 's/=cuda*//' -e '/tigre/d' scripts/requirements-test.yml
run: sed -ri -e '/ python /d' -e 's/(.* numpy) .*/\1=${{ matrix.numpy-version }}/' -e 's/ cuda*//' -e '/tigre/d' scripts/requirements-test.yml
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -109,8 +109,8 @@ jobs:
fi
fi
if $include_max; then
echo "include=[{'python-version': 3.12, 'os': 'ubuntu'}, {'python-version': 3.12, 'os': 'windows'}]" >> $GITHUB_OUTPUT
echo "include-numpy=[{'python-version': 3.12, 'numpy-version': 1.26, 'os': 'ubuntu'}, {'python-version': 3.12, 'numpy-version': 1.26, 'os': 'windows'}]" >> $GITHUB_OUTPUT
echo "include=[{'python-version': 3.13, 'os': 'ubuntu'}, {'python-version': 3.13, 'os': 'windows'}]" >> $GITHUB_OUTPUT
echo "include-numpy=[{'python-version': 3.13, 'numpy-version': 2, 'os': 'ubuntu'}, {'python-version': 3.13, 'numpy-version': 2, 'os': 'windows'}]" >> $GITHUB_OUTPUT
else
echo "include=[]" >> $GITHUB_OUTPUT
echo "include-numpy=[]" >> $GITHUB_OUTPUT
Expand All @@ -125,7 +125,7 @@ jobs:
os: ${{ fromJson(needs.conda-matrix.outputs.os) }}
include: ${{ fromJson(needs.conda-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: recursive
Expand Down Expand Up @@ -158,15 +158,15 @@ jobs:
os: ${{ fromJson(needs.conda-matrix.outputs.os) }}
include: ${{ fromJson(needs.conda-matrix.outputs.include-numpy) }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge
conda-remove-defaults: "true"
- run: conda install boa
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v5
with:
name: cil-py${{ matrix.python-version }}-${{ matrix.os }}
path: dist
Expand All @@ -180,13 +180,13 @@ jobs:
runs-on: ubuntu-latest
needs: conda-test
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: conda-incubator/setup-miniconda@v3
with:
mamba-version: "*"
channels: conda-forge
conda-remove-defaults: "true"
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v5
with: {pattern: cil-py*-*, path: dist, merge-multiple: true}
- run: mamba install anaconda-client
- name: anaconda upload -c ccpi
Expand All @@ -205,7 +205,7 @@ jobs:
defaults: {run: {shell: 'bash -el {0}', working-directory: docs}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: recursive
Expand All @@ -229,7 +229,7 @@ jobs:
conda list
- run: pip install ..
- name: checkout docs
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
path: docs/build
ref: gh-pages
Expand Down Expand Up @@ -262,7 +262,7 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: recursive
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Dependencies:
- olefile and dxchange are optional dependencies, instead of required (#2209)
- improve `tqdm` notebook support (#2241)
- Added support for numpy 2
- Update to CCPi-Regularisation toolkit 25.0.0
- Added support for python 3.13
- Added support for astra-toolbox 2.4
- Documentation:
- Render the user showcase notebooks in the documentation (#2189)
- Enhancements:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ LABEL org.opencontainers.image.source=https://github.com/TomographicImaging/CIL
LABEL org.opencontainers.image.licenses="Apache-2.0 AND BSD-3-Clause AND GPL-3.0"

# CUDA-specific packages
ARG CIL_EXTRA_PACKAGES="tigre=2.6 astra-toolbox=2.1.0=cuda*"
ARG CIL_EXTRA_PACKAGES="tigre=2.6 astra-toolbox::astra-toolbox=2.4=cuda* ccpi::ccpi-regulariser=25.0.0=cuda*"
# build & runtime dependencies
# TODO: sync scripts/create_local_env_for_cil_development.sh, scripts/requirements-test.yml, recipe/meta.yaml (e.g. missing libstdcxx-ng _openmp_mutex pip)?
# vis. https://github.com/TomographicImaging/CIL/pull/1590
COPY --chown="${NB_USER}" scripts/requirements-test.yml environment.yml
# channel_priority: https://stackoverflow.com/q/58555389
RUN sed -ri '/tigre|astra-toolbox| python /d' environment.yml \
RUN sed -ri -e '/tigre| python /d' -e 's/ cuda*//' environment.yml \
&& for pkg in 'jupyter-server-proxy>4.1.0' $CIL_EXTRA_PACKAGES; do echo " - $pkg" >> environment.yml; done \
&& conda config --env --set channel_priority strict \
&& for ch in defaults nvidia ccpi https://software.repos.intel.com/python/conda conda-forge; do conda config --env --add channels $ch; done \
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Binary installation of CIL can be achieved with `conda`.
We recommend using either [`miniconda`](https://docs.conda.io/projects/miniconda/en/latest) or [`miniforge`](https://github.com/conda-forge/miniforge), which are both minimal installers for `conda`. We also recommend a `conda` version of at least `23.10` for quicker installation.

#### Create a conda environment with CIL
We maintain an environment file with the required packages to run the [CIL demos](https://github.com/TomographicImaging/CIL-Demos) which you can use to create a new environment. This will have specific and tested versions of all dependencies that are outlined in the table below:
We maintain an environment file with the required packages to run the [CIL demos](https://github.com/TomographicImaging/CIL-Demos) which you can use to create a new environment. This will have specific and tested versions of all dependencies that are outlined in the table below:

```sh
conda env create -f https://tomographicimaging.github.io/scripts/env/cil_demos.yml
Expand Down Expand Up @@ -47,13 +47,13 @@ While building the CIL package we test with specific versions of dependencies. T

| Package | Tested Version | Conda install command | Description | License |
|----|----|--------|--------|----|
| [Python](https://www.python.org/) | 3.10 - 3.12 | `"python>=3.10,<=3.12"` || [PSF-2.0](https://docs.python.org/3/license.html) |
| [Numpy](https://github.com/numpy/numpy) | 1.23 - 1.26 | `"numpy>=1.23,<2"` || [BSD-3-Clause](https://numpy.org/doc/stable/license.html) |
| [Python](https://www.python.org/) | 3.10 - 3.13 | `"python>=3.10,<=3.13"` || [PSF-2.0](https://docs.python.org/3/license.html) |
| [Numpy](https://github.com/numpy/numpy) | 1.23 - 2.3 | `"numpy>=1.23,<=2.3"` || [BSD-3-Clause](https://numpy.org/doc/stable/license.html) |
| [IPP](https://www.intel.com/content/www/us/en/developer/tools/oneapi/ipp.html#gs.gxwq5p) | 2021.12 | `-c https://software.repos.intel.com/python/conda ipp=2021.12` | The Intel Integrated Performance Primitives Library (required for the CIL recon class). | [ISSL](http://www.intel.com/content/www/us/en/developer/articles/license/end-user-license-agreement.html) |
|--|--| **Optional dependencies** |--|--|
| [ASTRA toolbox](http://www.astra-toolbox.com) | 2.1 | CPU: `conda-forge::astra-toolbox=2.1=py*` <br> GPU: `conda-forge::astra-toolbox=2.1=cuda*` | CT projectors, FBP and FDK. | [GPL-3.0](https://github.com/astra-toolbox/astra-toolbox/blob/master/COPYING) |
| [ASTRA toolbox](http://www.astra-toolbox.com) | 2.1 - 2.4 | CPU: `astra-toolbox::astra-toolbox=2.4=py*` <br> GPU: `astra-toolbox::astra-toolbox=2.4=cuda*` | CT projectors, FBP and FDK. | [GPL-3.0](https://github.com/astra-toolbox/astra-toolbox/blob/master/COPYING) |
| [TIGRE](https://github.com/CERN/TIGRE) | 2.6 | `ccpi::tigre=2.6` | CT projectors, FBP and FDK. | [BSD-3-Clause](https://github.com/CERN/TIGRE/blob/master/LICENSE.txt) |
| [CCPi Regularisation Toolkit](https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit) | 24.0.1 | `ccpi::ccpi-regulariser=24.0.1` | Toolbox of regularisation methods. | [Apache-2.0](https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit/blob/master/LICENSE) |
| [CCPi Regularisation Toolkit](https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit) | 25.0.0 | CPU: `ccpi::ccpi-regulariser=25.0.0=cpu*` <br> GPU: `ccpi::ccpi-regulariser=25.0.0=cuda*` | Toolbox of regularisation methods. | [Apache-2.0](https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit/blob/master/LICENSE) |
| [TomoPhantom](https://github.com/dkazanc/TomoPhantom) | [2.0.0](https://github.com/dkazanc/TomoPhantom/releases/tag/v2.0.0) | `ccpi::tomophantom=2.0.0` | Generates phantoms to use as test data. | [Apache-2.0](https://github.com/dkazanc/TomoPhantom/blob/master/LICENSE) |
| [ipykernel](https://github.com/ipython/ipykernel) || `ipykernel` | Provides the IPython kernel to run Jupyter notebooks. | [BSD-3-Clause](https://github.com/ipython/ipykernel/blob/main/LICENSE) |
| [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) || `ipywidgets` | Enables visualisation tools within jupyter noteboooks. | [BSD-3-Clause](https://github.com/jupyter-widgets/ipywidgets/blob/main/LICENSE) |
Expand All @@ -62,7 +62,6 @@ While building the CIL package we test with specific versions of dependencies. T
|[olefile](https://github.com/decalage2/olefile)|>= 0.46|`olefile>=0.46`|Package to process Microsoft OLE2 files, used to read ZEISS data files.|[BSD-style (custom)](https://github.com/decalage2/olefile?tab=License-1-ov-file)|
|[dxchange](https://github.com/data-exchange/dxchange)||`dxchange`|Provides an interface with TomoPy for loading tomography data.|[BSD-style (custom)](https://github.com/data-exchange/dxchange?tab=License-1-ov-file)|


### Docker

Finally, CIL can be run via a Jupyter Notebook enabled Docker container:
Expand Down
24 changes: 12 additions & 12 deletions Wrappers/Python/cil/framework/acquisition_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class AcquisitionData(DataContainer, Partitioner):
"""
DataContainer for holding 2D or 3D sinogram

Parameters
----------
array : numpy.ndarray or DataContainer
Expand All @@ -36,10 +36,10 @@ class AcquisitionData(DataContainer, Partitioner):
If True, the array will be deep copied. If False, the array will be shallow copied.
geometry : AcquisitionGeometry
The geometry of the data. If the dtype of the array and geometry are different, the geometry dtype will be overridden.

**kwargs:
dtype : numpy.dtype
Specify the data type of the AcquisitionData array, this is useful if you pass None to array and want to over-ride the dtype of the geometry.
Specify the data type of the AcquisitionData array, this is useful if you pass None to array and want to over-ride the dtype of the geometry.
If an array is passed, dtype must match the dtype of the array.

"""
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(self,
if dtype is None:
dtype = geometry.dtype
array = numpy.empty(geometry.shape, dtype)

elif issubclass(type(array) , DataContainer):
array = array.as_array()

Expand All @@ -107,12 +107,12 @@ def __eq__(self, other):
'''
Check if two AcquisitionData objects are equal. This is done by checking if the geometry, data and dtype are equal.
Also, if the other object is a numpy.ndarray, it will check if the data and dtype are equal.

Parameters
----------
other: AcquisitionData or numpy.ndarray
The object to compare with.

Returns
-------
bool
Expand All @@ -123,12 +123,12 @@ def __eq__(self, other):
if numpy.array_equal(self.as_array(), other.as_array()) \
and self.geometry == other.geometry \
and self.dtype == other.dtype:
return True
return True
elif numpy.array_equal(self.as_array(), other) and self.dtype==other.dtype:
return True
else:
return False

def _get_slice(self, **kwargs):
'''
Functionality of get_slice
Expand Down Expand Up @@ -165,8 +165,8 @@ def _get_slice(self, **kwargs):
return out
else:
return AcquisitionData(out.array, deep_copy=False, geometry=geometry_new)


def get_slice(self, *args, **kwargs):
'''
Returns a new AcquisitionData of a single slice in the requested direction.
Expand Down Expand Up @@ -205,10 +205,10 @@ def get_slice(self, *args, **kwargs):
raise TypeError(f"Cannot use 'projection' for geometries that use angles. Use 'angle' instead.")
elif key not in AcquisitionDimension and key != 'force':
raise TypeError(f"'{key}' not in allowed labels {AcquisitionDimension}.")

if args:
warnings.warn("Positional arguments for get_slice are deprecated. Use keyword arguments instead.", DeprecationWarning, stacklevel=2)

num_args = len(args)

if num_args > 0:
Expand Down
4 changes: 1 addition & 3 deletions Wrappers/Python/cil/framework/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,7 @@ def __neg__(self):
return -1 * self

def dot(self, other):
#
tmp = [ self.containers[i].dot(other.containers[i]) for i in range(self.shape[0])]
return sum(tmp)
return sum(self.containers[i].dot(other.containers[i]) for i in range(self.shape[0]))

def __len__(self):

Expand Down
Loading
Loading