Skip to content

Fix to/from-file without events and resample corner cases#73

Merged
sixpearls merged 20 commits intomainfrom
load-save-events
Apr 12, 2026
Merged

Fix to/from-file without events and resample corner cases#73
sixpearls merged 20 commits intomainfrom
load-save-events

Conversation

@ixjlyons
Copy link
Copy Markdown
Contributor

@ixjlyons ixjlyons commented Mar 6, 2026

Fixes #70, #71, #72

@ixjlyons ixjlyons changed the title Fix to/from-file without events Fix to/from-file without events and resample corner cases Apr 10, 2026
Copy link
Copy Markdown
Contributor

@sixpearls sixpearls left a comment

Choose a reason for hiding this comment

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

Looks nice, thanks!

Comment thread src/condor/contrib.py Outdated
new_t = t_grid
new_x = np.empty((t_grid.size, self._res.x.shape[1]), float)
for seg in interp:
i_to_samp = np.nonzero((t_grid >= seg.t0) & (t_grid <= seg.t1))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was worried you would have an issue using >= and <= if there is an event on the grid. But it seems like you have test coverage for it -- do you know which side of the event it takes?

Copy link
Copy Markdown
Contributor Author

@ixjlyons ixjlyons Apr 10, 2026

Choose a reason for hiding this comment

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

Nice, that's a subtlety I hadn't thought through. It comes from t+ because the one matching <= from a previous segment is overwritten by the match with >= on the next segment. Perhaps it should be >= & < to be more explicit (and slightly more efficient I guess). The tf event would then need special handling, but that's not a big deal. This was my test rig (the sample at 0.3 does not coincide exactly with the event, but the one at 0.5 does, yay floating point)

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made the switch to >= & < for aesthetics and added a test.

Comment thread src/condor/contrib.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While you're here, would it make sense to handle re-sampling if there is no implementation?

Copy link
Copy Markdown
Contributor Author

@ixjlyons ixjlyons Apr 10, 2026

Choose a reason for hiding this comment

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

Merged in #76 and updated it slightly. Also created #78

Comment thread src/condor/contrib.py
@sixpearls sixpearls merged commit 7a0f622 into main Apr 12, 2026
34 checks passed
@ixjlyons ixjlyons deleted the load-save-events branch April 12, 2026 17:36
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.

TrajectoryAnalysis.resample fails on ODEs with single state

3 participants