Skip to content

Commit fd1e4b6

Browse files
committed
refactor(docs): clean up import statements and improve code formatting
1 parent 11c3dc4 commit fd1e4b6

11 files changed

+141
-61
lines changed

brainpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __dir__():
8282
_deprecated_modules = [
8383
'math', 'check', 'tools', 'connect', 'initialize', 'init', 'conn',
8484
'optim', 'losses', 'measure', 'inputs', 'encoding', 'checkpoints',
85-
'mixin', 'algorithms', 'integrators', 'ode', 'sde', 'fde',
85+
'algorithms', 'integrators', 'ode', 'sde', 'fde',
8686
'dnn', 'layers', 'dyn', 'running', 'train', 'analysis',
8787
'channels', 'neurons', 'rates', 'synapses', 'synouts', 'synplast',
8888
'visualization', 'visualize', 'types', 'modes', 'context',

brainpy/_stp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def __init__(
209209
self,
210210
in_size: Size,
211211
name: Optional[str] = None,
212-
# synapse parameters
213212
tau: ArrayLike = 200. * u.ms,
214213
U: ArrayLike = 0.07,
215214
):
@@ -220,7 +219,9 @@ def __init__(
220219
self.U = braintools.init.param(U, self.varshape)
221220

222221
def init_state(self, batch_size: int = None, **kwargs):
223-
self.x = brainstate.HiddenState(braintools.init.param(braintools.init.Constant(1.), self.varshape, batch_size))
222+
self.x = brainstate.HiddenState(
223+
braintools.init.param(braintools.init.Constant(1.), self.varshape, batch_size)
224+
)
224225

225226
def reset_state(self, batch_size: int = None, **kwargs):
226227
self.x.value = braintools.init.param(braintools.init.Constant(1.), self.varshape, batch_size)

docs/apis.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
API Reference
2+
=============
3+
4+
This page provides a comprehensive reference for all BrainPy APIs.
5+
6+
.. currentmodule:: brainpy
7+
.. automodule:: brainpy
8+
9+
10+
11+
Neuron Models
12+
-------------
13+
14+
.. autosummary::
15+
:toctree: generated/
16+
:nosignatures:
17+
18+
Neuron
19+
LIF
20+
LIFRef
21+
ALIF
22+
Izhikevich
23+
IF
24+
ExpIF
25+
AdExIF
26+
27+
28+
Synapse Models
29+
--------------
30+
31+
.. autosummary::
32+
:toctree: generated/
33+
:nosignatures:
34+
35+
Synapse
36+
Delta
37+
Exponential
38+
DualExponential
39+
Alpha
40+
NMDA
41+
AMPA
42+
GABAa
43+
44+
45+
Short-Term Plasticity
46+
---------------------
47+
48+
.. autosummary::
49+
:toctree: generated/
50+
:nosignatures:
51+
52+
STP
53+
STD
54+
STF
55+
56+
57+
Synaptic Output
58+
---------------
59+
60+
.. autosummary::
61+
:toctree: generated/
62+
:nosignatures:
63+
64+
CUBA
65+
COBA
66+
MgBlock
67+
68+
69+
Projection
70+
----------
71+
72+
.. autosummary::
73+
:toctree: generated/
74+
:nosignatures:
75+
76+
Projection
77+
FullProjDelta
78+
FullProjAlignPostDelta
79+
80+
81+
Readout
82+
-------
83+
84+
.. autosummary::
85+
:toctree: generated/
86+
:nosignatures:
87+
88+
Readout
89+
Dense
90+
Linear
91+
92+
93+
Input Generators
94+
----------------
95+
96+
.. autosummary::
97+
:toctree: generated/
98+
:nosignatures:
99+
100+
spike_input
101+
latency_input
102+

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717

1818
sys.path.insert(0, os.path.abspath('./'))
1919
sys.path.insert(0, os.path.abspath('../'))
20+
sys.path.insert(0, r'D:\codes\projects\brainstate')
2021

2122
import brainpy
22-
2323
shutil.copytree('../images/', './_static/logos/', dirs_exist_ok=True)
24+
shutil.copyfile('../changelog.md', './changelog.md')
2425

2526
# -- Project information -----------------------------------------------------
2627

docs/index.rst

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,10 @@
11
``brainpy`` documentation
22
=========================
33

4-
`brainpy <https://github.com/brainpy/BrainPy>`_
4+
`brainpy <https://github.com/brainpy/BrainPy>`_ provides a powerful and flexible framework
5+
for building, simulating, and training spiking neural networks.
56

67

7-
----
8-
9-
Features
10-
^^^^^^^^^
11-
12-
.. grid::
13-
14-
15-
16-
.. grid-item::
17-
:columns: 12 12 12 6
18-
19-
.. card:: Program Compilation
20-
:class-card: sd-border-0
21-
:shadow: none
22-
:class-title: sd-fs-6
23-
24-
.. div:: sd-font-normal
25-
26-
``BrainState`` supports `program compilation <./apis/compile.html>`__ (such as just-in-time compilation) with its `state-based <./apis/brainstate.html>`__ IR construction.
27-
28-
29-
30-
.. grid-item::
31-
:columns: 12 12 12 6
32-
33-
.. card:: Program Augmentation
34-
:class-card: sd-border-0
35-
:shadow: none
36-
:class-title: sd-fs-6
37-
38-
.. div:: sd-font-normal
39-
40-
``BrainState`` supports program `functionality augmentation <./apis/augment.html>`__ (such batching) with its `graph-based <./apis/graph.html>`__ Python objects.
41-
42-
43-
44-
45-
----
46-
478

489
Installation
4910
^^^^^^^^^^^^
@@ -79,6 +40,8 @@ See also the ecosystem
7940
``brainpy`` is one part of our `brain simulation ecosystem <https://brainmodeling.readthedocs.io/>`_.
8041

8142

43+
44+
8245
.. toctree::
8346
:hidden:
8447
:maxdepth: 1
@@ -97,14 +60,5 @@ See also the ecosystem
9760
:caption: API Reference
9861

9962
changelog.md
100-
apis/brainstate.rst
101-
apis/graph.rst
102-
apis/transform.rst
103-
apis/nn.rst
104-
apis/random.rst
105-
apis/util.rst
106-
apis/surrogate.rst
107-
apis/typing.rst
108-
apis/mixin.rst
109-
apis/environ.rst
63+
apis.rst
11064

docs_version2/index.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@ general-purpose Brain Dynamics Programming (BDP).
1010

1111

1212

13+
.. note::
14+
15+
From September 2025, BrainPy has been upgraded to version 3.x.
16+
To compatible apis within version 2.x. Please change your code:
17+
18+
.. code-block:: python
19+
20+
# Old version (v2.x)
21+
import brainpy as bp
22+
import brainpy.math as bm
23+
24+
to the new version:
25+
26+
27+
.. code-block:: python
28+
29+
# New version (v3.x)
30+
import brainpy.version2 as bp
31+
import brainpy.version2.math as bm
32+
33+
1334
1435
----
1536

examples/110_Susin_Destexhe_2021_gamma_oscillation_AI.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
# Asynchronous Network
2424

2525

26+
import braintools
2627
import brainunit as u
2728
import matplotlib.pyplot as plt
2829

2930
import brainpy
3031
import brainstate
31-
import braintools
3232
from Susin_Destexhe_2021_gamma_oscillation import (
3333
get_inputs, visualize_simulation_results,
3434
RS_par, FS_par, Ch_par, AdEx
@@ -164,7 +164,8 @@ def simulate_ai_net():
164164
# simulation
165165
times = u.math.arange(0. * u.ms, duration, brainstate.environ.get_dt())
166166
indices = u.math.arange(0, len(times))
167-
returns = brainstate.transform.for_loop(net.update, indices, times, varied_rates, pbar=brainstate.transform.ProgressBar(100))
167+
returns = brainstate.transform.for_loop(net.update, indices, times, varied_rates,
168+
pbar=brainstate.transform.ProgressBar(100))
168169

169170
# # spike raster plot
170171
# spikes = returns['FS.spike']

examples/111_Susin_Destexhe_2021_gamma_oscillation_CHING.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def simulate_ching_net():
182182
times = u.math.arange(0. * u.ms, duration, brainstate.environ.get_dt())
183183
indices = u.math.arange(0, len(times))
184184
returns = brainstate.transform.for_loop(net.update, indices, times, varied_rates,
185-
pbar=brainstate.transform.ProgressBar(100))
185+
pbar=brainstate.transform.ProgressBar(100))
186186

187187
# visualization
188188
visualize_simulation_results(

examples/112_Susin_Destexhe_2021_gamma_oscillation_ING.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def simulate_ing_net():
179179
times = u.math.arange(0. * u.ms, duration, brainstate.environ.get_dt())
180180
indices = u.math.arange(0, len(times))
181181
returns = brainstate.transform.for_loop(net.update, indices, times, varied_rates,
182-
pbar=brainstate.transform.ProgressBar(100))
182+
pbar=brainstate.transform.ProgressBar(100))
183183

184184
# visualization
185185
visualize_simulation_results(

examples/113_Susin_Destexhe_2021_gamma_oscillation_PING.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def simulate_ping_net():
128128
times = u.math.arange(0. * u.ms, duration, brainstate.environ.get_dt())
129129
indices = u.math.arange(0, len(times))
130130
returns = brainstate.transform.for_loop(net.update, indices, times, varied_rates,
131-
pbar=brainstate.transform.ProgressBar(100))
131+
pbar=brainstate.transform.ProgressBar(100))
132132

133133
# visualization
134134
visualize_simulation_results(

0 commit comments

Comments
 (0)