Skip to content

mf6 Package: copy method is broken #1498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Huite opened this issue Mar 27, 2025 · 1 comment · Fixed by #1505
Closed

mf6 Package: copy method is broken #1498

Huite opened this issue Mar 27, 2025 · 1 comment · Fixed by #1505
Assignees
Labels
bug Something isn't working needs tests Needs unit tests

Comments

@Huite
Copy link
Contributor

Huite commented Mar 27, 2025

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.

@Huite Huite added the bug Something isn't working label Mar 27, 2025
@github-project-automation github-project-automation bot moved this to 📯 New in iMOD Suite Mar 27, 2025
@Huite
Copy link
Contributor Author

Huite commented Mar 27, 2025

Simple removing the .to_dict() call might fix it?

Also having this unit-tested would be good...

@JoerivanEngelen JoerivanEngelen moved this from 📯 New to 🤝 Accepted in iMOD Suite Mar 28, 2025
@JoerivanEngelen JoerivanEngelen added the needs tests Needs unit tests label Mar 28, 2025
@JoerivanEngelen JoerivanEngelen moved this from 🤝 Accepted to 🏗 In Progress in iMOD Suite Apr 17, 2025
@JoerivanEngelen JoerivanEngelen self-assigned this Apr 17, 2025
@JoerivanEngelen JoerivanEngelen moved this from 🏗 In Progress to 🧐 In Review in iMOD Suite Apr 17, 2025
JoerivanEngelen added a commit that referenced this issue Apr 17, 2025
Fixes #1498 

# Description
Fix broken copy method

# Checklist
<!---
Before requesting review, please go through this checklist:
-->

- [x] Links to correct issue
- [x] Update changelog, if changes affect users
- [x] PR title starts with ``Issue #nr``, e.g. ``Issue #737``
- [x] Unit tests were added
- [ ] **If feature added**: Added/extended example

---------

Co-authored-by: JoerivanEngelen <joerivanengelen@hotmail.com>
@github-project-automation github-project-automation bot moved this from 🧐 In Review to ✅ Done in iMOD Suite Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs tests Needs unit tests
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants