Skip to content

Commit 0dcec94

Browse files
committed
fix(docs): update documentation links and add new guides for BrainPy 3.0
1 parent 12f57d4 commit 0dcec94

39 files changed

+16789
-147
lines changed

.github/workflows/stale.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,5 @@ cython_debug/
236236
/docs_version3/_build/
237237
/docs_version3/_static/logos/
238238
/docs_version3/changelog.md
239+
/examples_version2/dynamics_training/data/
240+
/docs/

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img alt="Header image of BrainPy - brain dynamics programming in Python." src="https://raw.githubusercontent.com/brainpy/BrainPy/master/images/logo.png" width=80%>
2+
<img alt="Header image of BrainPy - brain dynamics programming in Python." src="https://raw.githubusercontent.com/brainpy/BrainPy/master/images/logo-banner.png" width=80%>
33
</p>
44

55

@@ -16,8 +16,9 @@
1616

1717
BrainPy is a flexible, efficient, and extensible framework for computational neuroscience and brain-inspired computation based on the Just-In-Time (JIT) compilation. It provides an integrative ecosystem for brain dynamics programming, including brain dynamics **building**, **simulation**, **training**, **analysis**, etc.
1818

19-
- **Website (documentation and APIs)**: https://brainpy.readthedocs.io/
2019
- **Source**: https://github.com/brainpy/BrainPy
20+
- **Documentation**: https://brainpy.readthedocs.io/
21+
- **Documentation**: https://brainpy-v2.readthedocs.io/
2122
- **Bug reports**: https://github.com/brainpy/BrainPy/issues
2223
- **Ecosystem**: https://brainmodeling.readthedocs.io/
2324

docs/conf.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
import shutil
1616
import sys
1717

18-
# 要保留的文件/文件夹列表
1918
keep_files = {'highlight_test_lexer.py', 'conf.py', 'make.bat', 'Makefile'}
20-
21-
# 遍历当前目录
2219
for item in os.listdir('.'):
2320
if item not in keep_files:
2421
path = os.path.join('.', item)
@@ -34,21 +31,19 @@
3431
if build_version == 'v2':
3532
shutil.copytree(
3633
os.path.join(os.path.dirname(__file__), '../docs_version2'),
37-
os.path.join(os.path.dirname(__file__), ),
34+
os.path.join(os.path.dirname(__file__)),
3835
dirs_exist_ok=True
3936
)
4037
else:
4138
shutil.copytree(
4239
os.path.join(os.path.dirname(__file__), '../docs_version3'),
43-
os.path.join(os.path.dirname(__file__), ),
40+
os.path.join(os.path.dirname(__file__)),
4441
dirs_exist_ok=True
4542
)
4643

4744
sys.path.insert(0, os.path.abspath('./'))
4845
sys.path.insert(0, os.path.abspath('../'))
4946

50-
import brainpy
51-
5247
shutil.copytree('../images/', './_static/logos/', dirs_exist_ok=True)
5348
shutil.copyfile('../changelog.md', './changelog.md')
5449

@@ -62,7 +57,8 @@
6257

6358
fix_ipython2_lexer_in_notebooks(os.path.dirname(os.path.abspath(__file__)))
6459

65-
# The full version, including alpha/beta/rc tags
60+
import brainpy
61+
6662
release = brainpy.__version__
6763

6864
# -- General configuration ---------------------------------------------------

docs_version2/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Learn more
127127

128128
.. card:: :material-regular:`settings;2em` Examples
129129
:class-card: sd-text-black sd-bg-light
130-
:link: https://brainpy-examples.readthedocs.io/
130+
:link: https://brainpy-v2.readthedocs.io/projects/examples/
131131

132132
.. grid-item::
133133
:columns: 6 6 6 4

docs_version3/api/index.rst

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
API Reference
2+
=============
3+
4+
Complete API reference for BrainPy 3.0.
5+
6+
.. note::
7+
BrainPy 3.0 is built on top of `brainstate <https://brainstate.readthedocs.io/>`_,
8+
`brainunit <https://brainunit.readthedocs.io/>`_, and `braintools <https://braintools.readthedocs.io/>`_.
9+
10+
Organization
11+
------------
12+
13+
The API is organized into the following categories:
14+
15+
.. grid:: 1 2 2 2
16+
17+
.. grid-item-card:: :material-regular:`psychology;2em` Neurons
18+
:link: neurons.html
19+
20+
Spiking neuron models (LIF, ALIF, Izhikevich, etc.)
21+
22+
.. grid-item-card:: :material-regular:`timeline;2em` Synapses
23+
:link: synapses.html
24+
25+
Synaptic dynamics (Expon, Alpha, AMPA, GABA, NMDA)
26+
27+
.. grid-item-card:: :material-regular:`account_tree;2em` Projections
28+
:link: projections.html
29+
30+
Connect neural populations (AlignPostProj, AlignPreProj)
31+
32+
.. grid-item-card:: :material-regular:`hub;2em` Networks
33+
:link: networks.html
34+
35+
Network building blocks and utilities
36+
37+
.. grid-item-card:: :material-regular:`school;2em` Training
38+
:link: training.html
39+
40+
Gradient-based learning utilities
41+
42+
.. grid-item-card:: :material-regular:`input;2em` Input/Output
43+
:link: input-output.html
44+
45+
Input generation and output processing
46+
47+
Quick Reference
48+
---------------
49+
50+
**Most commonly used classes:**
51+
52+
Neurons
53+
~~~~~~~
54+
55+
.. code-block:: python
56+
57+
import brainpy as bp
58+
59+
# Leaky Integrate-and-Fire
60+
bp.LIF(size, V_rest, V_th, V_reset, tau, R, ...)
61+
62+
# Adaptive LIF
63+
bp.ALIF(size, V_rest, V_th, V_reset, tau, tau_w, a, b, ...)
64+
65+
# Izhikevich
66+
bp.Izhikevich(size, a, b, c, d, ...)
67+
68+
Synapses
69+
~~~~~~~~
70+
71+
.. code-block:: python
72+
73+
# Exponential
74+
bp.Expon.desc(size, tau)
75+
76+
# Alpha
77+
bp.Alpha.desc(size, tau)
78+
79+
# AMPA receptor
80+
bp.AMPA.desc(size, tau)
81+
82+
# GABA_a receptor
83+
bp.GABAa.desc(size, tau)
84+
85+
Projections
86+
~~~~~~~~~~~
87+
88+
.. code-block:: python
89+
90+
# Standard projection
91+
bp.AlignPostProj(
92+
comm=brainstate.nn.EventFixedProb(n_pre, n_post, prob, weight),
93+
syn=bp.Expon.desc(n_post, tau),
94+
out=bp.COBA.desc(E),
95+
post=post_neurons
96+
)
97+
98+
Networks
99+
~~~~~~~~
100+
101+
.. code-block:: python
102+
103+
# Module base class
104+
class MyNetwork(brainstate.nn.Module):
105+
def __init__(self):
106+
super().__init__()
107+
# ... define components
108+
109+
def update(self, x):
110+
# ... network dynamics
111+
return output
112+
113+
Training
114+
~~~~~~~~
115+
116+
.. code-block:: python
117+
118+
import braintools
119+
120+
# Optimizer
121+
optimizer = braintools.optim.Adam(lr=1e-3)
122+
123+
# Gradients
124+
grads = brainstate.transform.grad(loss_fn, params)(...)
125+
126+
# Update
127+
optimizer.update(grads)
128+
129+
Documentation Sections
130+
----------------------
131+
132+
.. toctree::
133+
:maxdepth: 2
134+
135+
neurons
136+
synapses
137+
projections
138+
networks
139+
training
140+
input-output
141+
142+
Import Structure
143+
----------------
144+
145+
BrainPy uses a clear import hierarchy:
146+
147+
.. code-block:: python
148+
149+
import brainpy as bp # Core BrainPy
150+
import brainstate # State management and modules
151+
import brainunit as u # Physical units
152+
import braintools # Training utilities
153+
154+
# Neurons and synapses
155+
neuron = bp.LIF(100, ...)
156+
synapse = bp.Expon.desc(100, tau=5*u.ms)
157+
158+
# State management
159+
state = brainstate.ShortTermState(...)
160+
brainstate.nn.init_all_states(net)
161+
162+
# Units
163+
current = 2.0 * u.nA
164+
voltage = -65 * u.mV
165+
time = 10 * u.ms
166+
167+
# Training
168+
optimizer = braintools.optim.Adam(lr=1e-3)
169+
loss = braintools.metric.softmax_cross_entropy(...)
170+
171+
Type Conventions
172+
----------------
173+
174+
**States:**
175+
176+
- ``ShortTermState`` - Temporary dynamics (V, g, spikes)
177+
- ``ParamState`` - Learnable parameters (weights, biases)
178+
- ``LongTermState`` - Persistent statistics
179+
180+
**Units:**
181+
182+
All physical quantities use ``brainunit``:
183+
184+
- Voltage: ``u.mV``
185+
- Current: ``u.nA``, ``u.pA``
186+
- Time: ``u.ms``, ``u.second``
187+
- Conductance: ``u.mS``, ``u.nS``
188+
- Concentration: ``u.mM``
189+
190+
**Shapes:**
191+
192+
- Single trial: ``(n_neurons,)``
193+
- Batched: ``(batch_size, n_neurons)``
194+
- Connectivity: ``(n_pre, n_post)``
195+
196+
See Also
197+
--------
198+
199+
**External Documentation:**
200+
201+
- `BrainState Documentation <https://brainstate.readthedocs.io/>`_ - State management
202+
- `BrainUnit Documentation <https://brainunit.readthedocs.io/>`_ - Physical units
203+
- `BrainTools Documentation <https://braintools.readthedocs.io/>`_ - Training utilities
204+
- `JAX Documentation <https://jax.readthedocs.io/>`_ - Underlying computation

0 commit comments

Comments
 (0)