Validation of the coreg method inputs - #971
Conversation
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
@rhugonnet just to be sure : |
|
@marinebcht Great to finally solve it. I like your solution. And you're right, I think we can then remove the checks in the subclasses to avoid duplication. The Small remark: Maybe we can add an override for the "Literal" case to not print directly its type (I'm sure many users will not know what "Literal" is), to instead print something like |
|
@rhugonnet Speaking of your example, the param in the ICP method (method) and its name in the CoregType (icp_method) is not the same ... So the error does not correspond 😔 |
We can have an exception for "Specific" parameters, so that the name prefix (icp_, lzd_, etc) is removed before raising the error; Or we can make them the same as the CoregDict in the |
Resolves #761
The input parameters for the coregistration functions were not tested, and the potential errors were not very clear (see #761).
To avoid this, I introduced a new check after the construction of the CoregDict dictionary to verify that it contains the correct types :
validate_typed_dict([the_dict_to_check, the_corresponding_type). This function raises an error when one of the key differs to the expected key type and can be use for any dictionary/type.Examples of errors :
/!\ Some of the parameters are checked before the construction on the dict (
CoregMethod __init__()) :TypeError: Argumentfit_optimizermust be a function (callable), got <class 'str'>.Types Changes
fit_loss_func can be :
=> fit_loss_func: Callable[[NDArrayf], np.floating[Any]] | str
=> Raises error if string in DHMinize init
Delete old checks
In NuthKaab:
Notes
Error when type is Literal :