Skip to content

Surprising deepcopy semantics with dtype='object' #4362

Closed
@darikg

Description

@darikg
from copy import deepcopy
import numpy as np
import xarray as xr

class Dummy: pass

a0 = np.array([Dummy()])
a1 = deepcopy(a0)
print(a0[0] is a1[0])  # False, as expected

x0 = xr.DataArray(a0, dims='dummy')
x1 = deepcopy(x0)
print(x0.values[0] is x1.values[0])  # unexpectedly True

I think this is a bug, and would be fixed with an extra deepcopy around here

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtopic-arraysrelated to flexible array support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions