xdem icon indicating copy to clipboard operation
xdem copied to clipboard

Raise type errors for coregistration inputs using existing TypedDicts

Open adebardo opened this issue 6 months ago • 1 comments

Context

We have highlighted that typing errors in APIs are not very clear.

aligned_dem = tba_dem.coregister_3d(ref_dem, xdem.coreg.NuthKaab(max_iterations="6"))

Image

@rhugonnet indicates that this relies on the typing work of our classes.

adebardo avatar Jul 17 '25 09:07 adebardo

Yes, the static typing works (if users use an IDE, they'll probably see that their argument is wrong), but the code doesn't fail elegantly if not because we aren't actually checking the inputs. It isn't too much work to raise proper TypeError because we can use the TypedDict we have defined in coreg/base to automatically check those with what's already defined.

rhugonnet avatar Jul 18 '25 00:07 rhugonnet