From 31895fed6feea186c19a04a962370a2eaf7952d9 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Mon, 20 Nov 2023 12:28:22 +0000 Subject: [PATCH 1/3] Disallow chunks=None in optimum_chunksize. --- lib/iris/_lazy_data.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/iris/_lazy_data.py b/lib/iris/_lazy_data.py index a23d47a2e0..7d2ae2a3ad 100644 --- a/lib/iris/_lazy_data.py +++ b/lib/iris/_lazy_data.py @@ -72,8 +72,8 @@ def _optimum_chunksize_internals( Args: - * chunks (tuple of int, or None): - Pre-existing chunk shape of the target data : None if unknown. + * chunks (tuple of int): + Pre-existing chunk shape of the target data. * shape (tuple of int): The full array shape of the target data. * limit (int): @@ -106,8 +106,6 @@ def _optimum_chunksize_internals( "chunks = [c[0] for c in normalise_chunks('auto', ...)]". """ - if chunks is None: - chunks = list(shape) # Set the chunksize limit. if limit is None: From 746862c91bc94d5626af816d2e25f209d32fed93 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Mon, 20 Nov 2023 14:14:05 +0000 Subject: [PATCH 2/3] Clearer docstrings. --- lib/iris/fileformats/netcdf/loader.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/iris/fileformats/netcdf/loader.py b/lib/iris/fileformats/netcdf/loader.py index 107415c79d..044eae9de7 100644 --- a/lib/iris/fileformats/netcdf/loader.py +++ b/lib/iris/fileformats/netcdf/loader.py @@ -780,7 +780,12 @@ def set( @contextmanager def from_file(self) -> None: """ - Ensures the chunks are loaded in from file variables, else will throw an error. + Ensures the chunksizes are loaded in from NetCDF file variables. + + Raises + ------ + KeyError + If any NetCDF file variable does not specify chunksizes. Notes ----- @@ -798,7 +803,7 @@ def from_file(self) -> None: @contextmanager def as_dask(self) -> None: """ - Ensures the chunks are decided from dask. + Uses Dask :external+dask:doc:`array` to control chunksizes. Notes ----- From 7bd420298a15a329d6f2e9edab1c73e69080ec55 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Mon, 20 Nov 2023 15:34:59 +0000 Subject: [PATCH 3/3] Corrected docstring. --- lib/iris/fileformats/netcdf/loader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/iris/fileformats/netcdf/loader.py b/lib/iris/fileformats/netcdf/loader.py index 044eae9de7..b7c1c80cf4 100644 --- a/lib/iris/fileformats/netcdf/loader.py +++ b/lib/iris/fileformats/netcdf/loader.py @@ -785,7 +785,8 @@ def from_file(self) -> None: Raises ------ KeyError - If any NetCDF file variable does not specify chunksizes. + If any NetCDF data variables - those that become + :class:`~iris.cube.Cube`\\ s - do not specify chunksizes. Notes -----