The "Fully custom simulator" example in the Simulator class docstring
(ssms/basic_simulators/simulator_class.py) raises when run verbatim.
The example returns 1-D rts/choices, but Simulator.simulate() calls
np.squeeze(x["rts"], axis=1) (simulator_class.py:675), which requires a
second axis.
This matters more than a typical docstring slip because it is the documented
entry point for the "bring your own model" workflow, and it is copy-pasteable.
Reproducer
import numpy as np
from ssms.basic_simulators.simulator_class import Simulator
# verbatim from the docstring
def my_sim(v, a, z, t, max_t=20, n_samples=1000, **kwargs):
rts = np.random.exponential(1/abs(v), n_samples) + t
choices = np.where(np.random.random(n_samples) < z, 1, -1)
return {'rts': rts, 'choices': choices,
'metadata': {'model': 'custom', 'n_samples': n_samples}}
sim = Simulator(simulator_function=my_sim, params=["v", "a", "z", "t"], nchoices=2)
results = sim.simulate(theta={'v': 0.5, 'a': 1.0, 'z': 0.5, 't': 0.3})
File ".../ssms/basic_simulators/simulator_class.py", line 675, in simulate
x["rts"] = np.squeeze(x["rts"], axis=1)
numpy.exceptions.AxisError: axis 1 is out of bounds for array of dimension 1
Returning (n_samples, 1) arrays instead works.
Possible fixes
Either update the docstring to require (n_samples, 1), or promote 1-D returns
to 2-D in simulate() before the squeeze.
Also note the same call emits three warnings about my_sim missing max_t,
delta_t and random_state — but the docstring example only declares max_t,
so following the docs guarantees warnings.
Version: ssm-simulators 0.13.2, numpy 2.4.6, Python 3.12
The "Fully custom simulator" example in the
Simulatorclass docstring(
ssms/basic_simulators/simulator_class.py) raises when run verbatim.The example returns 1-D
rts/choices, butSimulator.simulate()callsnp.squeeze(x["rts"], axis=1)(simulator_class.py:675), which requires asecond axis.
This matters more than a typical docstring slip because it is the documented
entry point for the "bring your own model" workflow, and it is copy-pasteable.
Reproducer
Returning
(n_samples, 1)arrays instead works.Possible fixes
Either update the docstring to require
(n_samples, 1), or promote 1-D returnsto 2-D in
simulate()before the squeeze.Also note the same call emits three warnings about
my_simmissingmax_t,delta_tandrandom_state— but the docstring example only declaresmax_t,so following the docs guarantees warnings.
Version: ssm-simulators 0.13.2, numpy 2.4.6, Python 3.12