Skip to content

Commit 0e28237

Browse files
authored
Merge branch 'main' into zarr-write
2 parents bf147dc + 6eeb074 commit 0e28237

File tree

6 files changed

+185
-103
lines changed

6 files changed

+185
-103
lines changed

Changelog.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ Version NEXTVERSION
1010
* Reduce the time taken to import `cf`
1111
(https://github.com/NCAS-CMS/cf-python/issues/902)
1212
* 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``
1327

1428
----
1529

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

0 commit comments

Comments
 (0)