Skip to content

Commit 62448bf

Browse files
authored
[update] Refine installation instructions and improve docstring formatting (#767)
* [update] Refine installation instructions and improve docstring formatting * [update] Add note about BrainPy's rewrite based on brainstate * [update] Remove redundant installation information from index
1 parent ee942e9 commit 62448bf

6 files changed

Lines changed: 63 additions & 68 deletions

File tree

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,28 @@
66

77
<p align="center">
88
<a href="https://pypi.org/project/brainpy/"><img alt="Supported Python Version" src="https://img.shields.io/pypi/pyversions/brainpy"></a>
9-
<a href="https://github.com/brainpy/BrainPy"><img alt="LICENSE" src="https://anaconda.org/brainpy/brainpy/badges/license.svg"></a>
9+
<a href="https://github.com/brainpy/BrainPy"><img alt="LICENSE" src="https://img.shields.io/badge/license-%20%20GNU%20GPLv3%20-green?style=plastic"></a>
1010
<a href="https://brainpy.readthedocs.io/en/latest/?badge=latest"><img alt="Documentation" src="https://readthedocs.org/projects/brainpy/badge/?version=latest"></a>
1111
<a href="https://badge.fury.io/py/brainpy"><img alt="PyPI version" src="https://badge.fury.io/py/brainpy.svg"></a>
1212
<a href="https://github.com/brainpy/BrainPy/actions/workflows/CI.yml"><img alt="Continuous Integration" src="https://github.com/brainpy/BrainPy/actions/workflows/CI.yml/badge.svg"></a>
1313
<a href="https://github.com/brainpy/BrainPy/actions/workflows/CI-models.yml"><img alt="Continuous Integration with Models" src="https://github.com/brainpy/BrainPy/actions/workflows/CI-models.yml/badge.svg"></a>
1414
</p>
1515

1616

17-
BrainPy is a flexible, efficient, and extensible framework for computational neuroscience and brain-inspired computation based on the Just-In-Time (JIT) compilation (built on top of [JAX](https://github.com/google/jax), [Taichi](https://github.com/taichi-dev/taichi), [Numba](https://github.com/numba/numba), and others). It provides an integrative ecosystem for brain dynamics programming, including brain dynamics **building**, **simulation**, **training**, **analysis**, etc.
17+
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/en/latest
19+
- **Website (documentation and APIs)**: https://brainpy.readthedocs.io/
2020
- **Source**: https://github.com/brainpy/BrainPy
2121
- **Bug reports**: https://github.com/brainpy/BrainPy/issues
2222
- **Ecosystem**: https://brainmodeling.readthedocs.io/
23-
- **Source on OpenI**: https://git.openi.org.cn/OpenI/BrainPy
2423

2524

25+
BrainPy now is rewritten based on [brainstate](https://github.com/chaobrain/brainstate), please learn [brainstate documentation](https://brainstate.readthedocs.io/) for the latest updates.
2626

27-
## Installation
28-
29-
BrainPy is based on Python (>=3.8) and can be installed on Linux (Ubuntu 16.04 or later), macOS (10.12 or later), and Windows platforms.
3027

31-
BrainPy requires ``jax<0.6.0``.
28+
## Installation
3229

33-
For detailed installation instructions, please refer to the documentation: [Quickstart/Installation](https://brainpy.readthedocs.io/en/latest/quickstart/installation.html)
30+
BrainPy is based on Python (>=3.10) and can be installed on Linux (Ubuntu 16.04 or later), macOS (10.12 or later), and Windows platforms.
3431

3532

3633
### Using BrainPy with docker
@@ -64,6 +61,7 @@ We provide a Binder environment for BrainPy. You can use the following button to
6461
- [《神经计算建模实战》 (Neural Modeling in Action)](https://github.com/c-xy17/NeuralModeling)
6562
- [第一届神经计算建模与编程培训班 (First Training Course on Neural Modeling and Programming)](https://github.com/brainpy/1st-neural-modeling-and-programming-course)
6663
- [第二届神经计算建模与编程培训班 (Second Training Course on Neural Modeling and Programming)](https://github.com/brainpy/2nd-neural-modeling-and-programming-course)
64+
- **[brain modeling ecosystem](https://brainmodeling.readthedocs.io/)**: A collection of tools and libraries for brain modeling and simulation.
6765

6866

6967
## Citing

brainpy/_src/analysis/lowdim/lowdim_analyzer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def F_vmap_fx(self):
287287

288288
@property
289289
def F_dfxdx(self):
290-
"""The function to evaluate :math:`\frac{df_x(*\mathrm{vars}, *\mathrm{pars})}{dx}`."""
290+
r"""The function to evaluate :math:`\frac{df_x(*\mathrm{vars}, *\mathrm{pars})}{dx}`."""
291291
if C.F_dfxdx not in self.analyzed_results:
292292
dfx = bm.vector_grad(self.F_fx, argnums=0)
293293
self.analyzed_results[C.F_dfxdx] = jax.jit(dfx, device=self.jit_device)
@@ -416,7 +416,7 @@ def __init__(self, *args, **kwargs):
416416

417417
@property
418418
def F_fy(self):
419-
"""The function to evaluate :math:`f_y(*\mathrm{vars}, *\mathrm{pars})`.
419+
r"""The function to evaluate :math:`f_y(*\mathrm{vars}, *\mathrm{pars})`.
420420
421421
This function has been transformed into the standard call.
422422
For instance, if the user has the ``target_vars=("v1", "v2")`` and
@@ -525,31 +525,31 @@ def F_vmap_fy(self):
525525

526526
@property
527527
def F_dfxdy(self):
528-
"""The function to evaluate :math:`\frac{df_x (*\mathrm{vars}, *\mathrm{pars})}{dy}`."""
528+
r"""The function to evaluate :math:`\frac{df_x (*\mathrm{vars}, *\mathrm{pars})}{dy}`."""
529529
if C.F_dfxdy not in self.analyzed_results:
530530
dfxdy = bm.vector_grad(self.F_fx, argnums=1)
531531
self.analyzed_results[C.F_dfxdy] = jax.jit(dfxdy, device=self.jit_device)
532532
return self.analyzed_results[C.F_dfxdy]
533533

534534
@property
535535
def F_dfydx(self):
536-
"""The function to evaluate :math:`\frac{df_y (*\mathrm{vars}, *\mathrm{pars})}{dx}`."""
536+
r"""The function to evaluate :math:`\frac{df_y (*\mathrm{vars}, *\mathrm{pars})}{dx}`."""
537537
if C.F_dfydx not in self.analyzed_results:
538538
dfydx = bm.vector_grad(self.F_fy, argnums=0)
539539
self.analyzed_results[C.F_dfydx] = jax.jit(dfydx, device=self.jit_device)
540540
return self.analyzed_results[C.F_dfydx]
541541

542542
@property
543543
def F_dfydy(self):
544-
"""The function to evaluate :math:`\frac{df_y (*\mathrm{vars}, *\mathrm{pars})}{dy}`."""
544+
r"""The function to evaluate :math:`\frac{df_y (*\mathrm{vars}, *\mathrm{pars})}{dy}`."""
545545
if C.F_dfydy not in self.analyzed_results:
546546
dfydy = bm.vector_grad(self.F_fy, argnums=1)
547547
self.analyzed_results[C.F_dfydy] = jax.jit(dfydy, device=self.jit_device)
548548
return self.analyzed_results[C.F_dfydy]
549549

550550
@property
551551
def F_jacobian(self):
552-
"""The function to evaluate :math:`J(*\mathrm{vars}, *\mathrm{pars})`."""
552+
r"""The function to evaluate :math:`J(*\mathrm{vars}, *\mathrm{pars})`."""
553553
if C.F_jacobian not in self.analyzed_results:
554554
@partial(bm.jacobian, argnums=(0, 1))
555555
def f_jacobian(*var_and_pars):
@@ -1037,7 +1037,7 @@ def __init__(self, *args, **kwargs):
10371037

10381038
@property
10391039
def F_fz(self):
1040-
"""The function to evaluate :math:`f_y(*\mathrm{vars}, *\mathrm{pars})`."""
1040+
r"""The function to evaluate :math:`f_y(*\mathrm{vars}, *\mathrm{pars})`."""
10411041
if C.F_fz not in self.analyzed_results:
10421042
variables, arguments = utils.get_args(self.model.f_derivatives[self.z_var])
10431043
wrapper = utils.std_derivative(arguments, self.target_var_names, self.target_par_names)

brainpy/_src/analysis/lowdim/lowdim_bifurcation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def plot_bifurcation(self, with_plot=True, show=False, with_return=False,
172172
tol_aux=1e-8, tol_unique=1e-2, tol_opt_candidate=None,
173173
num_par_segments=1, num_fp_segment=1, nullcline_aux_filter=1.,
174174
select_candidates='aux_rank', num_rank=100):
175-
"""Make the bifurcation analysis.
175+
r"""Make the bifurcation analysis.
176176
177177
Parameters::
178178

brainpy/_src/connect/random_conn.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
class FixedProb(TwoEndConnector):
3232
"""Connect the post-synaptic neurons with fixed probability.
3333
34-
Parameters::
35-
34+
Parameters::
35+
3636
prob: float
3737
The conn probability.
3838
pre_ratio: float
@@ -143,8 +143,8 @@ def build_mat(self):
143143
class FixedTotalNum(TwoEndConnector):
144144
"""Connect the synaptic neurons with fixed total number.
145145
146-
Parameters::
147-
146+
Parameters::
147+
148148
num : float,int
149149
The conn total number.
150150
allow_multi_conn : bool, optional
@@ -214,8 +214,8 @@ def __repr__(self):
214214
class FixedPreNum(FixedNum):
215215
"""Connect a fixed number pf pre-synaptic neurons for each post-synaptic neuron.
216216
217-
Parameters::
218-
217+
Parameters::
218+
219219
num : float, int
220220
The conn probability (if "num" is float) or the fixed number of
221221
connectivity (if "num" is int).
@@ -274,8 +274,8 @@ def single_conn():
274274
class FixedPostNum(FixedNum):
275275
"""Connect the fixed number of post-synaptic neurons for each pre-synaptic neuron.
276276
277-
Parameters::
278-
277+
Parameters::
278+
279279
num : float, int
280280
The conn probability (if "num" is float) or the fixed number of
281281
connectivity (if "num" is int).
@@ -374,8 +374,8 @@ class GaussianProb(OneEndConnector):
374374
375375
where :math:`v_k^i` is the :math:`i`-th neuron's encoded value at dimension :math:`k`.
376376
377-
Parameters::
378-
377+
Parameters::
378+
379379
sigma : float
380380
Width of the Gaussian function.
381381
encoding_values : optional, list, tuple, int, float
@@ -511,10 +511,10 @@ def build_mat(self, isOptimized=True):
511511

512512

513513
class SmallWorld(TwoEndConnector):
514-
"""Build a Watts–Strogatz small-world graph.
514+
r"""Build a Watts–Strogatz small-world graph.
515+
516+
Parameters::
515517
516-
Parameters::
517-
518518
num_neighbor : int
519519
Each node is joined with its `k` nearest neighbors in a ring
520520
topology.
@@ -525,17 +525,17 @@ class SmallWorld(TwoEndConnector):
525525
include_self : bool
526526
Whether include the node self.
527527
528-
Notes::
529-
528+
Notes::
529+
530530
First create a ring over :math:`num\_node` nodes [1]_. Then each node in the ring is
531531
joined to its :math:`num\_neighbor` nearest neighbors (or :math:`num\_neighbor - 1` neighbors
532532
if :math:`num\_neighbor` is odd). Then shortcuts are created by replacing some edges as
533533
follows: for each edge :math:`(u, v)` in the underlying ":math:`num\_node`-ring with
534534
:math:`num\_neighbor` nearest neighbors" with probability :math:`prob` replace it with a new
535535
edge :math:`(u, w)` with uniformly random choice of existing node :math:`w`.
536536
537-
References::
538-
537+
References::
538+
539539
.. [1] Duncan J. Watts and Steven H. Strogatz,
540540
Collective dynamics of small-world networks,
541541
Nature, 393, pp. 440--442, 1998.
@@ -655,27 +655,27 @@ def build_conn(self):
655655

656656

657657
class ScaleFreeBA(TwoEndConnector):
658-
"""Build a random graph according to the Barabási–Albert preferential
658+
r"""Build a random graph according to the Barabási–Albert preferential
659659
attachment model.
660660
661661
A graph of :math:`num\_node` nodes is grown by attaching new nodes each with
662662
:math:`m` edges that are preferentially attached to existing nodes
663663
with high degree.
664664
665-
Parameters::
666-
665+
Parameters::
666+
667667
m : int
668668
Number of edges to attach from a new node to existing nodes
669669
seed : integer, random_state, or None (default)
670670
Indicator of random number generation state.
671671
672-
Raises::
673-
672+
Raises::
673+
674674
ConnectorError
675675
If `m` does not satisfy ``1 <= m < n``.
676676
677-
References::
678-
677+
References::
678+
679679
.. [1] A. L. Barabási and R. Albert "Emergence of scaling in
680680
random networks", Science 286, pp 509-512, 1999.
681681
"""
@@ -774,8 +774,8 @@ class ScaleFreeBADual(TwoEndConnector):
774774
edges (with probability :math:`p`) or :math:`m_2` edges (with probability :math:`1-p`) that
775775
are preferentially attached to existing nodes with high degree.
776776
777-
Parameters::
778-
777+
Parameters::
778+
779779
m1 : int
780780
Number of edges to attach from a new node to existing nodes with probability :math:`p`
781781
m2 : int
@@ -785,13 +785,13 @@ class ScaleFreeBADual(TwoEndConnector):
785785
seed : integer, random_state, or None (default)
786786
Indicator of random number generation state.
787787
788-
Raises::
789-
788+
Raises::
789+
790790
ConnectorError
791791
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n`` or `p` does not satisfy ``0 <= p <= 1``.
792792
793-
References::
794-
793+
References::
794+
795795
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
796796
"""
797797

@@ -900,17 +900,17 @@ class PowerLaw(TwoEndConnector):
900900
"""Holme and Kim algorithm for growing graphs with powerlaw
901901
degree distribution and approximate average clustering.
902902
903-
Parameters::
904-
903+
Parameters::
904+
905905
m : int
906906
the number of random edges to add for each new node
907907
p : float,
908908
Probability of adding a triangle after adding a random edge
909909
seed : integer, random_state, or None (default)
910910
Indicator of random number generation state.
911911
912-
Notes::
913-
912+
Notes::
913+
914914
The average clustering has a hard time getting above a certain
915915
cutoff that depends on :math:`m`. This cutoff is often quite low. The
916916
transitivity (fraction of triangles to possible triangles) seems to
@@ -927,14 +927,14 @@ class PowerLaw(TwoEndConnector):
927927
since the initial :math:`m` nodes may not be all linked to a new node
928928
on the first iteration like the BA model.
929929
930-
Raises::
931-
930+
Raises::
931+
932932
ConnectorError
933933
If :math:`m` does not satisfy :math:`1 <= m <= n` or :math:`p` does not
934934
satisfy :math:`0 <= p <= 1`.
935935
936-
References::
937-
936+
References::
937+
938938
.. [1] P. Holme and B. J. Kim,
939939
"Growing scale-free networks with tunable clustering",
940940
Phys. Rev. E, 65, 026107, 2002.
@@ -1071,8 +1071,8 @@ class ProbDist(TwoEndConnector):
10711071
10721072
.. versionadded:: 2.1.13
10731073
1074-
Parameters::
1075-
1074+
Parameters::
1075+
10761076
dist: float, int
10771077
The maximum distance between two points.
10781078
prob: float

docs/index.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,21 @@ Installation
1717

1818
.. code-block:: bash
1919
20-
# python 3.9-3.11
21-
pip install -U brainpy[cpu] # windows, linux, macos
20+
pip install -U brainpy[cpu]
2221
2322
.. tab-item:: GPU (CUDA 12)
2423

2524
.. code-block:: bash
2625
27-
pip install -U brainpy[cuda12] -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
26+
pip install -U brainpy[cuda12]
2827
2928
.. tab-item:: TPU
3029

3130
.. code-block:: bash
3231
33-
pip install -U brainpy[tpu] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
32+
pip install -U brainpy[tpu]
3433
3534
36-
For more information, please see `installation <quickstart/installation.html>`_ section.
37-
3835
----
3936

4037
Learn more
@@ -112,6 +109,10 @@ Learn more
112109
in mind what BrainPy version you are using.
113110

114111

112+
.. note::
113+
BrainPy now is rewritten based on [brainstate](https://github.com/chaobrain/brainstate).
114+
115+
115116

116117
----
117118

@@ -122,7 +123,6 @@ Learn more
122123
:maxdepth: 1
123124
:caption: Quickstart
124125

125-
quickstart/installation
126126
quickstart/simulation
127127
quickstart/training
128128
quickstart/analysis

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@
3737
"Documentation": "https://brainpy.readthedocs.io/",
3838
"Source Code": "https://github.com/brainpy/BrainPy",
3939
},
40-
dependency_links=[
41-
'https://storage.googleapis.com/jax-releases/jax_cuda_releases.html',
42-
],
4340
extras_require={
4441
'cpu': ['jax[cpu]', 'brainstate[cpu]', 'brainunit[cpu]', 'brainevent[cpu]'],
4542
'cuda12': ['jax[cuda12]', 'brainstate[cuda12]', 'brainunit[cuda12]', 'brainevent[cuda12]'],
46-
'tpu': ['jax[tpu]', 'brainstate[cuda12]', 'brainunit[cuda12]', 'brainevent[cuda12]'],
43+
'tpu': ['jax[tpu]', 'brainstate[tpu]', 'brainunit[tpu]', 'brainevent[tpu]'],
4744
},
4845
keywords=('computational neuroscience, '
4946
'brain-inspired computation, '

0 commit comments

Comments
 (0)