BrainPy v2.7.3
Release Date: December 2024
This is a bug fix release that resolves critical issues with bm.for_loop and improves CI stability.
π Bug Fixes
bm.for_loop jit Parameter Fix
- Fixed: The
jitparameter inbm.for_loopwas accepted but never used - passingjit=Falsehad no effect - Implementation: When
jit=False, the call is now properly wrapped injax.disable_jit()context manager - Impact: Users can now debug code with
jit=Falseto see actual values instead of JIT-compiled traces
Zero-Length Scan Fix
- Fixed:
ValueError: zero-length scan is not supported in disable_jit() modewhen usingjit=Falsewith zero-length inputs - Implementation: Automatically falls back to JIT mode for zero-length inputs with a warning
- Impact: Prevents crashes when
DSRunner.run(duration)results in 0 time steps (e.g.,duration=0.5, dt=1.0)
Progress Bar Enhancement
- Enhanced:
progress_barparameter inbm.for_loop()andbm.scan()now supports advanced customization - New Features:
- Accept
ProgressBarinstances for fine-grained control (freq, desc, count parameters) - Accept integers as shorthand for frequency (e.g.,
progress_bar=10means update every 10 iterations) - Full backward compatibility with existing
progress_bar=True/Falseusage
- Accept
- Export: Added
bm.ProgressBarfor easy access (from brainpy.math import ProgressBar) - Impact: Aligns with brainstate API and enables better progress tracking customization
Parameter Cleanup
- Removed: Unused parameters
rematandunroll_kwargsfrombm.for_loop() - Backward Compatibility:
rematparameter kept inLoopOverTime.__init__()with deprecation warning - Fixes: Resolved TypeErrors in
DSRunnerandLoopOverTimethat used these parameters
CI Improvements
- Fixed: TclError on Windows Python 3.13 CI due to missing Tcl/Tk configuration
- Implementation: Set
MPLBACKEND=Aggenvironment variable in GitHub Actions workflow - Impact: Matplotlib tests now run successfully on all platforms (Linux, macOS, Windows)
π― Code Quality
- Added comprehensive test coverage for all fixes (11 new test cases)
- Updated API documentation to reflect new functionality
- All 38 tests in
test_controls.pypass
π¦ Files Modified
brainpy/__init__.py: Updated version to 2.7.3brainpy/math/object_transform/controls.py: Fixed jit handling, zero-length scan, progress_bar enhancementbrainpy/math/object_transform/__init__.py: Exported ProgressBarbrainpy/runners.py: Fixed unroll_kwargs usage with functools.partialbrainpy/transform.py: Added remat deprecation warning in LoopOverTimebrainpy/math/object_transform/tests/test_controls.py: Added 11 new test casesdocs_classic/apis/brainpy.math.oo_transform.rst: Added ProgressBar to documentation.github/workflows/CI.yml: Added MPLBACKEND=Agg for all test jobs
π Related PRs
- #803: Fix
bm.for_loopjit parameter handling and remove unused parameters - #802: Original issue report about
jitparameter not working - #801: CI dependency updates
- #800: Documentation improvements
- #798: JointEq error message improvements
β οΈ Breaking Changes
None. All changes are backward compatible or involve previously non-functional parameters.
π¦ Installation
pip install --upgrade brainpy==2.7.3