Typechecking within parcels to provide better error messages #1234
VeckoTheGecko
started this conversation in
Ideas
Replies: 1 comment
-
Good catch, @VeckoTheGecko. Could you add this check in the code yourself and create a PR? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think it would be good to enforce types within the user level API (eg.
if not isinstance(obj, class): raise ...
). Some error messages are very uninformative otherwise.Example
I wanted to combine a list of kernels down to a single combined kernel. Typing this:
raised this very cryptic traceback:
The underlying error is that
pset.Kernel
is applied twice by thelambda
(once on the left, and once on the right) and theKernel
method can't handle this as it does not verify thatpyfunc
isCallable
:https://github.com/OceanParcels/parcels/blob/7f6610417c948e85d65d98704db36e55e505b5a7/parcels/particleset/particlesetsoa.py#L644-L651
Clarifying this by having raising an error ("
pyfunc
must be Callable") or havingpset.Kernel(kern)
returnkern
would help here. In general, having this across the codebase would prevent similar errors.Of course, my example can be solved by doing:
Beta Was this translation helpful? Give feedback.
All reactions