Skip to content

mf6 Package: copy method is broken #1498

@Huite

Description

@Huite
nlayer = 1
nrow = 5
ncol = 5

dx = 1000.0
dy = -1000.0

x = np.arange(0, dx * ncol, dx) + 0.5 * dx
y = np.arange(0, dy * nrow, dy) + 0.5 * dy
layer = np.array([1])

idomain = xr.DataArray(np.ones((nlayer, nrow, ncol), dtype=int), dims=("layer", "y", "x"), coords={"layer": layer, "y": y, "x": x})
rch_rate = xr.full_like(idomain.sel(layer=1), 0.001, dtype=float)

rch = imod.mf6.Recharge(rch_rate)
rch.copy()

Results in:

TypeError: Recharge.__init__() got an unexpected keyword argument 'coords'

Problem is:

    def copy(self) -> Any:
        # All state should be contained in the dataset.
        return type(self)(**self.dataset.copy().to_dict())

to_dict() will insert a coords member, which obviously won't be a keyword for a package.

Metadata

Metadata

Labels

bugSomething isn't workingneeds testsNeeds unit tests

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions