sc_neurocore_engine/bindings/
hindmarsh_rose.rs1use numpy::{IntoPyArray, PyArray1};
12use pyo3::prelude::*;
13use pyo3::types::PyDict;
14
15use crate::neurons::HindmarshRoseNeuron;
16
17py_neuron_default!("HindmarshRoseNeuron", PyHindmarshRoseNeuron, HindmarshRoseNeuron, state x, state y, state z);
18
19pub(super) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
21 module.add_class::<PyHindmarshRoseNeuron>()?;
22 module.add_function(wrap_pyfunction!(py_hindmarsh_rose_simulate, module)?)?;
23 Ok(())
24}
25
26#[pyfunction]
34#[pyo3(signature = (x0, y0, z0, b, r, s, x_rest, dt, x_threshold, n_steps, current))]
35#[allow(clippy::too_many_arguments)]
36fn py_hindmarsh_rose_simulate<'py>(
37 py: Python<'py>,
38 x0: f64,
39 y0: f64,
40 z0: f64,
41 b: f64,
42 r: f64,
43 s: f64,
44 x_rest: f64,
45 dt: f64,
46 x_threshold: f64,
47 n_steps: usize,
48 current: f64,
49) -> (Bound<'py, PyArray1<f64>>, i64, f64, f64, f64) {
50 let mut neuron = HindmarshRoseNeuron {
51 x: x0,
52 y: y0,
53 z: z0,
54 b,
55 r,
56 s,
57 x_rest,
58 dt,
59 x_threshold,
60 };
61 let (trace, spikes) = neuron.simulate(n_steps, current);
62 (trace.into_pyarray(py), spikes, neuron.x, neuron.y, neuron.z)
63}