diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 23d75ba7..368d18ca 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, '3.10'] + python-version: [3.9, '3.10', '3.11', '3.12', '3.13'] platform: [ubuntu-latest] #, macos-latest] # windows-latest broken for now steps: - uses: actions/checkout@v2 @@ -37,8 +37,8 @@ jobs: python --version conda install -y pyopencl python -m pip install --upgrade pip - pip install setuptools wheel pytest pytest-cov pytest-benchmark dask networkx igraph pandas scikit-image==0.19.3 - pip install -e . + pip install setuptools wheel pytest pytest-cov pytest-benchmark dask networkx igraph pandas scikit-image + - name: Test shell: bash -l {0} run: pytest -v --cov=./ --cov-report=xml @@ -65,5 +65,5 @@ jobs: # TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} # run: | # git tag - # python setup.py sdist bdist_wheel + # python -m build # twine upload dist/* diff --git a/pyclesperanto_prototype/__init__.py b/pyclesperanto_prototype/__init__.py index be127315..96c3be49 100644 --- a/pyclesperanto_prototype/__init__.py +++ b/pyclesperanto_prototype/__init__.py @@ -10,5 +10,5 @@ from ._tier10 import * from ._tier11 import * -__version__ = "0.24.5" +__version__ = "0.24.6" __common_alias__ = "cle" diff --git a/pyclesperanto_prototype/_tier8/_AffineTransform3D.py b/pyclesperanto_prototype/_tier8/_AffineTransform3D.py index c02ddfc8..7e9d0935 100644 --- a/pyclesperanto_prototype/_tier8/_AffineTransform3D.py +++ b/pyclesperanto_prototype/_tier8/_AffineTransform3D.py @@ -1,7 +1,6 @@ from warnings import warn import numpy as np -import transforms3d import math from ._utilities import shear_angle_to_shear_factor @@ -16,9 +15,55 @@ class AffineTransform3D: """ + @staticmethod + def _identity_matrix(): + return np.eye(4, dtype=float) + + @staticmethod + def _scale_matrix(sx=1.0, sy=1.0, sz=1.0): + return np.asarray([ + [sx, 0, 0, 0], + [0, sy, 0, 0], + [0, 0, sz, 0], + [0, 0, 0, 1], + ], dtype=float) + + @staticmethod + def _rotation_matrix_x(angle_in_rad): + c = np.cos(angle_in_rad) + s = np.sin(angle_in_rad) + return np.asarray([ + [1, 0, 0, 0], + [0, c, -s, 0], + [0, s, c, 0], + [0, 0, 0, 1], + ], dtype=float) + + @staticmethod + def _rotation_matrix_y(angle_in_rad): + c = np.cos(angle_in_rad) + s = np.sin(angle_in_rad) + return np.asarray([ + [c, 0, s, 0], + [0, 1, 0, 0], + [-s, 0, c, 0], + [0, 0, 0, 1], + ], dtype=float) + + @staticmethod + def _rotation_matrix_z(angle_in_rad): + c = np.cos(angle_in_rad) + s = np.sin(angle_in_rad) + return np.asarray([ + [c, -s, 0, 0], + [s, c, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 1], + ], dtype=float) + def __init__(self, transform = None, image=None): if transform is None: - self._matrix = transforms3d.zooms.zfdir2aff(1) + self._matrix = self._identity_matrix() if isinstance(transform, AffineTransform3D): self._matrix = np.copy(transform._matrix) if isinstance(transform, str): @@ -56,11 +101,11 @@ def scale(self, scale_x: float = None, scale_y: float = None, scale_z: float = N warn('scale_z must not be 0') scale_z = 1 if scale_x is not None: - self._concatenate(transforms3d.zooms.zfdir2aff(scale_x, direction=(1, 0, 0), origin=(0, 0, 0))) + self._concatenate(self._scale_matrix(sx=scale_x)) if scale_y is not None: - self._concatenate(transforms3d.zooms.zfdir2aff(scale_y, direction=(0, 1, 0), origin=(0, 0, 0))) + self._concatenate(self._scale_matrix(sy=scale_y)) if scale_z is not None: - self._concatenate(transforms3d.zooms.zfdir2aff(scale_z, direction=(0, 0, 1), origin=(0, 0, 0))) + self._concatenate(self._scale_matrix(sz=scale_z)) return self @@ -83,11 +128,11 @@ def rotate(self, axis : int = 2, angle_in_degrees : float = 0): angle_in_rad = angle_in_degrees * np.pi / 180.0 if axis == 0: - self._concatenate(self._3x3_to_4x4(transforms3d.euler.euler2mat(angle_in_rad, 0, 0))) + self._concatenate(self._rotation_matrix_x(angle_in_rad)) if axis == 1: - self._concatenate(self._3x3_to_4x4(transforms3d.euler.euler2mat(0, angle_in_rad, 0))) + self._concatenate(self._rotation_matrix_y(angle_in_rad)) if axis == 2: - self._concatenate(self._3x3_to_4x4(transforms3d.euler.euler2mat(0, 0, angle_in_rad))) + self._concatenate(self._rotation_matrix_z(angle_in_rad)) return self diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..c5223a21 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,52 @@ +[build-system] +requires = ["setuptools>=68", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "pyclesperanto_prototype" +version = "0.24.6" +description = "GPU-accelerated image processing in python using OpenCL" +readme = { file = "README.md", content-type = "text/markdown" } +requires-python = ">=3.9" +license = { text = "BSD-3-Clause" } +authors = [ + { name = "Robert Haase", email = "robert.haase@uni-leipzig.de" } +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "Topic :: Scientific/Engineering :: Image Processing", + "Topic :: Scientific/Engineering :: Information Analysis", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Operating System :: OS Independent", + "License :: OSI Approved :: BSD License" +] +dependencies = [ + "numpy>=2.0.0", + "pyopencl", + "toolz", + "scikit-image>0.20.0", + "matplotlib" +] + +[project.urls] +"Bug Tracker" = "https://github.com/clEsperanto/pyclesperanto_prototype/issues" +Documentation = "https://github.com/clEsperanto/pyclesperanto_prototype#README.md" +"Source Code" = "https://github.com/clEsperanto/pyclesperanto_prototype" +"User Support" = "https://github.com/clEsperanto/pyclesperanto_prototype/issues" + +[project.entry-points."bia_bob_plugins"] +plugin1 = "pyclesperanto_prototype._bia_bob_plugins:list_bia_bob_plugins" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +include = ["pyclesperanto_prototype*"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 43ef549d..00000000 --- a/setup.cfg +++ /dev/null @@ -1,47 +0,0 @@ -[metadata] -name = pyclesperanto_prototype -version = 0.24.5 -author = Robert Haase -author_email = robert.haase@uni-leipzig.de -url = https://github.com/clEsperanto/pyclesperanto_prototype -license = BSD-3-Clause -description = GPU-accelerated image processing in python using OpenCL -long_description = file: README.md -long_description_content_type = text/markdown - -classifiers = - Development Status :: 3 - Alpha - Intended Audience :: Science/Research - Intended Audience :: Developers - Topic :: Scientific/Engineering :: Image Processing - Topic :: Scientific/Engineering :: Information Analysis - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Operating System :: OS Independent - License :: OSI Approved :: BSD License -project_urls = - Bug Tracker = https://github.com/clEsperanto/pyclesperanto_prototype/issues - Documentation = https://github.com/clEsperanto/pyclesperanto_prototype#README.md - Source Code = https://github.com/clEsperanto/pyclesperanto_prototype - User Support = https://github.com/clEsperanto/pyclesperanto_prototype/issues - -[options] -packages = pyclesperanto_prototype -python_requires = >=3.6 - -# add your package requirements here -install_requires = - numpy!=1.19.4, <2.0.0 - pyopencl - toolz - scikit-image>=0.18.0, !=0.20.0 - matplotlib - transforms3d - -[options.entry_points] -bia_bob_plugins = - plugin1 = pyclesperanto_prototype._bia_bob_plugins:list_bia_bob_plugins diff --git a/setup.py b/setup.py deleted file mode 100644 index 1f0c84c2..00000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -import setuptools - -setuptools.setup(include_package_data=True) diff --git a/tests/test_skimage_imsave.py b/tests/test_skimage_imsave.py index 01cddcec..13c61db6 100644 --- a/tests/test_skimage_imsave.py +++ b/tests/test_skimage_imsave.py @@ -3,4 +3,4 @@ def test_skimage_imsave(): image = cle.push([1, 2, 3]) from skimage.io import imsave - imsave('test.tif', image) \ No newline at end of file + imsave('test.tif', image, photometric='minisblack') \ No newline at end of file