Skip to content

Commit f530db3

Browse files
committed
privatize functions
1 parent 50d075a commit f530db3

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

numcodecs/zarr3.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
CODEC_PREFIX = "numcodecs."
5959

6060

61-
def from_zarr_dtype(dtype: Any) -> np.dtype:
61+
def _from_zarr_dtype(dtype: Any) -> np.dtype:
6262
"""
6363
Get a numpy data type from an array spec, depending on the zarr version.
6464
"""
@@ -67,7 +67,7 @@ def from_zarr_dtype(dtype: Any) -> np.dtype:
6767
return dtype # pragma: no cover
6868

6969

70-
def to_zarr_dtype(dtype: np.dtype) -> Any:
70+
def _to_zarr_dtype(dtype: np.dtype) -> Any:
7171
if Version(version('zarr')) >= Version("3.1.0"):
7272
from zarr.dtype import parse_data_type
7373

@@ -243,7 +243,7 @@ class LZMA(_NumcodecsBytesBytesCodec, codec_name="lzma"):
243243
class Shuffle(_NumcodecsBytesBytesCodec, codec_name="shuffle"):
244244
def evolve_from_array_spec(self, array_spec: ArraySpec) -> Shuffle:
245245
if self.codec_config.get("elementsize") is None:
246-
dtype = from_zarr_dtype(array_spec.dtype)
246+
dtype = _from_zarr_dtype(array_spec.dtype)
247247
return Shuffle(**{**self.codec_config, "elementsize": dtype.itemsize})
248248
return self # pragma: no cover
249249

@@ -252,7 +252,7 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Shuffle:
252252
class Delta(_NumcodecsArrayArrayCodec, codec_name="delta"):
253253
def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
254254
if astype := self.codec_config.get("astype"):
255-
dtype = to_zarr_dtype(np.dtype(astype)) # type: ignore[call-overload]
255+
dtype = _to_zarr_dtype(np.dtype(astype)) # type: ignore[call-overload]
256256
return replace(chunk_spec, dtype=dtype)
257257
return chunk_spec
258258

@@ -264,13 +264,13 @@ class BitRound(_NumcodecsArrayArrayCodec, codec_name="bitround"):
264264
class FixedScaleOffset(_NumcodecsArrayArrayCodec, codec_name="fixedscaleoffset"):
265265
def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
266266
if astype := self.codec_config.get("astype"):
267-
dtype = to_zarr_dtype(np.dtype(astype)) # type: ignore[call-overload]
267+
dtype = _to_zarr_dtype(np.dtype(astype)) # type: ignore[call-overload]
268268
return replace(chunk_spec, dtype=dtype)
269269
return chunk_spec
270270

271271
def evolve_from_array_spec(self, array_spec: ArraySpec) -> FixedScaleOffset:
272272
if self.codec_config.get("dtype") is None:
273-
dtype = from_zarr_dtype(array_spec.dtype)
273+
dtype = _from_zarr_dtype(array_spec.dtype)
274274
return FixedScaleOffset(**{**self.codec_config, "dtype": str(dtype)})
275275
return self
276276

@@ -281,7 +281,7 @@ def __init__(self, **codec_config: JSON) -> None:
281281

282282
def evolve_from_array_spec(self, array_spec: ArraySpec) -> Quantize:
283283
if self.codec_config.get("dtype") is None:
284-
dtype = from_zarr_dtype(array_spec.dtype)
284+
dtype = _from_zarr_dtype(array_spec.dtype)
285285
return Quantize(**{**self.codec_config, "dtype": str(dtype)})
286286
return self
287287

@@ -291,24 +291,24 @@ def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
291291
return replace(
292292
chunk_spec,
293293
shape=(1 + math.ceil(product(chunk_spec.shape) / 8),),
294-
dtype=to_zarr_dtype(np.dtype("uint8")),
294+
dtype=_to_zarr_dtype(np.dtype("uint8")),
295295
)
296296

297297
def validate(self, *, dtype: np.dtype[Any], **_kwargs) -> None:
298-
_dtype = from_zarr_dtype(dtype)
298+
_dtype = _from_zarr_dtype(dtype)
299299
if _dtype != np.dtype("bool"):
300300
raise ValueError(f"Packbits filter requires bool dtype. Got {dtype}.")
301301

302302

303303
class AsType(_NumcodecsArrayArrayCodec, codec_name="astype"):
304304
def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
305-
dtype = to_zarr_dtype(np.dtype(self.codec_config["encode_dtype"])) # type: ignore[arg-type]
305+
dtype = _to_zarr_dtype(np.dtype(self.codec_config["encode_dtype"])) # type: ignore[arg-type]
306306
return replace(chunk_spec, dtype=dtype)
307307

308308
def evolve_from_array_spec(self, array_spec: ArraySpec) -> AsType:
309309
if self.codec_config.get("decode_dtype") is None:
310310
# TODO: remove these coverage exemptions the correct way, i.e. with tests
311-
dtype = from_zarr_dtype(array_spec.dtype) # pragma: no cover
311+
dtype = _from_zarr_dtype(array_spec.dtype) # pragma: no cover
312312
return AsType(**{**self.codec_config, "decode_dtype": str(dtype)}) # pragma: no cover
313313
return self
314314

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ warn_unused_configs = true
244244

245245
[tool.pixi.project]
246246
channels = ["conda-forge"]
247-
platforms = ["linux-64"]
247+
platforms = ["linux-64", "osx-arm64", "osx-64", "win-64"]
248248

249249
[tool.pixi.dependencies]
250250
clang = ">=19.1.7,<20"

0 commit comments

Comments
 (0)