Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dyn] add reduce models, HH-type models and channels #408

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion brainpy/_src/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
25 changes: 0 additions & 25 deletions brainpy/_src/channels/__init__.py

This file was deleted.

7 changes: 7 additions & 0 deletions brainpy/_src/dyn/_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
has_ref_var: bool. Whether has the refractory variable. Default is ``False``.
'''.strip()

if_doc = '''
V_rest: float, ArrayType, callable. Resting membrane potential.
R: float, ArrayType, callable. Membrane resistance.
tau: float, ArrayType, callable. Membrane time constant.
V_initializer: ArrayType, callable. The initializer of membrane potential.
'''.strip()

lif_doc = '''
V_rest: float, ArrayType, callable. Resting membrane potential.
V_reset: float, ArrayType, callable. Reset potential after spike.
Expand Down
10 changes: 7 additions & 3 deletions brainpy/_src/dyn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
keep_size: bool = False,
mode: bm.Mode = None,
name: str = None,
method: str = 'exp_auto'
):
super().__init__(size=size,
mode=mode,
Expand All @@ -37,6 +38,9 @@ def __init__(
# axis names for parallelization
self.sharding = sharding

# integration method
self.method = method

# the before- / after-updates used for computing
self.before_updates: Dict[str, Callable] = bm.node_dict()
self.after_updates: Dict[str, Callable] = bm.node_dict()
Expand Down Expand Up @@ -109,21 +113,21 @@ def __init__(
keep_size: bool = False,
mode: Optional[bm.Mode] = None,
name: Optional[str] = None,
method: str = 'exp_auto',

spk_fun: Callable = bm.surrogate.InvSquareGrad(),
spk_type: Any = None,
detach_spk: bool = False,
method: str = 'exp_auto',
):
super().__init__(size=size,
mode=mode,
keep_size=keep_size,
name=name,
sharding=sharding)
sharding=sharding,
method=method)

self.spk_fun = is_callable(spk_fun)
self.detach_spk = detach_spk
self.method = method
self._spk_type = spk_type

@property
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions brainpy/_src/dyn/channels/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-

"""

Access through ``brainpy.channels``.
"""

from . import base, Ca, IH, K, Na, KCa, leaky

__all__ = []
__all__ += base.__all__
__all__ += K.__all__
__all__ += Na.__all__
__all__ += Ca.__all__
__all__ += IH.__all__
__all__ += KCa.__all__
__all__ += leaky.__all__

from .base import *
from .K import *
from .Na import *
from .IH import *
from .Ca import *
from .KCa import *
from .leaky import *
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import brainpy as bp
import brainpy.math as bm
from absl.testing import parameterized
from brainpy._src.channels import Ca
from brainpy._src.dyn.channels import Ca

class Test_Ca(parameterized.TestCase):
def test_Ca(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import brainpy as bp
import brainpy.math as bm
from absl.testing import parameterized
from brainpy._src.channels import IH, Ca
from brainpy._src.dyn.channels import IH, Ca


class Test_IH(parameterized.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import brainpy as bp
import brainpy.math as bm
from absl.testing import parameterized
from brainpy._src.channels import K
from brainpy._src.dyn.channels import K

class Test_K(parameterized.TestCase):
bm.random.seed(1234)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import brainpy as bp
import brainpy.math as bm
from absl.testing import parameterized
from brainpy._src.channels import KCa, Ca
from brainpy._src.dyn.channels import KCa, Ca

class Test_KCa(parameterized.TestCase):
bm.random.seed(1234)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import brainpy as bp
import brainpy.math as bm
from absl.testing import parameterized
from brainpy._src.channels import Na
from brainpy._src.dyn.channels import Na


class Test_Na(parameterized.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import brainpy as bp
import brainpy.math as bm
from absl.testing import parameterized
from brainpy._src.channels import leaky
from brainpy._src.dyn.channels import leaky

class Test_Leaky(parameterized.TestCase):
bm.random.seed(1234)
Expand Down
Loading