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