Commit 62646fd
Fix
* Initial plan
* Fix bm.for_loop jit parameter handling and remove unused parameters
Co-authored-by: Routhleck <[email protected]>
* Enhance progress_bar parameter to support ProgressBar instances
This commit improves the `progress_bar` parameter in `bm.for_loop()` and
`bm.scan()` to accept ProgressBar instances and integers for advanced
customization, while maintaining full backward compatibility.
Changes:
- Added `_convert_progress_bar_to_pbar()` helper function for parameter conversion
- Updated type hints to `Union[bool, brainstate.transform.ProgressBar, int]`
- Enhanced docstrings with detailed examples for all supported types
- Exported `ProgressBar` from `brainpy.math` for easy access
- Added 10 comprehensive test cases covering all usage patterns
- Updated API documentation to include ProgressBar
Supported usage:
- `progress_bar=True/False` (backward compatible)
- `progress_bar=bm.ProgressBar(freq=10)` (custom frequency)
- `progress_bar=bm.ProgressBar(desc="Processing")` (custom description)
- `progress_bar=10` (integer shorthand for freq parameter)
All 37 tests in test_controls.py pass, ensuring no regressions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix runners.py to use functools.partial instead of removed unroll_kwargs
The unroll_kwargs parameter was removed from bm.for_loop() as it was never
actually implemented. Updated runners.py to use functools.partial() to bind
shared_args to _step_func_predict, following the pattern already used in
train/online.py.
Changes:
- Added functools import
- Changed for_loop call to use functools.partial(self._step_func_predict, shared_args=shared_args)
- Removed unroll_kwargs={'shared_args': shared_args} which was non-functional
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix LoopOverTime to remove remat parameter from for_loop call
The remat parameter was removed from bm.for_loop() as it was never
implemented. Updated LoopOverTime to:
1. Remove remat from the for_loop() call
2. Keep remat parameter in __init__ for backward compatibility
3. Add deprecation warning when remat=True is passed
Changes:
- Removed remat=self.remat from for_loop call on line 283
- Added deprecation warning for remat parameter
- Removed self.remat storage (commented out for clarity)
This maintains backward compatibility while warning users that the
parameter no longer has any effect.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix zero-length scan error when using jit=False
When jit=False is used with zero-length input arrays, JAX's disable_jit()
mode cannot handle the scan operation because it cannot infer the output type.
Changes:
- Added check for zero-length inputs when jit=False
- Automatically falls back to JIT mode for zero-length inputs
- Issues a UserWarning to inform users of the fallback
- Added test case to verify zero-length input handling
- All 38 tests in test_controls.py pass
This fix resolves: ValueError: zero-length scan is not supported in
disable_jit() mode because the output type is unknown.
* Set MPLBACKEND=Agg in CI to fix Tkinter issues on Windows
On Windows Python 3.13 CI environment, Tcl/Tk is not properly configured,
causing matplotlib tests to fail with TclError. Setting the MPLBACKEND
environment variable to 'Agg' (non-interactive backend) resolves this issue.
Changes:
- Added MPLBACKEND=Agg env var to all test jobs (Linux, macOS, Windows)
- This ensures consistent behavior across all CI platforms
- Fixes TclError in test_phase_plane.py and test_aligns.py on Windows
This is a cleaner solution than modifying individual test files.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Routhleck <[email protected]>
Co-authored-by: routhleck <[email protected]>
Co-authored-by: Claude <[email protected]>bm.for_loop jit parameter handling and remove unused parameters (#803)1 parent 0c5b521 commit 62646fd
File tree
8 files changed
+2287
-26
lines changed- .github/workflows
- brainpy
- math/object_transform
- tests
- docs_classic/apis
8 files changed
+2287
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
| 83 | + | |
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
| |||
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| 113 | + | |
| 114 | + | |
109 | 115 | | |
110 | 116 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
34 | 71 | | |
35 | 72 | | |
36 | 73 | | |
| |||
205 | 242 | | |
206 | 243 | | |
207 | 244 | | |
208 | | - | |
209 | 245 | | |
210 | | - | |
211 | | - | |
| 246 | + | |
212 | 247 | | |
213 | 248 | | |
214 | 249 | | |
| |||
266 | 301 | | |
267 | 302 | | |
268 | 303 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | 304 | | |
274 | 305 | | |
275 | 306 | | |
| |||
278 | 309 | | |
279 | 310 | | |
280 | 311 | | |
281 | | - | |
282 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
283 | 339 | | |
284 | 340 | | |
| 341 | + | |
| 342 | + | |
285 | 343 | | |
286 | 344 | | |
287 | 345 | | |
| |||
296 | 354 | | |
297 | 355 | | |
298 | 356 | | |
299 | | - | |
300 | | - | |
301 | 357 | | |
302 | 358 | | |
303 | 359 | | |
| |||
306 | 362 | | |
307 | 363 | | |
308 | 364 | | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
314 | 404 | | |
315 | 405 | | |
316 | 406 | | |
| |||
320 | 410 | | |
321 | 411 | | |
322 | 412 | | |
323 | | - | |
| 413 | + | |
324 | 414 | | |
325 | 415 | | |
326 | 416 | | |
| |||
359 | 449 | | |
360 | 450 | | |
361 | 451 | | |
362 | | - | |
363 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
364 | 461 | | |
365 | 462 | | |
| 463 | + | |
| 464 | + | |
366 | 465 | | |
367 | 466 | | |
368 | 467 | | |
369 | 468 | | |
370 | 469 | | |
371 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
372 | 474 | | |
373 | 475 | | |
374 | 476 | | |
375 | 477 | | |
376 | 478 | | |
377 | 479 | | |
378 | | - | |
| 480 | + | |
379 | 481 | | |
380 | 482 | | |
381 | 483 | | |
| |||
0 commit comments