Skip to content

Commit

Permalink
update _load_stressmodel and tests
Browse files Browse the repository at this point in the history
- remove up and gain_scale_factor from dict and set using update_rfunc_settings
- fix test the same way
  • Loading branch information
dbrakenhoff committed Mar 21, 2023
1 parent 2fd896a commit 51b148c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pastas/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions tests/test_rfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 51b148c

Please sign in to comment.