From b33e9f0745549328312efcae53554e084d03440f Mon Sep 17 00:00:00 2001 From: William Moore Date: Wed, 27 Oct 2021 11:22:25 +0100 Subject: [PATCH] Rename to _validate_axes_name() --- ome_zarr/writer.py | 5 +++-- tests/test_writer.py | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ome_zarr/writer.py b/ome_zarr/writer.py index b760074b..cd5201b9 100644 --- a/ome_zarr/writer.py +++ b/ome_zarr/writer.py @@ -14,9 +14,10 @@ LOGGER = logging.getLogger("ome_zarr.writer") -def validate_axes_names( +def _validate_axes_names( ndim: int, axes: Union[str, List[str]] = None, fmt: Format = CurrentFormat() ) -> Union[None, List[str]]: + """Returns validated list of axes names or raise exception if invalid""" if fmt.version in ("0.1", "0.2"): if axes is not None: @@ -95,7 +96,7 @@ def write_multiscale( """ dims = len(pyramid[0].shape) - axes = validate_axes_names(dims, axes, fmt) + axes = _validate_axes_names(dims, axes, fmt) paths = [] for path, dataset in enumerate(pyramid): diff --git a/tests/test_writer.py b/tests/test_writer.py index fe7bd6a3..49900473 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -8,7 +8,7 @@ from ome_zarr.io import parse_url from ome_zarr.reader import Multiscales, Reader from ome_zarr.scale import Scaler -from ome_zarr.writer import validate_axes_names, write_image +from ome_zarr.writer import _validate_axes_names, write_image class TestWriter: @@ -84,21 +84,21 @@ def test_dim_names(self): # v0.3 MUST specify axes for 3D or 4D data with pytest.raises(ValueError): - validate_axes_names(3, axes=None, fmt=v03) + _validate_axes_names(3, axes=None, fmt=v03) # ndims must match axes length with pytest.raises(ValueError): - validate_axes_names(3, axes="yx", fmt=v03) + _validate_axes_names(3, axes="yx", fmt=v03) # axes must be ordered tczyx with pytest.raises(ValueError): - validate_axes_names(3, axes="yxt", fmt=v03) + _validate_axes_names(3, axes="yxt", fmt=v03) with pytest.raises(ValueError): - validate_axes_names(2, axes=["x", "y"], fmt=v03) + _validate_axes_names(2, axes=["x", "y"], fmt=v03) # valid axes - no change, converted to list - assert validate_axes_names(2, axes=["y", "x"], fmt=v03) == ["y", "x"] - assert validate_axes_names(5, axes="tczyx", fmt=v03) == [ + assert _validate_axes_names(2, axes=["y", "x"], fmt=v03) == ["y", "x"] + assert _validate_axes_names(5, axes="tczyx", fmt=v03) == [ "t", "c", "z", @@ -107,12 +107,12 @@ def test_dim_names(self): ] # if 2D or 5D, axes can be assigned automatically - assert validate_axes_names(2, axes=None, fmt=v03) == ["y", "x"] - assert validate_axes_names(5, axes=None, fmt=v03) == ["t", "c", "z", "y", "x"] + assert _validate_axes_names(2, axes=None, fmt=v03) == ["y", "x"] + assert _validate_axes_names(5, axes=None, fmt=v03) == ["t", "c", "z", "y", "x"] # for v0.1 or v0.2, axes should be None - assert validate_axes_names(2, axes=["y", "x"], fmt=FormatV01()) is None - assert validate_axes_names(2, axes=["y", "x"], fmt=FormatV02()) is None + assert _validate_axes_names(2, axes=["y", "x"], fmt=FormatV01()) is None + assert _validate_axes_names(2, axes=["y", "x"], fmt=FormatV02()) is None # check that write_image is checking axes data = self.create_data((125, 125))