Skip to content

Ensure that the interpolation domain is sorted #421

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

Merged
merged 5 commits into from
Apr 9, 2025

Conversation

SebastianM-C
Copy link
Contributor

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

A frequent user error is forgetting the correct argument error. This results in silently wrong results or extrapolation errors. I think that we can surface this error earlier to avoid further confusion. Let me know what you think about this.

ChrisRackauckas
ChrisRackauckas previously approved these changes Apr 9, 2025
@SebastianM-C
Copy link
Contributor Author

SebastianM-C commented Apr 9, 2025

Sorry, got the function wrong 😅
Should be fine now, I hope. I also noticed that we didn't check that length(t) == length(u) if there were no missing values, so I moved that up.

@SebastianM-C
Copy link
Contributor Author

hmm, It looks like RegularizationSmooth might need special treatment since it has 3 argument and the 3rd one has to be sorted, not the second one.

We have 3 arguments here and the 3rd one
has to be sorted instead of the second.
SouthEndMusic
SouthEndMusic previously approved these changes Apr 9, 2025
Copy link
Member

@SouthEndMusic SouthEndMusic left a comment

Choose a reason for hiding this comment

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

Nice, I remember being somewhat surprised that we didn't validate for the ordering of t before. I left a few comments.

if Tu === eltype(u) && Tt === eltype(t)
if !(issorted(check_sorted) || issorted(check_sorted, rev = true))
Copy link
Member

Choose a reason for hiding this comment

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

Should we support reverse ordering? It wouldn't surprise me if that violates an implicit assumption in certain methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me see if there's actually any test that errors if I remove reverse ordering. Some methods explicitly mention that they need monotonically increasing values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

842f606 changes to just monotonically increasing, nothing seems to be using reverse ordering and as you mention it likely is wrong. Is that would be needed in the future, we can add another flag to the function for that.

@ChrisRackauckas ChrisRackauckas merged commit 832fbab into SciML:master Apr 9, 2025
16 checks passed
@SebastianM-C SebastianM-C deleted the smc/err branch April 9, 2025 22:44
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.

3 participants