Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions autotest/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ def model_is_copy(m1, m2):
return False
for k, v in m1.__dict__.items():
v2 = m2.__dict__[k]
if v2 is v and type(v) not in [bool, str, type(None), float, int]:
# Allow identity sharing for immutable types including NumPy scalars
is_immutable = type(v) in [bool, str, type(None), float, int] or isinstance(
v, np.generic
)
if v2 is v and not is_immutable:
# some mf6 objects aren't copied with deepcopy
if isinstance(v, MFSimulationData):
continue
Expand Down Expand Up @@ -78,7 +82,16 @@ def package_is_copy(pk1, pk2):
"""
for k, v in pk1.__dict__.items():
v2 = pk2.__dict__[k]
if v2 is v and type(v) not in [bool, str, type(None), float, int, tuple]:
# Allow identity sharing for immutable types including NumPy scalars
is_immutable = type(v) in [
bool,
str,
type(None),
float,
int,
tuple,
] or isinstance(v, np.generic)
if v2 is v and not is_immutable:
# Deep copy doesn't work for ModflowUtltas
if not inspect.isclass(v):
return False
Expand Down
Loading