• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PrincetonUniversity / PsyNeuLink / 25497910489
84%
master: 85%

Build:
Build:
LAST BUILD BRANCH: devel
DEFAULT BRANCH: master
Ran 07 May 2026 02:19PM UTC
Jobs 1
Files 163
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

07 May 2026 01:11PM UTC coverage: 84.218% (+0.007%) from 84.211%
25497910489

push

github

web-flow
DriftOnASphereIntegrator: fix scalar-noise crash when wrapped in a Mechanism (#3534)

## Bug

Wrapping a `DriftOnASphereIntegrator` in any Mechanism
(`ProcessingMechanism`, `IntegratorMechanism`, etc.) and calling
`execute` / `Composition.run` crashes with

```
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0,
with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 1 is different from 24)
```

even when the integrator was constructed with a Python scalar
`noise=0.075`. Standalone `integ.execute(...)` works fine; only the
Mechanism-wrapped path crashes.

## Repro (against devel HEAD before this PR)

```python
import numpy as np
import psyneulink as pnl

init = np.random.random(25); init /= np.linalg.norm(init)
integ = pnl.DriftOnASphereIntegrator(
    dimension=25, noise=0.075, initializer=init, default_variable=np.zeros(24)
)
pm = pnl.ProcessingMechanism(default_variable=[[0.0] * 24], function=integ)
pm.execute([[0.0] * 24])  # ← matmul crash
```

## Root cause

PNL's parameter system stores the scalar `noise=0.075` as a length-1
ndarray when the function is bound to a Mechanism. At execute time,
`DriftOnASphereIntegrator._function`'s vector-noise branch
(`np.ndim(noise) == 1`) then runs against that length-1 array as if it
were a true per-dimension noise vector. The matmul `B @ (noise * eps)`
becomes `(d, d-1) @ (1,)` and numpy errors with the size-1-vs-`d-1`
mismatch.

## Fix

Two-line tightening in `_function`:

1. The vector branch now requires `noise.size > 1` (length-1 arrays fall
through to scalar handling).
2. The vector branch validates `noise.size == d - 1` and raises a clear
`FunctionError` otherwise — instead of letting numpy throw an opaque
matmul error.
3. The scalar branch `.item()`s 0-d / 1-d arrays back to a Python float
so the downstream `noise * z` shape is unambiguous.

## Verification

- `tests/functions/test_integrator.py` — all 18
`sphere`/`DriftOnASphere`-filtered tests pass against the patched
source.
- Re... (continued)

10520 of 13698 branches covered (76.8%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 1 file covered. (100.0%)

36185 of 41759 relevant lines covered (86.65%)

0.87 hits per line

Jobs
ID Job ID Ran Files Coverage
1 25497910489.1 07 May 2026 02:19PM UTC 163
84.22
GitHub Action Run
Source Files on build 25497910489
  • Tree
  • List 163
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 0f8d8bf3 on github
  • Prev Build on devel (#25299956806)
  • Next Build on devel (#25535066478)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc