Tools for producing animations and movies (FPS, NoInterrupt contexts)
Project description
MMF Contexts
This package provides a set of contexts to help working with Jupyter notebooks, especially producing animations, movies, and managing signals.
Usage
The main use-case is to do your work in an FPS context:
from mmf_contexts import FPS
for n in FPS(30, fps=10):
print(n)
This adds the following functionality:
KeyboardInterruptsare suspended during the loop body and will be processed each cycle. Thus, the actions in the loop are safe from being interrupted in a sensitive location. This allows you to useCtrl-Cetc. to stop the loop without crashing your program. (If you really need to stop it immediately, you can send 3Ctrl-Cin rapid succession.)- The loop will be rate limited to a maximum of approximately 10 frames per second.
A nice use-case is to make movies. The following works well in Jupyter Notebooks:
%matplotlib
import numpy as np, matplotlib.pyplot as plt
from mmf_contexts import FPS
x = np.linspace(0, 1)
fs = np.linspace(1, 30)
fig, ax = plt.subplots()
for f in FPS(fs, display=fig, embed=True, filename="mymovie.mp4"):
ax.cla()
ax.plot(x, np.sin(f*x))
This will make an animation while running in the Jupyter notebook, then embed this
animation as a movie so you can view it even if the notebook is running. Finally, it
will also save the animation to the file mymovie.mp4.
To Do: This does not yet work with standard IPython terminals since it relies on
display. Support for more general use-cases is a work in progress.
Change Log
REL: 0.1.2
- Just add
README.mdso PyPI has a description. No code changes.
REL: 0.1.1
- Added
README.mddocumentation. - Fixed bug with Jupyter Notebooks and movies (missing
MovieWriter). *(We need to find a good way of automating tests with Jupyter notbeook.) - Fixed links to docs etc.
REL: 0.1.0
Initial release. Attempted to upload this as animate to PyPI, but this is not
allowed, so we are renaming it mmf-contexts.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mmf_contexts-0.1.2.tar.gz.
File metadata
- Download URL: mmf_contexts-0.1.2.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.7 CPython/3.11.13 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbaccdeda887eafbd2394d5950ef69ca7e4d0d7d42480b1f99d0b42b9bd293e4
|
|
| MD5 |
e36b6e456212a939def3de64173dede2
|
|
| BLAKE2b-256 |
a5d1ef78ec6047b137f80f20d07acbfed911ff25ef79b199a0dd6be33306b78b
|
File details
Details for the file mmf_contexts-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mmf_contexts-0.1.2-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.7 CPython/3.11.13 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
561c78b14f2bb5a9e189113e85f958b4bcf6202865698c2d04ec9da75ef9ddb6
|
|
| MD5 |
a722920ad80c8973a7113380aec01524
|
|
| BLAKE2b-256 |
b4e7fafb4a3ed4339bce4a29cedad99ccf87e53aa60c309dac8bcc73161deddc
|