Skip to content

Release v0.12.2: Animation Format Support Enhancement

Choose a tag to compare

@Routhleck Routhleck released this 30 Dec 03:46
· 186 commits to master since this release

What's New

🎨 Unified Animation Writer with Multi-Format Support

  • Automatic format detection for animation saving (MP4, GIF, and more)
  • MP4 encoding is 36.8x faster than GIF with better quality
  • Simplified API across all visualization modules

Major Features / Key Changes

🎨 Animation Writer Improvements

  • New get_matplotlib_writer() function: Automatically detects output format from file extension and selects the appropriate writer (FFMpegWriter for MP4, PillowWriter for GIF, etc.)
  • Unified writer interface: Replaced hardcoded PillowWriter instances across visualization modules
  • Performance boost: MP4 encoding is 36.8x faster than GIF while providing better quality and smaller file sizes
from canns.analyzer.visualization.core import get_matplotlib_writer

# Automatically selects FFMpegWriter for .mp4
writer = get_matplotlib_writer('output.mp4', fps=30)

# Automatically selects PillowWriter for .gif
writer = get_matplotlib_writer('output.gif', fps=30)

🔧 Technical Improvements

  • Updated modules: spatial_plots.py, energy_plots.py, theta_sweep_plots.py now use format-aware writer selection
  • Code cleanup: Removed redundant writer configuration code (22 lines removed from theta_sweep_plots.py)
  • Better extensibility: Easy to add support for additional formats in the future

Files Modified

  • src/canns/analyzer/visualization/core/__init__.py: Export new writer function
  • src/canns/analyzer/visualization/core/writers.py: New writer factory function (51 lines)
  • src/canns/analyzer/visualization/spatial_plots.py: Updated to use automatic writer
  • src/canns/analyzer/visualization/energy_plots.py: Updated to use automatic writer
  • src/canns/analyzer/visualization/theta_sweep_plots.py: Simplified writer configuration

Breaking Changes

None - all changes are backward compatible.

Use Cases

  • Researchers: Save animations in MP4 format for faster encoding and better quality in publications
  • Daily analysis: Quickly generate animation outputs without worrying about format-specific writer configuration
  • Performance-sensitive workflows: 36.8x faster encoding when using MP4 format

Full Changelog: v0.12.1...v0.12.2