sc_neurocore_engine/bindings/
ermentrout_kopell_map.rs1use numpy::{IntoPyArray, PyArray1};
12use pyo3::exceptions::PyFloatingPointError;
13use pyo3::prelude::*;
14use pyo3::types::PyDict;
15
16use crate::neurons::ErmentroutKopellMapNeuron;
17
18py_neuron_default!("ErmentroutKopellMapNeuron", PyErmentroutKopellMapNeuron, ErmentroutKopellMapNeuron, state theta);
19
20pub(super) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
22 module.add_class::<PyErmentroutKopellMapNeuron>()?;
23 module.add_function(wrap_pyfunction!(py_ermentrout_kopell_map_simulate, module)?)?;
24 Ok(())
25}
26
27#[pyfunction]
35#[pyo3(signature = (theta0, dt, gain, theta_threshold, n_steps, current))]
36fn py_ermentrout_kopell_map_simulate<'py>(
37 py: Python<'py>,
38 theta0: f64,
39 dt: f64,
40 gain: f64,
41 theta_threshold: f64,
42 n_steps: usize,
43 current: f64,
44) -> PyResult<(Bound<'py, PyArray1<f64>>, i64, f64)> {
45 let mut neuron = ErmentroutKopellMapNeuron {
46 theta: theta0,
47 dt,
48 gain,
49 theta_threshold,
50 };
51 let (trace, spikes) = neuron
52 .simulate(n_steps, current)
53 .map_err(PyFloatingPointError::new_err)?;
54 Ok((trace.into_pyarray(py), spikes, neuron.theta))
55}