Skip to content

Commit

Permalink
only wrap BackendArrays in CopyOnWriteArray
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNicholas committed Feb 6, 2024
1 parent c9ba2be commit ca17266
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ def _protect_dataset_variables_inplace(dataset, cache):
for name, variable in dataset.variables.items():
if name not in dataset._indexes:
# no need to protect IndexVariable objects
data = indexing.CopyOnWriteArray(variable._data)
if isinstance(variable._data, backends.BackendArray):
data = indexing.CopyOnWriteArray(variable._data)
else:
data = variable.data
if cache:
data = indexing.MemoryCachedArray(data)
variable.data = data
Expand Down

0 comments on commit ca17266

Please sign in to comment.