Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Array(object):
set_mask_selection
get_coordinate_selection
set_coordinate_selection
set_options
digest
hexdigest
resize
Expand Down Expand Up @@ -710,6 +711,8 @@ def _get_basic_selection_zd(self, selection, out=None, fields=None):
cdata = self.chunk_store[ckey]

except KeyError:
if not self._fill_missing_chunk:
raise
# chunk not initialized
chunk = np.zeros((), dtype=self._dtype)
if self._fill_value is not None:
Expand Down Expand Up @@ -1376,6 +1379,18 @@ def set_coordinate_selection(self, selection, value, fields=None):

self._set_selection(indexer, value, fields=fields)

def set_options(self, fill_missing_chunk=True):
"""Set options.

Parameters
----------
fill_missing_chunk : bool
Whether Zarr is supposed to fill missing chunks. Defaults to True.

"""

self._fill_missing_chunk = fill_missing_chunk

def set_mask_selection(self, selection, value, fields=None):
"""Modify a selection of individual items, by providing a Boolean array of the
same shape as the array against which the selection is being made, where True
Expand Down Expand Up @@ -1472,6 +1487,8 @@ def _set_basic_selection_zd(self, selection, value, fields=None):
cdata = self.chunk_store[ckey]

except KeyError:
if not self._fill_missing_chunk:
raise
# chunk not initialized
chunk = np.zeros((), dtype=self._dtype)
if self._fill_value is not None:
Expand Down Expand Up @@ -1579,6 +1596,8 @@ def _chunk_getitem(self, chunk_coords, chunk_selection, out, out_selection,
cdata = self.chunk_store[ckey]

except KeyError:
if not self._fill_missing_chunk:
raise
# chunk not initialized
if self._fill_value is not None:
if fields:
Expand Down Expand Up @@ -1692,6 +1711,9 @@ def _chunk_setitem_nosync(self, chunk_coords, chunk_selection, value, fields=Non

except KeyError:

if not self._fill_missing_chunk:
raise

# chunk not initialized
if self._fill_value is not None:
chunk = np.empty(self._chunks, dtype=self._dtype, order=self._order)
Expand Down