Skip to content

Commit

Permalink
simplify _get_selection
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Jun 27, 2022
1 parent 28070f0 commit 9f74667
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re
from collections.abc import MutableMapping
from functools import reduce
from typing import Any
from typing import Any, Optional, Sequence, Union

import numpy as np
from numcodecs.compat import ensure_bytes, ensure_ndarray
Expand Down Expand Up @@ -788,7 +788,7 @@ def __getitem__(self, selection):
result = self.get_basic_selection(pure_selection, fields=fields)
return result

def get_basic_selection(self, selection=Ellipsis, out=None, fields=None):
def get_basic_selection(self, selection=Ellipsis, out=None, fields: Optional[Union[str, Sequence[str]]]=None):
"""Retrieve data for an item or region of the array.
Parameters
Expand Down Expand Up @@ -1238,20 +1238,8 @@ def _get_selection(self, indexer, out=None, fields=None):
out = np.empty(out_shape, dtype=out_dtype, order=self._order)
else:
check_array_shape('out', out, out_shape)

# iterate over chunks
#if any(map(lambda x: x == 0, self.shape)):
# # sequentially get one key at a time from storage
# for chunk_coords, chunk_selection, out_selection in indexer:
#
# # load chunk selection into output array
# self._chunk_getitem(chunk_coords, chunk_selection, out, out_selection,
# drop_axes=indexer.drop_axes, fields=fields)
#else:
# allow storage to get multiple items at once
# if all(map(lambda x: x > 0, out_shape)):

if indexer_parts:
if len(indexer_parts) > 0:
lchunk_coords, lchunk_selection, lout_selection = zip(*indexer_parts)
self._chunk_getitems(lchunk_coords, lchunk_selection, out, lout_selection,
drop_axes=indexer.drop_axes, fields=fields)
Expand Down

0 comments on commit 9f74667

Please sign in to comment.