Skip to content

Commit ff70281

Browse files
committed
Merge branch 'main' into ugrid-write
2 parents 020c2dd + 7305962 commit ff70281

21 files changed

+231
-147
lines changed

Changelog.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,27 @@ Version NEXTVERSION
33

44
**2026-01-??**
55

6-
* Write Zarr v3 datasets with `cf.write`, and allow the reading of
7-
grouped Zarr v2 and v3 datasets with `cf.read`
6+
* Write Zarr v3 datasets with `cf.write`
87
(https://github.com/NCAS-CMS/cf-python/issues/895)
98
* Read Zarr v2 and v3 datasets that contain a group hierarchy with
109
`cf.read` (https://github.com/NCAS-CMS/cf-python/issues/894)
1110
* Reduce the time taken to import `cf`
1211
(https://github.com/NCAS-CMS/cf-python/issues/902)
1312
* New optional dependency: ``zarr>=3.1.3``
13+
* New function to control the creation of cached elements during data
14+
display: `cf.display_data`
15+
(https://github.com/NCAS-CMS/cf-python/issues/913)
16+
* New methods: `cf.Data.get_cached_elements`,
17+
`cf.Data.cache_elements`
18+
(https://github.com/NCAS-CMS/cf-python/issues/913)
19+
* Set cached elements during `cf.Data.__init__`
20+
(https://github.com/NCAS-CMS/cf-python/issues/913)
21+
* Removed the `cf.constants.CONSTANTS` dictionary, replacing it
22+
with `cf.ConstantAccess.constants`
23+
(https://github.com/NCAS-CMS/cf-python/issues/902)
24+
* Reduce the time taken to import `cf`
25+
(https://github.com/NCAS-CMS/cf-python/issues/902)
26+
* Changed dependency: ``cfdm>=1.12.4.0, <1.12.5.0``
1427

1528
----
1629

cf/aggregate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4112,7 +4112,7 @@ def _get_hfl(
41124112
# Record the bounds of the first and last (sorted) cells
41134113
first, last = hfl_cache.flb.get(hash_value, (None, None))
41144114
if first is None:
4115-
cached_elements = d._get_cached_elements()
4115+
cached_elements = d.get_cached_elements()
41164116
x = []
41174117
for i in (0, 1, -2, -1):
41184118
value = cached_elements.get(i)

cf/data/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2761,7 +2761,7 @@ def Units(self, value):
27612761
self._set_dask(dx, clear=self._ALL ^ self._CACHE ^ self._CFA)
27622762

27632763
# Adjust cached values for the new units
2764-
cache = self._get_cached_elements()
2764+
cache = self.get_cached_elements()
27652765
if cache:
27662766
self._set_cached_elements(
27672767
{index: cf_func(value) for index, value in cache.items()}

cf/dimensioncoordinate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _infer_direction(self):
165165
if data is not None:
166166
# Infer the direction from the data
167167
if data.size > 1:
168-
c = data._get_cached_elements()
168+
c = data.get_cached_elements()
169169
if c:
170170
try:
171171
return bool(c.get(0) <= c.get(1))
@@ -179,7 +179,7 @@ def _infer_direction(self):
179179
data = self.get_bounds_data(None, _fill_value=False)
180180
if data is not None:
181181
# Infer the direction from the bounds
182-
c = data._get_cached_elements()
182+
c = data.get_cached_elements()
183183
if c:
184184
try:
185185
return bool(c.get(0) <= c.get(1))

cf/field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6994,7 +6994,7 @@ def collapse(
69946994
else:
69956995
b = dim.data
69966996

6997-
cached_elements = b._get_cached_elements()
6997+
cached_elements = b.get_cached_elements()
69986998
try:
69996999
# Try to set the new bounds from cached values
70007000
bounds_data = Data(

cf/functions.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def configuration(
156156
tempdir=None,
157157
chunksize=None,
158158
log_level=None,
159+
display_data=None,
159160
regrid_logging=None,
160161
relaxed_identities=None,
161162
bounds_combination_mode=None,
@@ -177,6 +178,7 @@ def configuration(
177178
* `tempdir`
178179
* `chunksize`
179180
* `log_level`
181+
* `display_data`
180182
* `regrid_logging`
181183
* `relaxed_identities`
182184
* `bounds_combination_mode`
@@ -200,10 +202,10 @@ def configuration(
200202
.. versionadded:: 3.6.0
201203
202204
.. seealso:: `atol`, `rtol`, `tempdir`, `chunksize`,
203-
`total_memory`, `log_level`, `regrid_logging`,
204-
`relaxed_identities`, `bounds_combination_mode`,
205-
`active_storage`, `active_storage_url`,
206-
`active_storage_max_requests`
205+
`total_memory`, `log_level`, `display_data`,
206+
`regrid_logging`, `relaxed_identities`,
207+
`bounds_combination_mode`, `active_storage`,
208+
`active_storage_url`, `active_storage_max_requests`
207209
208210
:Parameters:
209211
@@ -245,6 +247,12 @@ def configuration(
245247
* ``'DETAIL'`` (``3``);
246248
* ``'DEBUG'`` (``-1``).
247249
250+
display_data `bool` or `Constant`, optional
251+
The new display data option. The default is to not change
252+
the current behaviour.
253+
254+
.. versionadded:: NEXTVERSION
255+
248256
regrid_logging: `bool` or `Constant`, optional
249257
The new value (either True to enable logging or False to
250258
disable it). The default is to not change the current
@@ -303,6 +311,7 @@ def configuration(
303311
'log_level': 'WARNING',
304312
'bounds_combination_mode': 'AND',
305313
'chunksize': 82873466.88000001,
314+
'display_data': True,
306315
'active_storage': False,
307316
'active_storage_url': None,
308317
'active_storage_max_requests': 100}
@@ -320,6 +329,7 @@ def configuration(
320329
'log_level': 'WARNING',
321330
'bounds_combination_mode': 'AND',
322331
'chunksize': 75000000.0,
332+
'display_data': True,
323333
'active_storage': False,
324334
'active_storage_url': None,
325335
'active_storage_max_requests': 100}
@@ -347,6 +357,7 @@ def configuration(
347357
'log_level': 'INFO',
348358
'bounds_combination_mode': 'AND',
349359
'chunksize': 75000000.0,
360+
'display_data': True,
350361
'active_storage': False,
351362
'active_storage_url': None}
352363
>>> with cf.configuration(atol=9, rtol=10):
@@ -360,6 +371,7 @@ def configuration(
360371
'log_level': 'INFO',
361372
'bounds_combination_mode': 'AND',
362373
'chunksize': 75000000.0,
374+
'display_data': True,
363375
'active_storage': False,
364376
'active_storage_url': None,
365377
'active_storage_max_requests': 100}
@@ -372,6 +384,7 @@ def configuration(
372384
'log_level': 'INFO',
373385
'bounds_combination_mode': 'AND',
374386
'chunksize': 75000000.0,
387+
'display_data': True,
375388
'active_storage': False,
376389
'active_storage_url': None,
377390
'active_storage_max_requests': 100}
@@ -402,6 +415,7 @@ def configuration(
402415
new_tempdir=tempdir,
403416
new_chunksize=chunksize,
404417
new_log_level=log_level,
418+
new_display_data=display_data,
405419
new_regrid_logging=regrid_logging,
406420
new_relaxed_identities=relaxed_identities,
407421
bounds_combination_mode=bounds_combination_mode,
@@ -445,6 +459,7 @@ def _configuration(_Configuration, **kwargs):
445459
"new_tempdir": tempdir,
446460
"new_chunksize": chunksize,
447461
"new_log_level": log_level,
462+
"new_display_data": display_data,
448463
"new_regrid_logging": regrid_logging,
449464
"new_relaxed_identities": relaxed_identities,
450465
"bounds_combination_mode": bounds_combination_mode,
@@ -459,10 +474,6 @@ def _configuration(_Configuration, **kwargs):
459474

460475
old = ConstantAccess.constants(copy=True)
461476

462-
# old = {name.lower(): val for name, val in CONSTANTS.items()}
463-
#
464-
# old.pop("total_memory", None)
465-
466477
# Filter out 'None' kwargs from configuration() defaults. Note that this
467478
# does not filter out '0' or 'True' values, which is important as the user
468479
# might be trying to set those, as opposed to None emerging as default.
@@ -552,7 +563,6 @@ def FREE_MEMORY():
552563
# Functions inherited from cfdm
553564
# --------------------------------------------------------------------
554565
class ConstantAccess(cfdm.ConstantAccess):
555-
_constants = {}
556566
_Constant = Constant
557567

558568
def __docstring_substitutions__(self):
@@ -576,6 +586,10 @@ class log_level(ConstantAccess, cfdm.log_level):
576586
_reset_log_emergence_level = _reset_log_emergence_level
577587

578588

589+
class display_data(ConstantAccess, cfdm.display_data):
590+
pass
591+
592+
579593
class regrid_logging(ConstantAccess):
580594
"""Whether or not to enable `esmpy` regridding logging.
581595

cf/mixin/properties.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
_DEPRECATION_ERROR_KWARGS,
88
_DEPRECATION_ERROR_METHOD,
99
)
10-
from ..functions import atol as cf_atol
11-
from ..functions import rtol as cf_rtol
1210
from ..mixin_container import Container
1311
from ..query import Query
1412
from ..units import Units
@@ -34,32 +32,6 @@ def __new__(cls, *args, **kwargs):
3432
instance._Data = Data
3533
return instance
3634

37-
# ----------------------------------------------------------------
38-
# Private attributes
39-
# ----------------------------------------------------------------
40-
@property
41-
def _atol(self):
42-
"""Return the tolerance on absolute differences between real
43-
numbers, as returned by the `cf.atol` function.
44-
45-
This is used by, for example, the `_equals` method.
46-
47-
"""
48-
return cf_atol().value
49-
50-
@property
51-
def _rtol(self):
52-
"""Return the tolerance on relative differences between real
53-
numbers, as returned by the `cf.rtol` function.
54-
55-
This is used by, for example, the `_equals` method.
56-
57-
"""
58-
return cf_rtol().value
59-
60-
# ----------------------------------------------------------------
61-
# Private methods
62-
# ----------------------------------------------------------------
6335
def _matching_values(self, value0, value1, units=False, basic=False):
6436
"""Whether two values match.
6537
@@ -100,9 +72,6 @@ def _matching_values(self, value0, value1, units=False, basic=False):
10072

10173
return self._equals(value1, value0, basic=basic)
10274

103-
# ----------------------------------------------------------------
104-
# Attributes
105-
# ----------------------------------------------------------------
10675
@property
10776
def id(self):
10877
"""An identity for the {{class}} object.
@@ -150,9 +119,6 @@ def id(self):
150119
f"{self.__class__.__name__} doesn't have attribute 'id'"
151120
)
152121

153-
# ----------------------------------------------------------------
154-
# CF properties
155-
# ----------------------------------------------------------------
156122
@property
157123
def calendar(self):
158124
"""The calendar CF property.
@@ -554,9 +520,6 @@ def valid_range(self, value):
554520
def valid_range(self):
555521
self.del_property("valid_range", default=AttributeError())
556522

557-
# ----------------------------------------------------------------
558-
# Methods
559-
# ----------------------------------------------------------------
560523
def get_property(self, prop, default=ValueError()):
561524
"""Get a CF property.
562525

cf/mixin2/container.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from ..docstring import _docstring_substitution_definitions
9-
from ..functions import atol, rtol
109

1110

1211
class Container:
@@ -55,23 +54,3 @@ def __docstring_package_depth__(self):
5554
5655
"""
5756
return 0
58-
59-
@property
60-
def _atol(self):
61-
"""Internal alias for `{{package}}.atol`.
62-
63-
An alias is necessary to avoid a name clash with the keyword
64-
argument of identical name (`atol`) in calling functions.
65-
66-
"""
67-
return atol().value
68-
69-
@property
70-
def _rtol(self):
71-
"""Internal alias for `{{package}}.rtol`.
72-
73-
An alias is necessary to avoid a name clash with the keyword
74-
argument of identical name (`rtol`) in calling functions.
75-
76-
"""
77-
return rtol().value

cf/read_write/read.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class read(cfdm.read):
334334
335335
{{read group_dimension_search: `str`, optional}}
336336
337-
.. versionadded:: (cfdm) NEXTVERSION
337+
.. versionadded:: NEXTVERSION
338338
339339
umversion: deprecated at version 3.0.0
340340
Use the *um* parameter instead.

0 commit comments

Comments
 (0)