Skip to content

Commit

Permalink
support exponential euler integration (#25)
Browse files Browse the repository at this point in the history
* fix

* support `exponential euler` integration

* update
  • Loading branch information
chaoming0625 authored Jan 21, 2025
1 parent daf5c2f commit 2eeea49
Show file tree
Hide file tree
Showing 18 changed files with 461 additions and 210 deletions.
15 changes: 12 additions & 3 deletions dendritex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@
from ._base import __all__ as _base_all
from ._integrators import *
from ._integrators import __all__ as _integrators_all
from ._protocol import *
from ._protocol import __all__ as _protocol_all

__all__ = (
['neurons', 'ions', 'channels'] +
_base_all +
_integrators_all
['neurons', 'ions', 'channels']
+ _base_all
+ _integrators_all
+ _protocol_all
)

del (
_base_all,
_integrators_all,
_protocol_all,
)
19 changes: 10 additions & 9 deletions dendritex/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import numpy as np
from brainstate.mixin import _JointGenericAlias

from ._integrators import DiffEqModule
from ._protocol import DiffEqModule
from ._misc import set_module_as, Container, TreeNode

__all__ = [
Expand Down Expand Up @@ -101,7 +101,7 @@ def post_integral(self, *args, **kwargs):
"""
For the neuron model, the `post_integral()` is the `update()` function.
"""
return self.update(*args, **kwargs)
pass

def init_state(self, batch_size=None):
nodes = self.nodes(IonChannel, allowed_hierarchy=(1, 1)).values()
Expand Down Expand Up @@ -193,6 +193,13 @@ def init_state(self, *args, **kwargs):


class IonInfo(NamedTuple):
"""
The information of the ion.
Attributes:
E: The reversal potential.
C: The ion concentration.
"""
C: bst.typing.ArrayLike
E: bst.typing.ArrayLike

Expand All @@ -211,12 +218,6 @@ class Ion(IonChannel, Container):
# The type of the master object.
root_type = HHTypedNeuron

# Reversal potential.
E: bst.typing.ArrayLike | bst.State

# Ion concentration.
C: bst.typing.ArrayLike | bst.State

def __init__(
self,
size: bst.typing.Size,
Expand Down Expand Up @@ -290,7 +291,7 @@ def register_external_current(self, key: str, fun: Callable):
raise ValueError
self._external_currents[key] = fun

def pack_info(self):
def pack_info(self) -> IonInfo:
E = self.E
E = E.value if isinstance(E, bst.State) else E
C = self.C.value if isinstance(self.C, bst.State) else self.C
Expand Down
Loading

0 comments on commit 2eeea49

Please sign in to comment.