sc_neurocore_engine/bindings/population/
larter_breakspear.rs1use pyo3::exceptions::PyValueError;
10use pyo3::prelude::*;
11use pyo3::types::PyDict;
12
13use crate::neurons;
14
15#[pyclass(
16 name = "LarterBreakspearNeuron",
17 module = "sc_neurocore_engine.sc_neurocore_engine"
18)]
19#[derive(Clone)]
20pub struct PyLarterBreakspearNeuron {
21 inner: neurons::LarterBreakspearNeuron,
22}
23
24#[pymethods]
25impl PyLarterBreakspearNeuron {
26 #[new]
27 fn new() -> Self {
28 Self {
29 inner: neurons::LarterBreakspearNeuron::new(),
30 }
31 }
32
33 #[pyo3(signature = (coupling=0.0))]
34 fn step(&mut self, coupling: f64) -> PyResult<f64> {
35 self.inner.try_step(coupling).map_err(PyValueError::new_err)
36 }
37
38 fn reset(&mut self) {
39 self.inner.reset();
40 }
41
42 fn get_state(&self, py: Python<'_>) -> PyResult<Py<PyAny>> {
43 let d = PyDict::new(py);
44 d.set_item("v", self.inner.v)?;
45 d.set_item("w", self.inner.w)?;
46 d.set_item("z", self.inner.z)?;
47 Ok(d.into_any().unbind())
48 }
49}
50
51pub(super) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
52 module.add_class::<PyLarterBreakspearNeuron>()?;
53 Ok(())
54}