Commit 73a54b3
authored
fix(ci): repair adaptive pooling ZeroDivisionError and mypy numpy stubs (#867)
Two standing CI failures, both from dependency drift since the last green run
(2026-06-19). Neither was caused by the recent _version.py move (that only broke
the editable-install build, already fixed in #866).
Continuous Integration (test failure):
brainpy/dnn/pooling.py::_adaptive_pool1d divided by `size // target_size`, which
is 0 whenever target_size > size (a spatial dim smaller than its target, e.g.
AdaptiveMaxPool3d(target=[6,5,4]) on an input axis of size 2). A newer jax
evaluates `arr.size % math.prod(...)` inside reshape, turning the resulting
reshape(-1, 0) into ZeroDivisionError (4 failed / 4179 passed). Rewrite it with
PyTorch-style adaptive bins -- output i = operation(x[floor(i*size/T) :
ceil((i+1)*size/T)]) -- which never yields an empty window and handles both
down- and up-sampling. Verified against the exact PyTorch formula (mean & max)
and under vmap. Add a positive-target_size guard and regression tests.
Type Checking (mypy failure):
numpy 2.5.1 ships PEP 695 `type` aliases in its stubs, which mypy rejects as a
syntax error unless the analysis target is Python 3.12+. Bump [tool.mypy]
python_version 3.11 -> 3.14.1 parent b75464a commit 73a54b3
3 files changed
Lines changed: 95 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
703 | 703 | | |
704 | 704 | | |
705 | 705 | | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
706 | 713 | | |
707 | 714 | | |
708 | 715 | | |
709 | 716 | | |
710 | 717 | | |
711 | 718 | | |
712 | 719 | | |
713 | | - | |
| 720 | + | |
| 721 | + | |
714 | 722 | | |
715 | 723 | | |
716 | 724 | | |
717 | 725 | | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
718 | 736 | | |
| 737 | + | |
| 738 | + | |
719 | 739 | | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
730 | 747 | | |
731 | 748 | | |
732 | 749 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 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 | + | |
| 339 | + | |
277 | 340 | | |
278 | 341 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| |||
0 commit comments