OutlierVentures / QTM-Interface

GNU General Public License v3.0
28 stars 18 forks source link

Function Robustness #38

Closed achimstruve closed 9 months ago

achimstruve commented 1 year ago

Someone needs to go through all the policy functions in the ./Model/parts directory and improve the input error catching and handling.

E.g. implementing checks for numbers not to be below 0 where appropriate and to throw an explaining error message. Also think of other potential wrong / invalid inputs for the functions, catch them and throw appropriate errors.

One way to throw an error would be by calling raise ValueError("This is an error message example!")

We can also do more assertations if necessary, such as this example of row 336 in ./Model/parts/utils.py: np.testing.assert_allclose(radCAD_value, QTM_data_table_value, rtol=relative_tolerance, err_msg=error_message)

Whenever implementing such error catches, make sure that the ./Model/tests/test_stage.py always runs through without complications.

alex-damjanovic commented 1 year ago

E.g. implementing checks for numbers not to be below 0 where appropriate and to throw an explaining error message. Also think of other potential wrong / invalid inputs for the functions, catch them and throw appropriate errors.

I am thinking if this should be even handled in these files, as the inputs are mostly from the params dictionary.

On the first glance I think a simple numpy.max (x, 0) could handle most of the edge cases, no?

cc @achimstruve @BlockBoy32

achimstruve commented 1 year ago

Yeah, you are right. We can do this as a first iteration and always can improve it later on.

The most modular and clean approach would be to have error catches / handlings within individual functions and additionally on the input parameter level, such as described in issue #44. That is why we have two issues. This one is for the function level.

Regarding the function level, another important aspect is to check all divisions that happen in any function and to ensure the denominator is never 0.

cc @alex-damjanovic

achimstruve commented 9 months ago

I am closing this issue as the model reached a good robustness due to extensive usage and corresponding adjustments. We could re-open it if someone wants to go deep on this again.