You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a NetCDF file produced by an upstream process. After loading this into an xarray dataset and calling DataSet.copy(deep=True), I find that some coordinates still share memory with the source of the copy.
I expected a deep copy to be deep, with no shared memory between.
Minimal Complete Verifiable Example
importxarrayasxrimportnumpyasnpds=xr.load_dataset("/Users/philchiu/repos/spheres/tests/data_clean.nc")
ds2=ds.copy(deep=True)
print(ds.variables["FREQUENCY"].data)
ds2.variables["FREQUENCY"].data[:] =99.99# This should be the original array, but instead it's all 99.99print(ds.variables["FREQUENCY"].data)
# I would expect both of these to print False, but it prints True, Falseprint(np.shares_memory(ds.variables["FREQUENCY"].data, ds2.variables["FREQUENCY"].data))
print(np.shares_memory(ds.variables["AMPLITUDE"].data, ds2.variables["AMPLITUDE"].data))
MVCE confirmation
Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
Complete example — the example is self-contained, including all data and the text of any traceback.
Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
New issue — a search of GitHub Issues suggests this is not a duplicate.
Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
importxarrayasxrimportnumpyasnpds=xr.load_dataset("data_clean.nc")
ds2=ds.copy(deep=True)
print(ds.variables["FREQUENCY"].data)
ds2.variables["FREQUENCY"].data[:] =99.99# This should be the original array, but instead it's all 99.99print(ds.variables["FREQUENCY"].data)
# I would expect both of these to print False, but it prints True, Falseprint(np.shares_memory(ds.variables["FREQUENCY"].data, ds2.variables["FREQUENCY"].data))
print(np.shares_memory(ds.variables["AMPLITUDE"].data, ds2.variables["AMPLITUDE"].data))
What happened?
I have a NetCDF file produced by an upstream process. After loading this into an xarray dataset and calling
DataSet.copy(deep=True)
, I find that some coordinates still share memory with the source of the copy.The NetCDF file in question:
data_clean.nc.zip
What did you expect to happen?
I expected a deep copy to be deep, with no shared memory between.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
The text was updated successfully, but these errors were encountered: