-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This avoids accidental mutation and redirects users to the rechunk method Example ------- In [1]: import dask.array as da In [2]: x = da.ones(6, chunks=3) In [3]: x.chunks = 2 ValueError: Can not set chunks directly Please use the rechunk method instead: x.rechunk(2) cc @JDWarner
- Loading branch information
Showing
2 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -442,7 +442,7 @@ def map_blocks(func, *arrs, **kwargs): | |
chunks = tuple([nb * (bs,) | ||
for nb, bs in zip(result.numblocks, chunks)]) | ||
if chunks is not None: | ||
result.chunks = chunks | ||
result._chunks = chunks | ||
|
||
return result | ||
|
||
|
@@ -605,13 +605,13 @@ class Array(object): | |
block sizes along each dimension | ||
""" | ||
|
||
__slots__ = 'dask', 'name', 'chunks', '_dtype' | ||
__slots__ = 'dask', 'name', '_chunks', '_dtype' | ||
|
||
def __init__(self, dask, name, chunks, dtype=None, shape=None): | ||
self.dask = dask | ||
self.name = name | ||
self.chunks = normalize_chunks(chunks, shape) | ||
if self.chunks is None: | ||
self._chunks = normalize_chunks(chunks, shape) | ||
if self._chunks is None: | ||
raise ValueError(chunks_none_error_message) | ||
if dtype is not None: | ||
dtype = np.dtype(dtype) | ||
|
@@ -629,6 +629,16 @@ def numblocks(self): | |
def shape(self): | ||
return tuple(map(sum, self.chunks)) | ||
|
||
def _get_chunks(self): | ||
return self._chunks | ||
|
||
def _set_chunks(self, chunks): | ||
raise ValueError("Can not set chunks directly\n\n" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mrocklin
via email
Author
Owner
|
||
"Please use the rechunk method instead:\n" | ||
" x.rechunk(%s)" % str(chunks)) | ||
|
||
chunks = property(_get_chunks, _set_chunks, "chunks property") | ||
|
||
def __len__(self): | ||
return sum(self.chunks[0]) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe
TypeError
?