From 74c1e35d55b7325a375f622baa733d94d21d5faf Mon Sep 17 00:00:00 2001 From: Max Bohnet Date: Mon, 19 Aug 2024 17:23:01 +0200 Subject: [PATCH 1/6] add changelog.md --- README.md | 2 ++ cythonarrays/CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 cythonarrays/CHANGELOG.md diff --git a/README.md b/README.md index 479adcc..e6925ce 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ # cythonarrays Python Packages to facilitate cython cdef-classes that expose memoryviews as numpy arrays. +[Changelog](CHANGELOG.md) + ##cythonarrays: [![PyPI version](https://badge.fury.io/py/cythonarrays.svg)](https://badge.fury.io/py/cythonarrays) [![Anaconda-Server Badge](https://anaconda.org/maxbo/cythonarrays/badges/version.svg)](https://anaconda.org/maxbo/cythonarrays) diff --git a/cythonarrays/CHANGELOG.md b/cythonarrays/CHANGELOG.md new file mode 100644 index 0000000..ba4d1eb --- /dev/null +++ b/cythonarrays/CHANGELOG.md @@ -0,0 +1,35 @@ +# Changelog + + +## [Unreleased] + +### Added + + +### Changed + + +### Removed + + +## [1.6.2] - 2024-08-19 + +### Added + +- CHANGELOG.md + +### Fixed +- correct check of hdf5-version +- pd.DataSet.sizes instead of shape + +### Changed +- update to numpy>=2.0 +- change definition of NINF_d etc. + +### Removed + + + +[unreleased]: https://github.com/MaxBo/cythonarrays/compare/v1.6.2...HEAD +[1.3.1]: https://github.com/MaxBo/cythonarrays/compare/v1.6.1...v1.6.2 +[1.3.0]: https://github.com/MaxBo/cythonarrays/releases/tag/v1.6.1 \ No newline at end of file From 951b7783775bbf8fd1d21a9d56e68968e784e3fa Mon Sep 17 00:00:00 2001 From: Max Bohnet Date: Mon, 19 Aug 2024 17:23:27 +0200 Subject: [PATCH 2/6] change nan/nnif definitions/spelling --- .../src/cythonarrays/array_descriptors.py | 2 +- .../src/cythonarrays/array_shapes.pyx | 22 +++++++++++-------- .../cythonarrays/tests/test_cythonarray.py | 8 +++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/cythonarrays/src/cythonarrays/array_descriptors.py b/cythonarrays/src/cythonarrays/array_descriptors.py index bac2dff..e4dfa38 100644 --- a/cythonarrays/src/cythonarrays/array_descriptors.py +++ b/cythonarrays/src/cythonarrays/array_descriptors.py @@ -180,7 +180,7 @@ def shape(self, value: Union[int, str, bytes, Tuple[Union[int, str]]]): the shape provided as a number, a string (comma separated for several dimensions) or a tuple/list of strings or ints """ - if isinstance(value, (int, np.compat.long)): + if isinstance(value, (int, )): value = (value, ) elif isinstance(value, (str, bytes)): splitted = value.split(',') diff --git a/cythonarrays/src/cythonarrays/array_shapes.pyx b/cythonarrays/src/cythonarrays/array_shapes.pyx index 5a96a12..5c83c4d 100644 --- a/cythonarrays/src/cythonarrays/array_shapes.pyx +++ b/cythonarrays/src/cythonarrays/array_shapes.pyx @@ -16,6 +16,10 @@ from .array_descriptors import ArrayDescriptor cimport cython cdef extern from "numpy/npy_math.h": bint npy_isnan(double x) nogil + double NPY_INFINITY + float NPY_INFINITYF + double NPY_NAN + float NPY_NANF cdef class ArrayShapes(object): @@ -34,19 +38,19 @@ cdef class ArrayShapes(object): def __init__(self, *args, **kwargs): """ - inits the Array and creates the constands for NAN and NINF + inits the Array and creates the constants for NAN, INF and NINF """ # super class has to be called even if the super class of ArrayShapes # is only `object` super().__init__(*args, **kwargs) - # set NAN-Values - self.NAN_f = np.NAN #np.float32(0) / np.float32(0) - self.INF_f = np.float32(1) / np.float32(0) - self.NINF_f = np.float32(-1) / np.float32(0) - - self.NAN_d = np.NAN #np.float64(0) / np.float64(0) - self.INF_d = np.float64(1) / np.float64(0) - self.NINF_d = np.float64(-1) / np.float64(0) + #set NAN-Values + self.NAN_f = NPY_NANF + self.INF_f = NPY_INFINITYF + self.NINF_f = -NPY_INFINITYF + + self.NAN_d = NPY_NAN + self.INF_d = NPY_INFINITY + self.NINF_d = -NPY_INFINITY cdef char _isnan(self, np_floating x) nogil: """ diff --git a/cythonarrays/src/cythonarrays/tests/test_cythonarray.py b/cythonarrays/src/cythonarrays/tests/test_cythonarray.py index 2eabeae..279407e 100644 --- a/cythonarrays/src/cythonarrays/tests/test_cythonarray.py +++ b/cythonarrays/src/cythonarrays/tests/test_cythonarray.py @@ -386,7 +386,7 @@ def test_33_del_property(self): # reset to default (not defined) example.reset_array('km_ij') - np.testing.assert_array_equal(example.km_ij, np.NAN) + np.testing.assert_array_equal(example.km_ij, np.nan) # reset to default (new value defined) example.dtypes['km_ij'].default = 11 @@ -449,9 +449,9 @@ def test042_test_nan(self, persons_gi: np.ndarray): groups, zones = persons_gi.shape example = Example(groups, zones) - assert example.isnan_py(np.NAN) - assert not example.isnan_py(np.NINF) - assert not example.isnan_py(np.Inf) + assert example.isnan_py(np.nan) + assert not example.isnan_py(-np.inf) + assert not example.isnan_py(np.inf) assert not example.isnan_py(0) assert not example.isnan_py(1) assert not example.isnan_py(-1) From 8d52b723f1ec65fed5c8a2b18eb6e8220d6f6b7f Mon Sep 17 00:00:00 2001 From: Max Bohnet Date: Mon, 19 Aug 2024 17:23:37 +0200 Subject: [PATCH 3/6] update to numpy 2.0 --- cythonarrays/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cythonarrays/requirements.txt b/cythonarrays/requirements.txt index 801197a..0c25e98 100644 --- a/cythonarrays/requirements.txt +++ b/cythonarrays/requirements.txt @@ -1,4 +1,4 @@ -numpy +numpy>=2.0 cython xarray h5netcdf From da0d75ed1afae4641a6da5a729201c945ff9076f Mon Sep 17 00:00:00 2001 From: Max Bohnet Date: Mon, 19 Aug 2024 17:23:45 +0200 Subject: [PATCH 4/6] verison 1.6.2 --- cythonarrays/src/cythonarrays/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cythonarrays/src/cythonarrays/_version.py b/cythonarrays/src/cythonarrays/_version.py index 5c14ca9..a01c367 100644 --- a/cythonarrays/src/cythonarrays/_version.py +++ b/cythonarrays/src/cythonarrays/_version.py @@ -1 +1 @@ -__version__ = '1.6.1' \ No newline at end of file +__version__ = '1.6.2' \ No newline at end of file From ecadde6d290f0ecd9f3a635cdecfa2767454a524 Mon Sep 17 00:00:00 2001 From: Max Bohnet Date: Mon, 19 Aug 2024 17:43:27 +0200 Subject: [PATCH 5/6] remove support for python 3.8 --- .github/workflows/linux-conda.yml | 4 ++-- cythonarrays/CHANGELOG.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux-conda.yml b/.github/workflows/linux-conda.yml index 912f104..ead5ae2 100644 --- a/.github/workflows/linux-conda.yml +++ b/.github/workflows/linux-conda.yml @@ -16,7 +16,7 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] + python-version: [3.9, '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 - name: Setup base conda for Python 3.11 @@ -50,7 +50,7 @@ jobs: eval "$($CONDA_EXE shell.bash activate test-environment)" which python cd cythonarrays - pip install sphinx sphinxcontrib-napoleon sphinx-autodoc-typehints 'mistune<2' m2r2 + pip install sphinx sphinxcontrib-napoleon sphinx-autodoc-typehints 'mistune<2' m2r2 'docutils<0.20' pytest sphinx-apidoc -f --separate -o docs_rst/cythonarrays src/cythonarrays sphinx-build docs_rst ../docs diff --git a/cythonarrays/CHANGELOG.md b/cythonarrays/CHANGELOG.md index ba4d1eb..63ab815 100644 --- a/cythonarrays/CHANGELOG.md +++ b/cythonarrays/CHANGELOG.md @@ -27,6 +27,7 @@ - change definition of NINF_d etc. ### Removed +- support for python 3.8 (does not support numpy 2.0) From 6f324c99dc04b10822b539bff6bd0096df9d1c07 Mon Sep 17 00:00:00 2001 From: Max Bohnet Date: Mon, 19 Aug 2024 18:26:01 +0200 Subject: [PATCH 6/6] fix changelog --- cythonarrays/CHANGELOG.md => CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) rename cythonarrays/CHANGELOG.md => CHANGELOG.md (64%) diff --git a/cythonarrays/CHANGELOG.md b/CHANGELOG.md similarity index 64% rename from cythonarrays/CHANGELOG.md rename to CHANGELOG.md index 63ab815..d75c857 100644 --- a/cythonarrays/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,6 @@ - CHANGELOG.md ### Fixed -- correct check of hdf5-version -- pd.DataSet.sizes instead of shape ### Changed - update to numpy>=2.0 @@ -32,5 +30,5 @@ [unreleased]: https://github.com/MaxBo/cythonarrays/compare/v1.6.2...HEAD -[1.3.1]: https://github.com/MaxBo/cythonarrays/compare/v1.6.1...v1.6.2 -[1.3.0]: https://github.com/MaxBo/cythonarrays/releases/tag/v1.6.1 \ No newline at end of file +[1.6.2]: https://github.com/MaxBo/cythonarrays/compare/v1.6.1...v1.6.2 +[1.6.1]: https://github.com/MaxBo/cythonarrays/releases/tag/v1.6.1 \ No newline at end of file