Skip to content

Commit

Permalink
rename indexing module
Browse files Browse the repository at this point in the history
  • Loading branch information
normanrz committed May 24, 2024
1 parent fd2c70d commit b24fc77
Show file tree
Hide file tree
Showing 7 changed files with 1,035 additions and 1,193 deletions.
8 changes: 4 additions & 4 deletions src/zarr/array.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import json
import math

# Notes on what I've changed here:
# 1. Split Array into AsyncArray and Array
Expand Down Expand Up @@ -34,9 +33,10 @@
Selection,
ZarrFormat,
concurrent_map,
product,
)
from zarr.config import config
from zarr.indexing2 import (
from zarr.indexing import (
BasicIndexer,
BlockIndex,
BlockIndexer,
Expand Down Expand Up @@ -408,7 +408,7 @@ async def _get_selection(
order=self.order,
fill_value=self.metadata.fill_value,
)
if math.prod(indexer.shape) > 0:
if product(indexer.shape) > 0:
# reading chunks and decoding them
await self.metadata.codec_pipeline.read(
[
Expand All @@ -433,7 +433,7 @@ async def getitem(
shape=self.metadata.shape,
chunk_grid=self.metadata.chunk_grid,
)
return await self._get_selection(indexer, factory=factory)
return await self._get_selection(indexer, create_factory=factory)

async def _save_metadata(self, metadata: ArrayMetadata) -> None:
to_save = metadata.to_buffer_dict()
Expand Down
6 changes: 3 additions & 3 deletions src/zarr/chunk_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
parse_named_configuration,
parse_shapelike,
)
from zarr.indexing import _ceildiv
from zarr.indexing import ceildiv

if TYPE_CHECKING:
from typing_extensions import Self
Expand Down Expand Up @@ -63,12 +63,12 @@ def to_dict(self) -> dict[str, JSON]:

def all_chunk_coords(self, array_shape: ChunkCoords) -> Iterator[ChunkCoords]:
return itertools.product(
*(range(0, _ceildiv(s, c)) for s, c in zip(array_shape, self.chunk_shape, strict=False))
*(range(0, ceildiv(s, c)) for s, c in zip(array_shape, self.chunk_shape, strict=False))
)

def get_nchunks(self, array_shape: ChunkCoords) -> int:
return reduce(
operator.mul,
(_ceildiv(s, c) for s, c in zip(array_shape, self.chunk_shape, strict=True)),
(ceildiv(s, c) for s, c in zip(array_shape, self.chunk_shape, strict=True)),
1,
)
3 changes: 1 addition & 2 deletions src/zarr/codecs/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
from zarr.codecs.registry import get_codec_class
from zarr.common import JSON, concurrent_map, parse_named_configuration
from zarr.config import config
from zarr.indexing import is_total_slice
from zarr.indexing2 import is_scalar
from zarr.indexing import is_scalar, is_total_slice
from zarr.metadata import ArrayMetadata

if TYPE_CHECKING:
Expand Down
3 changes: 1 addition & 2 deletions src/zarr/codecs/sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
parse_shapelike,
product,
)
from zarr.indexing import c_order_iter, morton_order_iter
from zarr.indexing2 import BasicIndexer
from zarr.indexing import BasicIndexer, c_order_iter, morton_order_iter
from zarr.metadata import ArrayMetadata, parse_codecs

if TYPE_CHECKING:
Expand Down
Loading

0 comments on commit b24fc77

Please sign in to comment.