Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Changelog.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
Version NEXTVERSION
-------------------

**2025-12-??**

**2026-01-??**

* New function to control the creation of cached elements during data
display: `cf.display_data`
(https://github.com/NCAS-CMS/cf-python/issues/913)
* New methods: `cf.Data.get_cached_elements`
`cf.Data.cache_elements`
(https://github.com/NCAS-CMS/cf-python/issues/913)
* Set cached elements during `cf.Data.__init__`
(https://github.com/NCAS-CMS/cf-python/issues/913)
* Removed the `cf.constants.CONSTANTS` dictionary, replacing it
`cf.ConstantAccess.constants`
(https://github.com/NCAS-CMS/cf-python/issues/902)
* Reduce the time taken to import `cf`
(https://github.com/NCAS-CMS/cf-python/issues/902)
* Changed dependency: ``cfdm>=1.12.4.0, <1.12.5.0``

----

Expand Down
32 changes: 23 additions & 9 deletions cf/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def configuration(
tempdir=None,
chunksize=None,
log_level=None,
display_data=None,
regrid_logging=None,
relaxed_identities=None,
bounds_combination_mode=None,
Expand All @@ -177,6 +178,7 @@ def configuration(
* `tempdir`
* `chunksize`
* `log_level`
* `display_data`
* `regrid_logging`
* `relaxed_identities`
* `bounds_combination_mode`
Expand All @@ -200,10 +202,10 @@ def configuration(
.. versionadded:: 3.6.0

.. seealso:: `atol`, `rtol`, `tempdir`, `chunksize`,
`total_memory`, `log_level`, `regrid_logging`,
`relaxed_identities`, `bounds_combination_mode`,
`active_storage`, `active_storage_url`,
`active_storage_max_requests`
`total_memory`, `log_level`, `display_data`,
`regrid_logging`, `relaxed_identities`,
`bounds_combination_mode`, `active_storage`,
`active_storage_url`, `active_storage_max_requests`

:Parameters:

Expand Down Expand Up @@ -245,6 +247,12 @@ def configuration(
* ``'DETAIL'`` (``3``);
* ``'DEBUG'`` (``-1``).

display_data `bool` or `Constant`, optional
The new display data option. The default is to not change
the current behaviour.

.. versionadded:: NEXTVERSION

regrid_logging: `bool` or `Constant`, optional
The new value (either True to enable logging or False to
disable it). The default is to not change the current
Expand Down Expand Up @@ -303,6 +311,7 @@ def configuration(
'log_level': 'WARNING',
'bounds_combination_mode': 'AND',
'chunksize': 82873466.88000001,
'display_data': True,
'active_storage': False,
'active_storage_url': None,
'active_storage_max_requests': 100}
Expand All @@ -320,6 +329,7 @@ def configuration(
'log_level': 'WARNING',
'bounds_combination_mode': 'AND',
'chunksize': 75000000.0,
'display_data': True,
'active_storage': False,
'active_storage_url': None,
'active_storage_max_requests': 100}
Expand Down Expand Up @@ -347,6 +357,7 @@ def configuration(
'log_level': 'INFO',
'bounds_combination_mode': 'AND',
'chunksize': 75000000.0,
'display_data': True,
'active_storage': False,
'active_storage_url': None}
>>> with cf.configuration(atol=9, rtol=10):
Expand All @@ -360,6 +371,7 @@ def configuration(
'log_level': 'INFO',
'bounds_combination_mode': 'AND',
'chunksize': 75000000.0,
'display_data': True,
'active_storage': False,
'active_storage_url': None,
'active_storage_max_requests': 100}
Expand All @@ -372,6 +384,7 @@ def configuration(
'log_level': 'INFO',
'bounds_combination_mode': 'AND',
'chunksize': 75000000.0,
'display_data': True,
'active_storage': False,
'active_storage_url': None,
'active_storage_max_requests': 100}
Expand Down Expand Up @@ -402,6 +415,7 @@ def configuration(
new_tempdir=tempdir,
new_chunksize=chunksize,
new_log_level=log_level,
new_display_data=display_data,
new_regrid_logging=regrid_logging,
new_relaxed_identities=relaxed_identities,
bounds_combination_mode=bounds_combination_mode,
Expand Down Expand Up @@ -445,6 +459,7 @@ def _configuration(_Configuration, **kwargs):
"new_tempdir": tempdir,
"new_chunksize": chunksize,
"new_log_level": log_level,
"new_display_data": display_data,
"new_regrid_logging": regrid_logging,
"new_relaxed_identities": relaxed_identities,
"bounds_combination_mode": bounds_combination_mode,
Expand All @@ -459,10 +474,6 @@ def _configuration(_Configuration, **kwargs):

old = ConstantAccess.constants(copy=True)

# old = {name.lower(): val for name, val in CONSTANTS.items()}
#
# old.pop("total_memory", None)

# Filter out 'None' kwargs from configuration() defaults. Note that this
# does not filter out '0' or 'True' values, which is important as the user
# might be trying to set those, as opposed to None emerging as default.
Expand Down Expand Up @@ -552,7 +563,6 @@ def FREE_MEMORY():
# Functions inherited from cfdm
# --------------------------------------------------------------------
class ConstantAccess(cfdm.ConstantAccess):
_constants = {}
_Constant = Constant

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


class display_data(ConstantAccess, cfdm.display_data):
pass


class regrid_logging(ConstantAccess):
"""Whether or not to enable `esmpy` regridding logging.

Expand Down
37 changes: 0 additions & 37 deletions cf/mixin/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
_DEPRECATION_ERROR_KWARGS,
_DEPRECATION_ERROR_METHOD,
)
from ..functions import atol as cf_atol
from ..functions import rtol as cf_rtol
from ..mixin_container import Container
from ..query import Query
from ..units import Units
Expand All @@ -34,32 +32,6 @@ def __new__(cls, *args, **kwargs):
instance._Data = Data
return instance

# ----------------------------------------------------------------
# Private attributes
# ----------------------------------------------------------------
@property
def _atol(self):
"""Return the tolerance on absolute differences between real
numbers, as returned by the `cf.atol` function.

This is used by, for example, the `_equals` method.

"""
return cf_atol().value

@property
def _rtol(self):
"""Return the tolerance on relative differences between real
numbers, as returned by the `cf.rtol` function.

This is used by, for example, the `_equals` method.

"""
return cf_rtol().value

# ----------------------------------------------------------------
# Private methods
# ----------------------------------------------------------------
def _matching_values(self, value0, value1, units=False, basic=False):
"""Whether two values match.

Expand Down Expand Up @@ -100,9 +72,6 @@ def _matching_values(self, value0, value1, units=False, basic=False):

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

# ----------------------------------------------------------------
# Attributes
# ----------------------------------------------------------------
@property
def id(self):
"""An identity for the {{class}} object.
Expand Down Expand Up @@ -150,9 +119,6 @@ def id(self):
f"{self.__class__.__name__} doesn't have attribute 'id'"
)

# ----------------------------------------------------------------
# CF properties
# ----------------------------------------------------------------
@property
def calendar(self):
"""The calendar CF property.
Expand Down Expand Up @@ -554,9 +520,6 @@ def valid_range(self, value):
def valid_range(self):
self.del_property("valid_range", default=AttributeError())

# ----------------------------------------------------------------
# Methods
# ----------------------------------------------------------------
def get_property(self, prop, default=ValueError()):
"""Get a CF property.

Expand Down
21 changes: 0 additions & 21 deletions cf/mixin2/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

from ..docstring import _docstring_substitution_definitions
from ..functions import atol, rtol


class Container:
Expand Down Expand Up @@ -55,23 +54,3 @@ def __docstring_package_depth__(self):

"""
return 0

@property
def _atol(self):
"""Internal alias for `{{package}}.atol`.

An alias is necessary to avoid a name clash with the keyword
argument of identical name (`atol`) in calling functions.

"""
return atol().value

@property
def _rtol(self):
"""Internal alias for `{{package}}.rtol`.

An alias is necessary to avoid a name clash with the keyword
argument of identical name (`rtol`) in calling functions.

"""
return rtol().value
Loading
Loading