ImperialCollegeLondon / wsi

WSIMOD is a software for simulating water quality and quantity
https://imperialcollegelondon.github.io/wsi/
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Adds the extensions patch functionality #101

Closed dalonsoa closed 2 months ago

dalonsoa commented 2 months ago

Adds the ability to patch any method, attribute or item within an attribute in a node using decorators. This includes the patching of handlers and of sub-attributes.

Supersedes #97

dalonsoa commented 2 months ago

It does have access, and indeed the test will fail if I call the node.pull_set_handler["default"] since it does not have the right input arguments. All versions of the patch require the first argument to be a node (typically self). The only difference is that for the case of having an item the previous version of the object to override is not preserved in a self._patched_whatever. This is - I had hoped - explained in the docstring.

I'll check your test, now

dalonsoa commented 2 months ago

There was a but in the code making the use of the function more convoluted. I've fixed the bug and amend your test, so it works as it should. See the following for the changes https://github.com/ImperialCollegeLondon/wsi/pull/101/commits/566976ee6d905424ac5f34f7b2ac874ca551c087

Many thanks for your tests - they have picked a few things that were just wrong.