Skip to content

Commit

Permalink
Add systematical documents
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Apr 18, 2021
1 parent abeb739 commit fb167ae
Show file tree
Hide file tree
Showing 70 changed files with 3,429 additions and 4,723 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

![Logo](docs/images/logo.png)
![Logo](docs/_static/logo.png)

[![LICENSE](https://anaconda.org/brainpy/brainpy/badges/license.svg)](https://github.com/PKU-NIP-Lab/BrainPy) [![Documentation](https://readthedocs.org/projects/brainpy/badge/?version=latest)](https://brainpy.readthedocs.io/en/latest/?badge=latest) [![Conda](https://anaconda.org/brainpy/brainpy-simulator/badges/version.svg)](https://anaconda.org/brainpy/brainpy-simulator) [![PyPI version](https://badge.fury.io/py/brainpy-simulator.svg)](https://badge.fury.io/py/brainpy-simulator)

Expand All @@ -21,7 +21,7 @@ Moreover, `BrainPy` is designed to effectively satisfy your basic requirements:
- *Efficient running speed*, because BrainPy is compatible with the latest JIT compilers or any other accelerating framework you prefer (below we list the speed comparison based on Numba JIT).


![Speed Comparison](docs/images/speed.png)
![Speed Comparison](docs/_static/speed.png)

`BrainPy` is a backend-independent neural simulator. Users can define models with any backend they prefer. Intrinsically, BrainPy supports the array/tensor-oriented backends such like [NumPy](https://numpy.org/), [PyTorch](https://pytorch.org/), and [TensorFlow](https://www.tensorflow.org/), it also supports the JIT compilers such as [Numba](https://numba.pydata.org/) on CPU or CUDA devices. Extending BrainPy to support other backend frameworks you prefer is very easy. The details please see documents coming soon.

Expand Down Expand Up @@ -71,7 +71,7 @@ Here list several simple examples for neurodynamics simulation and analysis. Com
<tr>
<td border="0" width="30%">
<a href="https://github.com/PKU-NIP-Lab/BrainModels/blob/main/brainmodels/tensor_backend/neurons/HodgkinHuxley_model.py">
<img src="docs/images/HH_neuron.png">
<img src="docs/_static/HH_neuron.png">
</a>
</td>
<td border="0" valign="top">
Expand All @@ -82,7 +82,7 @@ Here list several simple examples for neurodynamics simulation and analysis. Com
<tr>
<td border="0" width="30%">
<a href="https://github.com/PKU-NIP-Lab/BrainModels/blob/main/brainmodels/tensor_backend/synapses/AMPA_synapse.py">
<img src="docs/images/AMPA_model.png">
<img src="docs/_static/AMPA_model.png">
</a>
</td>
<td border="0" valign="top">
Expand All @@ -93,7 +93,7 @@ Here list several simple examples for neurodynamics simulation and analysis. Com
<tr>
<td border="0" width="30%">
<a href="https://brainmodels.readthedocs.io/en/latest/from_papers/Wang_1996_gamma_oscillation.html">
<img src="docs/images/gamma_oscillation.png">
<img src="docs/_static/gamma_oscillation.png">
</a>
</td>
<td border="0" valign="top">
Expand All @@ -107,7 +107,7 @@ Here list several simple examples for neurodynamics simulation and analysis. Com
<tr>
<td border="0" width="30%">
<a href="https://brainmodels.readthedocs.io/en/latest/from_papers/Vreeswijk_1996_EI_net.html">
<img src="docs/images/EI_balance_net.png">
<img src="docs/_static/EI_balance_net.png">
</a>
</td>
<td border="0" valign="top">
Expand All @@ -120,7 +120,7 @@ Here list several simple examples for neurodynamics simulation and analysis. Com
<tr>
<td border="0" width="30%">
<a href="https://brainmodels.readthedocs.io/en/latest/from_papers/Wu_2008_CANN.html">
<img src="docs/images/CANN1d.png">
<img src="docs/_static/CANN1d.png">
</a>
</td>
<td border="0" valign="top">
Expand All @@ -134,7 +134,7 @@ Here list several simple examples for neurodynamics simulation and analysis. Com
<tr>
<td border="0" width="30%">
<a href="https://brainmodels.readthedocs.io/en/latest/tutorials/dynamics_analysis/NaK_model_analysis.html">
<img src="docs/images/phase_plane_analysis1.png">
<img src="docs/_static/phase_plane_analysis1.png">
</a>
</td>
<td border="0" valign="top">
Expand All @@ -146,7 +146,7 @@ Here list several simple examples for neurodynamics simulation and analysis. Com
<tr>
<td border="0" width="30%">
<a href="https://brainmodels.readthedocs.io/en/latest/tutorials/dynamics_analysis/FitzHugh_Nagumo_analysis.html">
<img src="docs/images/FitzHugh_Nagumo_codimension1.png">
<img src="docs/_static/FitzHugh_Nagumo_codimension1.png">
</a>
</td>
<td border="0" valign="top">
Expand All @@ -159,7 +159,7 @@ Here list several simple examples for neurodynamics simulation and analysis. Com
<tr>
<td border="0" width="30%">
<a href="https://brainmodels.readthedocs.io/en/latest/tutorials/dynamics_analysis/FitzHugh_Nagumo_analysis.html#Codimension-2-bifurcation-analysis">
<img src="docs/images/FitzHugh_Nagumo_codimension2.png">
<img src="docs/_static/FitzHugh_Nagumo_codimension2.png">
</a>
</td>
<td border="0" valign="top">
Expand Down
2 changes: 1 addition & 1 deletion brainpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

__version__ = "1.0.0rc2"
__version__ = "1.0.0"

# "backend" module
from . import backend
Expand Down
29 changes: 23 additions & 6 deletions brainpy/backend/ops/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import types

from .numpy_ import *

Expand All @@ -16,9 +17,12 @@

_backend = 'numpy'
BUFFER = {}
OPS_FOR_SOLVER = ['normal', 'sum', 'exp', 'matmul', 'shape', ]
OPS_FOR_SOLVER = ['normal', 'sum', 'exp', 'shape', ]
OPS_FOR_SIMULATION = ['as_tensor', 'zeros', 'ones', 'arange',
'vstack', 'where', 'unsqueeze', 'squeeze']
OPS_OF_DTYPE = ['bool',
'int', 'int32', 'int64',
'float', 'float32', 'float64']


def switch_to(backend):
Expand Down Expand Up @@ -54,7 +58,7 @@ def switch_to(backend):
ops_in_buffer = get_buffer(backend)
for ops in OPS_FOR_SOLVER:
if ops not in ops_in_buffer:
raise ValueError(f'Operation "{ops}" is needed, but is not '
raise ValueError(f'Necessary operation "{ops}" is not '
f'defined in "{backend}" backend\'s buffers.')

# set operations from BUFFER
Expand All @@ -71,17 +75,30 @@ def set_ops_from_module(module):
----------
module :
"""

ops_in_module = {p: getattr(module, p) for p in dir(module)
if (not p.startswith('__')) and
(not isinstance(getattr(module, p), types.ModuleType))}
global_vars = globals()

for ops in OPS_FOR_SOLVER:
if not hasattr(module, ops):
if ops not in ops_in_module:
raise ValueError(f'Operation "{ops}" is needed, but is not '
f'defined in module "{module}".')
global_vars[ops] = getattr(module, ops)
global_vars[ops] = ops_in_module.pop(ops)
for ops in OPS_FOR_SIMULATION:
if hasattr(module, ops):
global_vars[ops] = getattr(module, ops)
if ops in ops_in_module:
global_vars[ops] = ops_in_module.pop(ops)
else:
del global_vars[ops]
for ops in OPS_OF_DTYPE:
if ops in ops_in_module:
global_vars[ops] = ops_in_module.pop(ops)
else:
del global_vars[ops]

for ops, val in ops_in_module.items():
global_vars[ops] = val


def set_ops(**kwargs):
Expand Down
Loading

0 comments on commit fb167ae

Please sign in to comment.