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