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 checked that this issue has not already been reported.
I have checked that this bug exists on the latest version of HydroMT.
Reproducible Example
from hydromt import Model, raster
class MyModel(Model):
def __init__(self, root=None, mode="r"):
super().__init__(root, mode=mode)
def read_maps(
self,
) -> None:
da = raster.full_from_transform(
transform=[0.5, 0.0, 3.0, 0.0, -0.5, -9.0],
shape=(4, 6),
)
# this will cause a recursion error in read-mode
self.set_maps(da, name="test")
# and is preferred over the current implementation
# which does not make use of the checks in set_maps method
self._maps["test"] = da
mod = MyModel(mode="r+")
mod.read_maps() # RecursionError
I prefer to use the set_ methods inside the read methods to avoid duplicating code that does checks on the data. For developers implementing hydromt for their model I've always explicitly advised to avoid setting directly using self._maps[name] = data for the same reason.
Additional context
No response
The text was updated successfully, but these errors were encountered:
HydroMT version checks
Reproducible Example
Current behaviour
You get a RecursionError when using set methods inside read methods for any model component since #460
This is used a lot in plugins and the new implementation causes errors downstream, see e.g. https://github.com/Deltares/hydromt_sfincs/actions/runs/5797018073/job/15711743003
Desired behaviour
I prefer to use the set_ methods inside the read methods to avoid duplicating code that does checks on the data. For developers implementing hydromt for their model I've always explicitly advised to avoid setting directly using
self._maps[name] = data
for the same reason.Additional context
No response
The text was updated successfully, but these errors were encountered: