From 51b148cde6410844b00cc02b1408c14460c6a2d7 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Tue, 21 Mar 2023 18:26:01 +0100 Subject: [PATCH] update _load_stressmodel and tests - remove up and gain_scale_factor from dict and set using update_rfunc_settings - fix test the same way --- pastas/io/base.py | 6 +++++- tests/test_rfuncs.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pastas/io/base.py b/pastas/io/base.py index eed7059e0..63a4f894c 100644 --- a/pastas/io/base.py +++ b/pastas/io/base.py @@ -142,7 +142,11 @@ def _load_stressmodel(ts, data): if "rfunc" in ts.keys(): rfunc_class = ts["rfunc"].pop("class") # Determine response class - ts["rfunc"] = getattr(ps.rfunc, rfunc_class)(**ts["rfunc"]) + rfunc_up = ts["rfunc"].pop("up", None) # get up value + rfunc_gsf = ts["rfunc"].pop("gain_scale_factor", None) # get gain_scale_factor + rfunc = getattr(ps.rfunc, rfunc_class)(**ts["rfunc"]) + rfunc.update_rfunc_settings(up=rfunc_up, gain_scale_factor=rfunc_gsf) + ts["rfunc"] = rfunc if "recharge" in ts.keys(): recharge_class = ts["recharge"].pop("class") diff --git a/tests/test_rfuncs.py b/tests/test_rfuncs.py index aacaca894..2d707bf22 100644 --- a/tests/test_rfuncs.py +++ b/tests/test_rfuncs.py @@ -21,7 +21,10 @@ def test_to_dict_rfuncs(rfunc_name) -> None: # Create the exact same instance using to_dict data = rfunc1.to_dict() rfunc_class = data.pop("class") # Determine response class + rfunc_up = data.pop("up", None) + rfunc_gsf = data.pop("gain_scale_factor", None) rfunc2 = getattr(ps.rfunc, rfunc_class)(**data) + rfunc2.update_rfunc_settings(up=rfunc_up, gain_scale_factor=rfunc_gsf) if rfunc_name == "HantushWellModel": rfunc1.set_distances(100.0)