Skip to content

Added animation hold#136

Merged
TomGeorge1234 merged 1 commit intoRatInABox-Lab:mainfrom
colleenjg:cjg-dev
Apr 9, 2026
Merged

Added animation hold#136
TomGeorge1234 merged 1 commit intoRatInABox-Lab:mainfrom
colleenjg:cjg-dev

Conversation

@colleenjg
Copy link
Copy Markdown
Contributor

Added an option when creating animations (trajectory or rate timeseries) to hold the last frame for a few seconds.

You'll notice that I made frames an array instead of a lazy iterable.
frames = np.concatenate([np.arange(frames), np.repeat(frames - 1, hold_n)])

This is not the most memory efficient approach, but I couldn't find a way to make frames a lazy iterable. itertools.chain can chain iterables, but then you can't call len() on them, which matplotlib's animation function needs to do. This seemed like a reasonable compromise. If the user sets hold to 0, frames is left as a lazy iterable so previous behaviour is unchanged.

@TomGeorge1234
Copy link
Copy Markdown
Collaborator

honestly it seems fine to me! We can always look into it again if the inefficency becomes an issue.

thanks!

@TomGeorge1234 TomGeorge1234 merged commit bb468a2 into RatInABox-Lab:main Apr 9, 2026
3 checks passed
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