Skip to content

Commit

Permalink
Potential fix for h5py deepcopy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shoyer committed Sep 16, 2020
1 parent 66ab0ae commit 8c3113b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xarray/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,12 @@ def __setitem__(self, key, value):
self._ensure_copied()
self.array[key] = value

def __deepcopy__(self, memo):
# CopyOnWriteArray is used to wrap backend array objects, which might
# point to files on disk. Implementing __deepcopy__ this way ensures
# that deep copying is always valid, and results in an in-memory copy.
return type(self)(np.array(self.array))


class MemoryCachedArray(ExplicitlyIndexedNDArrayMixin):
__slots__ = ("array",)
Expand Down

0 comments on commit 8c3113b

Please sign in to comment.