Skip to content

Commit 15c1b88

Browse files
committed
dev
1 parent 2cd7605 commit 15c1b88

File tree

7 files changed

+119
-143
lines changed

7 files changed

+119
-143
lines changed

Changelog.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ version 3.17.0
33

44
**2025-??-??**
55

6+
* Set new minimum version of `numpy`: ``2.0.0``
7+
(https://github.com/NCAS-CMS/cf-python/issues/843)
68
* Replace dataset aggregation functionality (CFA) with that imported
79
from `cfdm` (https://github.com/NCAS-CMS/cf-python/issues/841)
8-
* Changed dependency: ``1.12.0.0<=cfdm<1.12.1.0``
10+
* Changed dependency: ``Python>=3.9.0``
11+
* Changed dependency: ``numpy>=2.0.0``
12+
* Changed dependency: ``cfdm>=1.12.0.0, <1.12.1.0``
13+
* Changed optional dependency: ``esmpy>=8.7.0``
14+
* Removed dependency (now incorporated into `cfdm`): ``h5py``
15+
* Removed dependency (now incorporated into `cfdm`): ``h5netcdf``
16+
* Removed dependency (now incorporated into `cfdm`): ``s3fs``
917

1018
----
1119

@@ -283,8 +291,8 @@ version 3.15.0
283291
* Handled the renaming of the ESMF Python interface from `ESMF` to
284292
`esmpy` at version 8.4.0. Both module names are accepted for now.
285293
* Changed dependency: ``1.10.1.0<=cfdm<1.10.2.0``
286-
* Changed (optional) dependency: ``8.0.0<=esmpy``
287-
* Changed (optional) dependency: ``1.10.0<=scipy``
294+
* Changed optional dependency: ``8.0.0<=esmpy``
295+
* Changed optional dependency: ``1.10.0<=scipy``
288296

289297
----
290298

cf/__init__.py

Lines changed: 92 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
8181
"""
8282

83-
__Conventions__ = "CF-1.11"
8483
__date__ = "2025-01-28"
8584
__version__ = "3.16.3"
8685

@@ -95,153 +94,141 @@
9594
"packaging",
9695
"scipy",
9796
)
98-
9997
x = ", ".join(_requires)
10098
_error0 = f"cf v{__version__} requires the modules {x}. "
10199

100+
import importlib.util
101+
from platform import python_version
102+
103+
_found_esmpy = bool(importlib.util.find_spec("esmpy"))
104+
102105
try:
103-
import cfdm
106+
import packaging
107+
from packaging.version import Version
104108
except ImportError as error1:
105109
raise ImportError(_error0 + str(error1))
110+
else:
111+
_minimum_vn = "20.0"
112+
if Version(packaging.__version__) < Version(_minimum_vn):
113+
raise RuntimeError(
114+
f"Bad packaging version: cf requires packaging>={_minimum_vn}. "
115+
f"Got {packaging.__version__} at {packaging.__file__}"
116+
)
106117

107-
__cf_version__ = cfdm.core.__cf_version__
108-
109-
from packaging.version import Version
110-
import importlib.util
111-
import platform
112-
113-
# ESMF renamed its Python module to `esmpy` at ESMF version 8.4.0. Allow
114-
# either for now for backwards compatibility.
115-
_found_esmpy = bool(
116-
importlib.util.find_spec("esmpy") or importlib.util.find_spec("ESMF")
117-
)
118+
try:
119+
import cfdm
120+
except ImportError as error1:
121+
raise ImportError(_error0 + str(error1))
122+
else:
123+
# Check the version of cfdm
124+
_minimum_vn = "1.12.0.0"
125+
_maximum_vn = "1.12.1.0"
126+
_cfdm_version = Version(cfdm.__version__)
127+
if not Version(_minimum_vn) <= _cfdm_version < Version(_maximum_vn):
128+
raise RuntimeError(
129+
"Bad cfdm version: cf requires "
130+
f"{_minimum_vn}<=cfdm<{_maximum_vn}. "
131+
f"Got {cfdm.__version__} at {cfdm.__file__}"
132+
)
133+
134+
__cf_version__ = cfdm.__cf_version__
135+
__Conventions__ = f"CF-{__cf_version__}"
118136

119137
try:
120138
import netCDF4
121139
except ImportError as error1:
122140
raise ImportError(_error0 + str(error1))
141+
else:
142+
_minimum_vn = "1.7.2"
143+
if Version(netCDF4.__version__) < Version(_minimum_vn):
144+
raise RuntimeError(
145+
f"Bad netCDF4 version: cf requires netCDF4>={_minimum_vn}. "
146+
f"Got {netCDF4.__version__} at {netCDF4.__file__}"
147+
)
123148

124149
try:
125150
import numpy as np
126151
except ImportError as error1:
127152
raise ImportError(_error0 + str(error1))
153+
else:
154+
_minimum_vn = "2.0.0"
155+
if not Version(_minimum_vn) < Version(np.__version__):
156+
raise ValueError(
157+
f"Bad numpy version: cf requires numpy>={_minimum_vn} "
158+
f"Got {np.__version__} at {np.__file__}"
159+
)
128160

129161
try:
130162
import cftime
131163
except ImportError as error1:
132164
raise ImportError(_error0 + str(error1))
165+
else:
166+
_minimum_vn = "1.6.4"
167+
if Version(cftime.__version__) < Version(_minimum_vn):
168+
raise RuntimeError(
169+
f"Bad cftime version: cf requires cftime>={_minimum_vn}. "
170+
f"Got {cftime.__version__} at {cftime.__file__}"
171+
)
133172

134173
try:
135174
import cfunits
136175
except ImportError as error1:
137176
raise ImportError(_error0 + str(error1))
177+
else:
178+
_minimum_vn = "3.3.7"
179+
if Version(cfunits.__version__) < Version(_minimum_vn):
180+
raise RuntimeError(
181+
f"Bad cfunits version: cf requires cfunits>={_minimum_vn}. "
182+
f"Got {cfunits.__version__} at {cfunits.__file__}"
183+
)
138184

139185
try:
140186
import psutil
141187
except ImportError as error1:
142188
raise ImportError(_error0 + str(error1))
189+
else:
190+
_minimum_vn = "0.6.0"
191+
if Version(psutil.__version__) < Version(_minimum_vn):
192+
raise RuntimeError(
193+
f"Bad psutil version: cf requires psutil>={_minimum_vn}. "
194+
f"Got {psutil.__version__} at {psutil.__file__}"
195+
)
143196

144197
try:
145198
import dask
146199
except ImportError as error1:
147200
raise ImportError(_error0 + str(error1))
148-
149-
try:
150-
import packaging
151-
except ImportError as error1:
152-
raise ImportError(_error0 + str(error1))
201+
else:
202+
_minimum_vn = "2024.6.1"
203+
_maximum_vn = "2024.7.1"
204+
if (
205+
not Version(_minimum_vn)
206+
<= Version(dask.__version__)
207+
<= Version(_maximum_vn)
208+
):
209+
raise ValueError(
210+
"Bad dask version: cf requires "
211+
f"{_minimum_vn}<=dask<={_maximum_vn}. "
212+
f"Got {dask.__version__} at {dask.__file__}"
213+
)
153214

154215
try:
155216
import scipy
156217
except ImportError as error1:
157218
raise ImportError(_error0 + str(error1))
158-
159-
# Check the version of packaging
160-
_minimum_vn = "20.0"
161-
if Version(packaging.__version__) < Version(_minimum_vn):
162-
raise RuntimeError(
163-
f"Bad packaging version: cf requires packaging>={_minimum_vn}. "
164-
f"Got {packaging.__version__} at {packaging.__file__}"
165-
)
166-
167-
# Check the version of psutil
168-
_minimum_vn = "0.6.0"
169-
if Version(psutil.__version__) < Version(_minimum_vn):
170-
raise RuntimeError(
171-
f"Bad psutil version: cf requires psutil>={_minimum_vn}. "
172-
f"Got {psutil.__version__} at {psutil.__file__}"
173-
)
174-
175-
# Check the version of netCDF4
176-
_minimum_vn = "1.7.2"
177-
if Version(netCDF4.__version__) < Version(_minimum_vn):
178-
raise RuntimeError(
179-
f"Bad netCDF4 version: cf requires netCDF4>={_minimum_vn}. "
180-
f"Got {netCDF4.__version__} at {netCDF4.__file__}"
181-
)
182-
183-
# Check the version of cftime
184-
_minimum_vn = "1.6.4"
185-
if Version(cftime.__version__) < Version(_minimum_vn):
186-
raise RuntimeError(
187-
f"Bad cftime version: cf requires cftime>={_minimum_vn}. "
188-
f"Got {cftime.__version__} at {cftime.__file__}"
189-
)
190-
191-
# Check the version of numpy
192-
_minimum_vn = "2.0.0"
193-
if not Version(_minimum_vn) < Version(np.__version__):
194-
raise ValueError(
195-
"Bad numpy version: cfdm requires {_minimum_vn}<=numpy. "
196-
f"Got {Version(np.__version__)} at {np.__file__}"
197-
)
198-
199-
# Check the version of cfunits
200-
_minimum_vn = "3.3.7"
201-
if Version(cfunits.__version__) < Version(_minimum_vn):
202-
raise RuntimeError(
203-
f"Bad cfunits version: cf requires cfunits>={_minimum_vn}. "
204-
f"Got {cfunits.__version__} at {cfunits.__file__}"
205-
)
206-
207-
# Check the version of cfdm
208-
_minimum_vn = "1.12.0.0"
209-
_maximum_vn = "1.12.1.0"
210-
_cfdm_version = Version(cfdm.__version__)
211-
if not Version(_minimum_vn) <= _cfdm_version < Version(_maximum_vn):
212-
raise RuntimeError(
213-
f"Bad cfdm version: cf requires {_minimum_vn}<=cfdm<{_maximum_vn}. "
214-
f"Got {cfdm.__version__} at {cfdm.__file__}"
215-
)
216-
217-
# Check the version of dask
218-
219-
_minimum_vn = "2024.6.1"
220-
_maximum_vn = "2024.7.1"
221-
if (
222-
not Version(_minimum_vn)
223-
<= Version(dask.__version__)
224-
<= Version(_maximum_vn)
225-
):
219+
else:
220+
_minimum_vn = "1.10.0"
221+
if Version(scipy.__version__) < Version(_minimum_vn):
222+
raise RuntimeError(
223+
f"Bad scipy version: cf requires scipy>={_minimum_vn}. "
224+
f"Got {scipy.__version__} at {scipy.__file__}"
225+
)
226+
227+
_minimum_vn = "3.9.0"
228+
if Version(python_version()) < Version(_minimum_vn):
226229
raise ValueError(
227-
"Bad dask version: cf requires {_minimum_vn}<=dask<={_maximum_vn}. "
228-
f"Got {dask.__version__} at {dask.__file__}"
229-
)
230-
231-
# Check the version of Python
232-
_minimum_vn = "3.8.0"
233-
if Version(platform.python_version()) < Version(_minimum_vn):
234-
raise ValueError(
235-
f"Bad python version: cf requires python version {_minimum_vn} "
236-
f"or later. Got {platform.python_version()}"
237-
)
238-
239-
# Check the version of scipy
240-
_minimum_vn = "1.10.0"
241-
if Version(scipy.__version__) < Version(_minimum_vn):
242-
raise RuntimeError(
243-
f"Bad scipy version: cf requires scipy>={_minimum_vn}. "
244-
f"Got {scipy.__version__} at {scipy.__file__}"
230+
f"Bad python version: cf requires python>={_minimum_vn}. "
231+
f"Got {python_version()}"
245232
)
246233

247234
del _minimum_vn, _maximum_vn

cf/data/collapse/dask_collapse.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,12 +859,12 @@ def cf_sample_size_chunk(x, dtype="i8", computing_meta=False, **kwargs):
859859

860860
x = cfdm_to_memory(x)
861861
if np.ma.isMA(x):
862-
# Note: We're not using `np.ones_like` here (like we used to
863-
# for numpy<2.0.0) because numpy currently
864-
# (numpy==2.2.3) has a bug that produces a
865-
# RuntimeWarning: "numpy/ma/core.py:502: RuntimeWarning:
866-
# invalid value encountered in cast fill_value =
867-
# np.asarray(fill_value, dtype=ndtype)". See
862+
# Note: We're not using `np.ones_like` here (like we used to)
863+
# because numpy currently (numpy==2.2.3) has a bug that
864+
# produces a RuntimeWarning: "numpy/ma/core.py:502:
865+
# RuntimeWarning: invalid value encountered in cast
866+
# fill_value = np.asarray(fill_value,
867+
# dtype=ndtype)". See
868868
# https://github.com/numpy/numpy/issues/28255 for more
869869
# details.
870870
x = np.ma.array(np.ones((x.shape), dtype=x.dtype), mask=x.mask)

cf/mixin/propertiesdata.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ class PropertiesData(Properties):
4949

5050
_special_properties = ("units", "calendar")
5151

52-
# def __array__(self, *dtype):
53-
# """Returns a numpy array representation of the data."""
54-
# data = self.get_data(None)
55-
# if data is not None:
56-
# return data.__array__(*dtype)#
57-
#
58-
# raise ValueError(f"{self.__class__.__name__} has no data")
59-
6052
def __contains__(self, value):
6153
"""Called to implement membership test operators.
6254

docs/source/installation.rst

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Windows Subsystem for Linux (WSL)
3232
**Python versions**
3333
-------------------
3434

35-
The cf package is only for Python 3.8 or newer.
35+
The cf package is only for Python 3.9 or newer.
3636

3737
----
3838

@@ -108,7 +108,7 @@ visualisation package <http://ajheaps.github.io/cf-plot>`_, run:
108108
:caption: *Install with conda.*
109109
110110
$ conda install -c conda-forge cf-python cf-plot udunits2
111-
$ conda install -c conda-forge "esmpy>=8.0.0"
111+
$ conda install -c conda-forge "esmpy>=8.7.0"
112112
113113
The second of the two ``conda`` commands is required for
114114
:ref:`regridding <Regridding>` to work.
@@ -190,26 +190,18 @@ installed, which:
190190
Required
191191
^^^^^^^^
192192

193-
* `Python <https://www.python.org/>`_, 3.8.0 or newer.
193+
* `Python <https://www.python.org/>`_, 3.9.0 or newer.
194194

195-
* `numpy <http://www.numpy.org>`_, versions 1.15 up to, but not
196-
including, 2.0.
195+
* `numpy <http://www.numpy.org>`_, versions 2.0.0 or newer.
197196

198197
* `dask <https://pypi.org/project/dask>`_, versions 2024.6.0 to
199198
2024.7.1 inclusive.
200199

201-
* `netCDF4 <https://pypi.org/project/netcdf4/>`_, 1.6.5 or newer.
200+
* `netCDF4 <https://pypi.org/project/netcdf4/>`_, 1.7.2 or newer.
202201

203-
* `cftime <https://pypi.org/project/cftime/>`_, version 1.6.2 or newer
202+
* `cftime <https://pypi.org/project/cftime/>`_, version 1.6.4 or newer
204203
(note that this package may be installed with netCDF4).
205204

206-
* `h5netcdf <https://pypi.org/project/h5netcdf>`_, version 1.3.0
207-
newer.
208-
209-
* `h5py <https://pypi.org/project/h5py>`_, version 3.10.0 or newer.
210-
211-
* `s3fs <https://pypi.org/project/s3fs>`_, version 2024.6.0 or newer.
212-
213205
* `scipy <https://pypi.org/project/scipy>`_, version 1.10.0 or newer.
214206

215207
* `cfdm <https://pypi.org/project/cfdm/>`_, version 1.12.0.0 or up to,
@@ -256,11 +248,11 @@ environments for which these features are not required.
256248

257249
* `esmpy <https://earthsystemmodeling.org/esmpy/>`_, previously
258250
named `ESMF` with the old module name also being accepted for import,
259-
version 8.0.0 or newer. This is easily installed via conda with
251+
version 8.7.0 or newer. This is easily installed via conda with
260252

261253
.. code-block:: console
262254
263-
$ conda install -c conda-forge "esmpy>=8.0.0"
255+
$ conda install -c conda-forge "esmpy>=8.7.0"
264256
265257
or may be installed from source.
266258

requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ cfunits>=3.3.7
77
dask>=2024.6.0,<=2024.7.1
88
packaging>=20.0
99
scipy>=1.10.0
10-
h5netcdf>=1.3.0
11-
h5py>=3.12.1
12-
s3fs>=2024.6.0

0 commit comments

Comments
 (0)