-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More verbose error messages #66
More verbose error messages #66
Conversation
Gives more information about why the error failed.
Gives more information about why the error failed.
…V/diffrax into FedericoV-verbose-error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologise for doing this ;)
diffrax/integrate.py
Outdated
@@ -599,7 +599,8 @@ def diffeqsolve( | |||
|
|||
# Error checking | |||
if dt0 is not None: | |||
error_if(lambda: (t1 - t0) * dt0 <= 0, "Must have (t1 - t0) * dt0 > 0") | |||
msg = f"Must have (t1 ({t1, type(t1)}) - t0 ({t0, type(t0)})) * dt0 ({dt0, type(dt0)})> 0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I find this a little hard to read. Can the f"{}"
values be collected at the end of the error message?
When printing out a type, can we use plain English to denote what's going on, e.g. Got value {t1} of type {type(t1)}.
diffrax/misc/errors.py
Outdated
"`pred` must either be a `bool`, a NumPy array, a JAX array, or a " | ||
"zero-argument callable that returns a `bool` or JAX array." | ||
f"`pred` {pred} must either be a `bool`, a JAX array, or a zero-argument callable " | ||
f"that returns a `bool` or JAX array, instead of {type(pred)}." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd don't hold to this as a hard-and-fast rule, but for something like this where an error here can almost only ever occur due to something totally crazy: I'd recommend putting the f"{}"
values at the end of the docstring. That way if they're something with a huge __str__
they won't blat the rest of the error message that comes after them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good :)
Let me know if this looks better.
Error messages now have type and value information and the end.
LGTM! I'll merge once the tests pass and we'll fold this into the 0.0.3 release. |
...if the tests pass, haha. It looks you haven't set up the pre-commit hooks. See CONTRIBUTING.md. |
Makes the error messages a bit more verbose in a few places, with information about types and values.