Skip to content

Commit 06b2bf4

Browse files
committed
Refactor module assignments to 'brainpy.state' for consistency across files
1 parent 23f0e9f commit 06b2bf4

File tree

13 files changed

+60
-55
lines changed

13 files changed

+60
-55
lines changed

brainpy/state/__init__.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
from ._base import __all__ as base_all
1919
from ._exponential import *
2020
from ._exponential import __all__ as exp_all
21+
from ._hh import *
22+
from ._hh import __all__ as hh_all
2123
from ._inputs import *
2224
from ._inputs import __all__ as inputs_all
23-
from ._lif import *
24-
from ._lif import __all__ as neuron_all
2525
from ._izhikevich import *
2626
from ._izhikevich import __all__ as izh_all
27-
from ._hh import *
28-
from ._hh import __all__ as hh_all
27+
from ._lif import *
28+
from ._lif import __all__ as neuron_all
2929
from ._projection import *
3030
from ._projection import __all__ as proj_all
3131
from ._readout import *
@@ -38,13 +38,8 @@
3838
from ._synaptic_projection import __all__ as synproj_all
3939
from ._synouts import *
4040
from ._synouts import __all__ as synout_all
41-
from .. import mixin
4241

43-
__main__ = ['version2', 'mixin'] + inputs_all + neuron_all + izh_all + hh_all + readout_all + stp_all + synapse_all
42+
__main__ = inputs_all + neuron_all + izh_all + hh_all + readout_all + stp_all + synapse_all
4443
__main__ = __main__ + synout_all + base_all + exp_all + proj_all + synproj_all
4544
del inputs_all, neuron_all, izh_all, hh_all, readout_all, stp_all, synapse_all, synout_all, base_all
4645
del exp_all, proj_all, synproj_all
47-
48-
if __name__ == '__main__':
49-
mixin
50-

brainpy/state/_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def _input_label_repr(name: str, label: Optional[str] = None):
4040

4141

4242
class Dynamics(brainstate.nn.Dynamics):
43+
__module__ = 'brainpy.state'
44+
4345
def __init__(self, in_size: Size, name: Optional[str] = None):
4446
# initialize
4547
super().__init__(name=name, in_size=in_size)
@@ -595,7 +597,7 @@ class Neuron(Dynamics):
595597
.. [3] Gerstner, W., Kistler, W. M., Naud, R., & Paninski, L. (2014). Neuronal dynamics:
596598
From single neurons to networks and models of cognition. Cambridge University Press.
597599
"""
598-
__module__ = 'brainpy'
600+
__module__ = 'brainpy.state'
599601

600602
def __init__(
601603
self,
@@ -849,4 +851,4 @@ class Synapse(Dynamics):
849851
.. [3] Gerstner, W., Kistler, W. M., Naud, R., & Paninski, L. (2014). Neuronal dynamics:
850852
From single neurons to networks and models of cognition. Cambridge University Press.
851853
"""
852-
__module__ = 'brainpy'
854+
__module__ = 'brainpy.state'

brainpy/state/_exponential.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Expon(Synapse, AlignPost):
7171
where synaptic variables are aligned with post-synaptic neurons, enabling event-driven
7272
computation and more efficient handling of sparse connectivity patterns.
7373
"""
74-
__module__ = 'brainpy'
74+
__module__ = 'brainpy.state'
7575

7676
def __init__(
7777
self,
@@ -156,7 +156,7 @@ class DualExpon(Synapse, AlignPost):
156156
where synaptic variables are aligned with post-synaptic neurons, enabling event-driven
157157
computation and more efficient handling of sparse connectivity patterns.
158158
"""
159-
__module__ = 'brainpy'
159+
__module__ = 'brainpy.state'
160160

161161
def __init__(
162162
self,

brainpy/state/_hh.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class HH(Neuron):
148148
.. [2] https://en.wikipedia.org/wiki/Hodgkin%E2%80%93Huxley_model
149149
"""
150150

151-
__module__ = 'brainpy'
151+
__module__ = 'brainpy.state'
152152

153153
def __init__(
154154
self,
@@ -380,7 +380,7 @@ class MorrisLecar(Neuron):
380380
.. [3] https://en.wikipedia.org/wiki/Morris%E2%80%93Lecar_model
381381
"""
382382

383-
__module__ = 'brainpy'
383+
__module__ = 'brainpy.state'
384384

385385
def __init__(
386386
self,
@@ -572,7 +572,7 @@ class WangBuzsakiHH(Neuron):
572572
neuroscience, 16(20), pp.6402-6413.
573573
"""
574574

575-
__module__ = 'brainpy'
575+
__module__ = 'brainpy.state'
576576

577577
def __init__(
578578
self,

brainpy/state/_inputs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class SpikeTime(brainstate.nn.Dynamics):
6060
name : str, optional
6161
The name of the dynamic system.
6262
"""
63-
__module__ = 'brainpy'
63+
__module__ = 'brainpy.state'
6464

6565
def __init__(
6666
self,
@@ -116,7 +116,7 @@ class PoissonSpike(brainstate.nn.Dynamics):
116116
"""
117117
Poisson Neuron Group.
118118
"""
119-
__module__ = 'brainpy'
119+
__module__ = 'brainpy.state'
120120

121121
def __init__(
122122
self,
@@ -203,7 +203,7 @@ class PoissonEncoder(brainstate.nn.Dynamics):
203203
- The independence of spike generation between time steps results in renewal process
204204
statistics without memory of previous spiking history.
205205
"""
206-
__module__ = 'brainpy'
206+
__module__ = 'brainpy.state'
207207

208208
def __init__(
209209
self,
@@ -316,7 +316,7 @@ class PoissonInput(brainstate.nn.Module):
316316
- The update method internally calls the poisson_input function which handles the
317317
spike generation and target state updates.
318318
"""
319-
__module__ = 'brainpy'
319+
__module__ = 'brainpy.state'
320320

321321
def __init__(
322322
self,
@@ -348,7 +348,7 @@ def update(self):
348348
)
349349

350350

351-
@set_module_as('brainpy')
351+
@set_module_as('brainpy.state')
352352
def poisson_input(
353353
freq: u.Quantity[u.Hz],
354354
num_input: int,

brainpy/state/_izhikevich.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Izhikevich(Neuron):
119119
IEEE transactions on neural networks, 15(5), 1063-1070.
120120
"""
121121

122-
__module__ = 'brainpy'
122+
__module__ = 'brainpy.state'
123123

124124
def __init__(
125125
self,
@@ -302,7 +302,7 @@ class IzhikevichRef(Neuron):
302302
IEEE transactions on neural networks, 15(5), 1063-1070.
303303
"""
304304

305-
__module__ = 'brainpy'
305+
__module__ = 'brainpy.state'
306306

307307
def __init__(
308308
self,

brainpy/state/_lif.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class IF(Neuron):
113113
I. Homogeneous synaptic input. Biological cybernetics, 95(1), 1-19.
114114
"""
115115

116-
__module__ = 'brainpy'
116+
__module__ = 'brainpy.state'
117117

118118
def __init__(
119119
self,
@@ -237,7 +237,7 @@ class LIF(Neuron):
237237
.. [2] Burkitt, A. N. (2006). A review of the integrate-and-fire neuron model:
238238
I. Homogeneous synaptic input. Biological cybernetics, 95(1), 1-19.
239239
"""
240-
__module__ = 'brainpy'
240+
__module__ = 'brainpy.state'
241241

242242
def __init__(
243243
self,
@@ -380,7 +380,7 @@ class ExpIF(Neuron):
380380
conductance-based synaptic drive." Physical Review E 76, no. 2 (2007): 021919.
381381
.. [5] https://en.wikipedia.org/wiki/Exponential_integrate-and-fire
382382
"""
383-
__module__ = 'brainpy'
383+
__module__ = 'brainpy.state'
384384

385385
def __init__(
386386
self,
@@ -506,7 +506,7 @@ class ExpIFRef(Neuron):
506506
>>> with brainstate.environ.context(t=t*0.1*u.ms):
507507
>>> spikes = expif.update(x=inputs[t])
508508
"""
509-
__module__ = 'brainpy'
509+
__module__ = 'brainpy.state'
510510

511511
def __init__(
512512
self,
@@ -680,7 +680,7 @@ class AdExIF(Neuron):
680680
681681
:class:`brainpy.dyn.AdExIF` for the dynamical-system counterpart.
682682
"""
683-
__module__ = 'brainpy'
683+
__module__ = 'brainpy.state'
684684

685685
def __init__(
686686
self,
@@ -863,7 +863,7 @@ class AdExIFRef(Neuron):
863863
864864
:class:`brainpy.dyn.AdExIFRef` for the dynamical-system counterpart.
865865
"""
866-
__module__ = 'brainpy'
866+
__module__ = 'brainpy.state'
867867

868868
def __init__(
869869
self,
@@ -1072,7 +1072,7 @@ class LIFRef(Neuron):
10721072
.. [3] Izhikevich, E. M. (2003). Simple model of spiking neurons. IEEE Transactions on
10731073
neural networks, 14(6), 1569-1572.
10741074
"""
1075-
__module__ = 'brainpy'
1075+
__module__ = 'brainpy.state'
10761076

10771077
def __init__(
10781078
self,
@@ -1244,7 +1244,7 @@ class ALIF(Neuron):
12441244
the adaptive exponential integrate-and-fire model. Biological cybernetics,
12451245
99(4), 335-347.
12461246
"""
1247-
__module__ = 'brainpy'
1247+
__module__ = 'brainpy.state'
12481248

12491249
def __init__(
12501250
self,
@@ -1390,7 +1390,7 @@ class QuaIF(Neuron):
13901390
(2000) Intrinsic dynamics in neuronal networks. I. Theory.
13911391
J. Neurophysiology 83, pp. 808–827.
13921392
"""
1393-
__module__ = 'brainpy'
1393+
__module__ = 'brainpy.state'
13941394

13951395
def __init__(
13961396
self,
@@ -1545,7 +1545,7 @@ class AdQuaIF(Neuron):
15451545
nonlinear integrate-and-fire neurons." SIAM Journal on Applied
15461546
Mathematics 68, no. 4 (2008): 1045-1079.
15471547
"""
1548-
__module__ = 'brainpy'
1548+
__module__ = 'brainpy.state'
15491549

15501550
def __init__(
15511551
self,
@@ -1706,7 +1706,7 @@ class AdQuaIFRef(Neuron):
17061706
- Refractory period prevents unrealistically high firing rates.
17071707
- More biologically realistic than AdQuaIF without refractory period.
17081708
"""
1709-
__module__ = 'brainpy'
1709+
__module__ = 'brainpy.state'
17101710

17111711
def __init__(
17121712
self,
@@ -1939,7 +1939,7 @@ class Gif(Neuron):
19391939
leaky integrate-and-fire models classify multiple neuron types."
19401940
Nature communications 9, no. 1 (2018): 1-15.
19411941
"""
1942-
__module__ = 'brainpy'
1942+
__module__ = 'brainpy.state'
19431943

19441944
def __init__(
19451945
self,
@@ -2151,7 +2151,7 @@ class GifRef(Neuron):
21512151
- Can still exhibit diverse firing patterns: regular, bursting, adaptation.
21522152
- Refractory period prevents unrealistically high firing rates.
21532153
"""
2154-
__module__ = 'brainpy'
2154+
__module__ = 'brainpy.state'
21552155

21562156
def __init__(
21572157
self,

brainpy/state/_projection.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Projection(brainstate.nn.Module):
7171
Derived classes should implement specific projection behaviors, such as
7272
dense connectivity, sparse connectivity, or specific weight update rules.
7373
"""
74-
__module__ = 'brainstate.nn'
74+
__module__ = 'brainpy.state'
7575

7676
def update(self, *args, **kwargs):
7777
sub_nodes = tuple(self.nodes(allowed_hierarchy=(1, 1)).values())
@@ -181,7 +181,7 @@ class AlignPostProj(Projection):
181181
>>> exe_current = E(pop.get_spike())
182182
183183
"""
184-
__module__ = 'brainstate.nn'
184+
__module__ = 'brainpy.state'
185185

186186
def __init__(
187187
self,
@@ -303,7 +303,7 @@ class DeltaProj(Projection):
303303
... )
304304
>>> delta_input(1.0) # Apply voltage increment directly
305305
"""
306-
__module__ = 'brainstate.nn'
306+
__module__ = 'brainpy.state'
307307

308308
def __init__(
309309
self,
@@ -380,7 +380,7 @@ class CurrentProj(Projection):
380380
... )
381381
>>> current_input(0.2) # Apply external current
382382
"""
383-
__module__ = 'brainstate.nn'
383+
__module__ = 'brainpy.state'
384384

385385
def __init__(
386386
self,
@@ -439,6 +439,7 @@ class align_pre_projection(Projection):
439439
short-term plasticity.
440440
441441
"""
442+
__module__ = 'brainpy.state'
442443

443444
def __init__(
444445
self,
@@ -486,6 +487,7 @@ class align_post_projection(Projection):
486487
properties, synaptic outputs, post-synaptic dynamics, and short-term plasticity.
487488
488489
"""
490+
__module__ = 'brainpy.state'
489491

490492
def __init__(
491493
self,

brainpy/state/_readout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class LeakyRateReadout(brainstate.nn.Module):
7474
r : HiddenState
7575
Hidden state representing the output values
7676
"""
77-
__module__ = 'brainpy'
77+
__module__ = 'brainpy.state'
7878

7979
def __init__(
8080
self,
@@ -160,7 +160,7 @@ class LeakySpikeReadout(Neuron):
160160
Synaptic weight matrix
161161
"""
162162

163-
__module__ = 'brainpy'
163+
__module__ = 'brainpy.state'
164164

165165
def __init__(
166166
self,

brainpy/state/_stp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class STP(Synapse):
9797
.. [2] Tsodyks, M., Pawelzik, K., & Markram, H. (1998). Neural networks with dynamic
9898
synapses. Neural computation, 10(4), 821-835.
9999
"""
100-
__module__ = 'brainpy'
100+
__module__ = 'brainpy.state'
101101

102102
def __init__(
103103
self,
@@ -203,7 +203,7 @@ class STD(Synapse):
203203
pyramidal neurons depends on neurotransmitter release probability.
204204
Proceedings of the National Academy of Sciences, 94(2), 719-723.
205205
"""
206-
__module__ = 'brainpy'
206+
__module__ = 'brainpy.state'
207207

208208
def __init__(
209209
self,

0 commit comments

Comments
 (0)