Skip to content
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

Improve errors #478

Merged
merged 14 commits into from
Aug 18, 2024
Merged

Conversation

lockwo
Copy link
Contributor

@lockwo lockwo commented Aug 7, 2024

Previously, the abstract term error, now:

#446: ValueError: Error while tracing ODETerm(vector_field=<function equations>).vf: matmul input operand 1 must have ndim at least 1, but it has ndim 0

#461: ValueError: The brownian increment BrownianIncrement(dt=f32[], W=f32[5]) does not have the minimal Levy Area <class 'diffrax._custom_types.AbstractSpaceTimeLevyArea'>.

#474: ValueError: The brownian increment BrownianIncrement(dt=f32[], W=f32[]) does not have the minimal Levy Area <class 'diffrax._custom_types.AbstractSpaceTimeLevyArea'>.

Just generally propagating the actual error

@patrick-kidger
Copy link
Owner

(Let me know when you want a review btw, I'm ignoring this for now whilst it's a draft -- which I'm taking as a "you don't need to review this yet" signal)

@lockwo
Copy link
Contributor Author

lockwo commented Aug 12, 2024

(Let me know when you want a review btw, I'm ignoring this for now whilst it's a draft -- which I'm taking as a "you don't need to review this yet" signal)

Yea, that's exactly what I mean by draft, you can ignore it. But with the weird backward edge case resolved, it is ready for you to take a look at

@lockwo lockwo marked this pull request as ready for review August 12, 2024 19:55
Comment on lines 140 to 142
if not _term_compatible(
yi, args, term, arg, term_contr_kwarg, bwd_compat
):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is now wrong, as the return type is a 2-tuple rather than a boolean?

I think perhaps we should instead change the name and signature of this function to be _assert_term_compatible(...) -> None, and have it raise an error if it finds an issue?
In a couple of cases (here; in the backward compatibility), we can then try-except the error in question. (Here to do a raise ValueError(...) from e; in the backward compability just to treat it as a boolean.)

Copy link
Contributor Author

@lockwo lockwo Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, changing to assert makes sense, then I can make the try catch block explicitly around the backward compatibility code rather than as a flag. It's not hurdle keeping it, but I'm curious what's the motivation for this specific backward compatible section? Diffrax (and equinox) have introduced breaking/non backward compatible changes in other areas (I think new events did for example, and equinox is about with jax, and I'm sure other cases).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really just that I try to avoid backward compatibility breaks if it's reasonable to do so.

The change with events, for example, includes a similar backward compatibility converter. That one was a little imperfect because we no longer provide the same information as the old events API (which was far too broad), but was still a best-effort!

Copy link
Contributor Author

@lockwo lockwo Aug 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admire your commitment to backwards compatibility for pre 1.0 releases, in the crucible I was forged (qiskit) there were so many breaking changes in minor releases pre 1.0 that they literally made a YouTube series called “breaking changes” to help explain them all every minor release

diffrax/_integrate.py Outdated Show resolved Hide resolved
diffrax/_solver/srk.py Outdated Show resolved Hide resolved
diffrax/_integrate.py Outdated Show resolved Hide resolved
@patrick-kidger
Copy link
Owner

patrick-kidger commented Aug 17, 2024

Great! This LGTM.

Looks like one of the tests has gone a bit wonky, I'm not sure why. Anyway, happy to merge this once things are green.

(Whilst I'm here, I'm also noticing that our tests have quite a few warnings in them. Some of these are expected -- fixed upstream in Equinox, which should have a new release any day now. The one about WeaklyDiagonalControlTerm could probably do with being suppressed in the tests, though.)

@patrick-kidger patrick-kidger merged commit f0f6cf7 into patrick-kidger:main Aug 18, 2024
2 checks passed
@patrick-kidger
Copy link
Owner

And merged! :)

@lockwo lockwo deleted the Owen/improve-errors branch August 20, 2024 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants