Skip to content

Commit

Permalink
Merge pull request #44 from PKU-NIP-Lab/develop
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
chaoming0625 committed Apr 28, 2021
2 parents 1a2334a + 3491ec9 commit ec9e6dd
Show file tree
Hide file tree
Showing 22 changed files with 484 additions and 225 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ docs/quickstart/.ipynb_checkpoints

docs/tutorials_advanced/_autosummary
docs/tutorials_advanced/.ipynb_checkpoints
develop/fast_synapse_computation.py
develop/fast_synapse_computation2.py

docs/apis/_autosummary
docs/tutorials_advanced/usage_of_inputfactory.py
docs/tutorials_advanced/usage_of_utils_connect.py

docs/apis/_autosummary
docs/apis/integrators/_autosummary

develop/benchmark/COBA/brian2*
develop/benchmark/COBA/annarchy*
develop/benchmark/COBAHH/brian2*
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ Moreover, `BrainPy` is designed to effectively satisfy your basic requirements:

# Installation

``BrainPy`` is based on Python (>=3.7), and the following packages are required to be installed to use ``BrainPy``:

- NumPy >= 1.13
- Matplotlib >= 3.3

Install ``BrainPy`` by using ``pip``:

```bash
> pip install brainpy-simulator>=1.0.0rc2
> pip install -U brainpy-simulator
```

Install ``BrainPy`` by using ``conda``:
Expand All @@ -48,15 +53,9 @@ Install ``BrainPy`` from source:
> # or
> pip install git+https://git.openi.org.cn/OpenI/BrainPy
> # or
> pip install -e git://github.com/PKU-NIP-Lab/BrainPy.git@V0.2.5
> pip install -e git://github.com/PKU-NIP-Lab/BrainPy.git@V1.0.0
```

``BrainPy`` is based on Python (>=3.7), and the following packages are required to be installed to use ``BrainPy``:

- NumPy >= 1.13
- Matplotlib >= 3.3



# Let's start

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.0"
__version__ = "1.0.1"

# "backend" module
from . import backend
Expand Down
6 changes: 6 additions & 0 deletions brainpy/backend/drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def switch_to(backend):

elif backend in ['numba', 'numba-parallel']:
from . import numba_cpu

if backend == 'numba':
numba_cpu.set_numba_profile(nogil=False, parallel=False)
else:
numba_cpu.set_numba_profile(nogil=True, parallel=True)

NET_DRIVER = buffer.get('net', None) or GeneralNetDriver
NODE_DRIVER = buffer.get('node', None) or numba_cpu.NumbaCPUNodeDriver
DIFFINT_DRIVER = buffer.get('intg', None) or numba_cpu.NumbaCpuDiffIntDriver
Expand Down
37 changes: 20 additions & 17 deletions brainpy/visualization/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ def line_plot(ts,
plot_ids = [0]
elif isinstance(plot_ids, int):
plot_ids = [plot_ids]
try:
assert isinstance(plot_ids, (list, tuple))
except AssertionError:
raise ModelUseError('"plot_ids" specifies the value index to plot, '
'it must be a list/tuple.')
if not isinstance(plot_ids, (list, tuple)) and \
not (isinstance(plot_ids, np.ndarray) and np.ndim(plot_ids) == 1):
raise ModelUseError(f'"plot_ids" specifies the value index to plot, it must '
f'be a list/tuple/1D numpy.ndarray, not {type(plot_ids)}.')

# get ax
if ax is None:
Expand Down Expand Up @@ -184,7 +183,7 @@ def animate_2D(values,
val_min=None,
val_max=None,
cmap=None,
frame_delay=1.,
frame_delay=10,
frame_step=1,
title_size=10,
figsize=None,
Expand Down Expand Up @@ -231,8 +230,8 @@ def animate_2D(values,
Returns
-------
figure : plt.figure
The created figure instance.
anim : animation.FuncAnimation
The created animation function.
"""
dt = backend.get_dt() if dt is None else dt
num_step, num_neuron = values.shape
Expand All @@ -252,25 +251,29 @@ def frame(t):
plt.pcolor(img, cmap=cmap, vmin=val_min, vmax=val_max)
plt.colorbar()
plt.axis('off')
fig.suptitle("Time: {:.2f} ms".format((t + 1) * dt),
fontsize=title_size, fontweight='bold')
fig.suptitle(t="Time: {:.2f} ms".format((t + 1) * dt),
fontsize=title_size,
fontweight='bold')
return [fig.gca()]

values = values.reshape((num_step, height, width))
anim_result = animation.FuncAnimation(
fig, frame, frames=list(range(1, num_step, frame_step)),
init_func=None, interval=frame_delay, repeat_delay=3000)
anim = animation.FuncAnimation(fig=fig,
func=frame,
frames=list(range(1, num_step, frame_step)),
init_func=None,
interval=frame_delay,
repeat_delay=3000)
if save_path is None:
if show:
plt.show()
else:
if save_path[-3:] == 'gif':
anim_result.save(save_path, dpi=gif_dpi, writer='imagemagick')
anim.save(save_path, dpi=gif_dpi, writer='imagemagick')
elif save_path[-3:] == 'mp4':
anim_result.save(save_path, writer='ffmpeg', fps=video_fps, bitrate=3000)
anim.save(save_path, writer='ffmpeg', fps=video_fps, bitrate=3000)
else:
anim_result.save(save_path + '.mp4', writer='ffmpeg', fps=video_fps, bitrate=3000)
return fig
anim.save(save_path + '.mp4', writer='ffmpeg', fps=video_fps, bitrate=3000)
return anim


def animate_1D(dynamical_vars,
Expand Down
2 changes: 1 addition & 1 deletion develop/conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: brainpy-simulator
version: "1.0.0"
version: "1.0.1"

source:
path: ../../
Expand Down
2 changes: 1 addition & 1 deletion docs/apis/backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ brainpy.backend
set_dt
get_dt
set_ops
get_backend
get_backend_name
set_class_keywords
set_ops_from_module
8 changes: 4 additions & 4 deletions docs/apis/connectivity.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
brainpy.connect
===============
``brainpy.connect`` module
==========================

.. currentmodule:: brainpy.simulation.connectivity
.. automodule:: brainpy.simulation.connectivity
Expand All @@ -17,8 +17,8 @@ brainpy.connect
post2pre
pre2syn
post2syn
pre_slice_syn
post_slice_syn
pre_slice
post_slice


``connector`` methods
Expand Down
58 changes: 44 additions & 14 deletions docs/apis/integrators.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
brainpy.integrators
===================
``brainpy.integrators`` module
==============================

.. currentmodule:: brainpy.integrators
.. automodule:: brainpy.integrators

.. contents::
:local:
:depth: 1
.. toctree::
:maxdepth: 3

integrators/ODE
integrators/SDE


General functions
Expand All @@ -18,22 +19,51 @@ General functions

odeint
sdeint
ddeint
fdeint
set_default_odeint
get_default_odeint
set_default_sdeint
get_default_sdeint

``ast_analysis`` module
-----------------------


.. rubric:: :doc:`integrators/ODE`

.. autosummary::
:toctree: _autosummary
:nosignatures:

ode.euler
ode.midpoint
ode.heun2
ode.ralston2
ode.rk2
ode.rk3
ode.heun3
ode.ralston3
ode.ssprk3
ode.rk4
ode.ralston4
ode.rk4_38rule

ode.rkf45
ode.rkf12
ode.rkdp
ode.ck
ode.bs
ode.heun_euler

DiffEqReader
separate_variables
ode.exponential_euler

.. autoclass:: DiffEqReader
:members:


.. rubric:: :doc:`integrators/SDE`

.. autosummary::
:nosignatures:

sde.euler
sde.heun
sde.milstein
sde.exponential_euler
sde.srk1w1_scalar
sde.srk2w1_scalar
sde.KlPl_scalar
47 changes: 47 additions & 0 deletions docs/apis/integrators/ODE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Numerical Methods for ODEs
==========================

.. currentmodule:: brainpy.integrators.ode
.. automodule:: brainpy.integrators.ode


Explicit Runge-Kutta methods
----------------------------

.. autosummary::
:toctree: _autosummary

euler
midpoint
heun2
ralston2
rk2
rk3
heun3
ralston3
ssprk3
rk4
ralston4
rk4_38rule


Adaptive Runge-Kutta methods
----------------------------

.. autosummary::
:toctree: _autosummary

rkf45
rkf12
rkdp
ck
bs
heun_euler

Other methods
-------------

.. autosummary::
:toctree: _autosummary

exponential_euler
16 changes: 16 additions & 0 deletions docs/apis/integrators/SDE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Numerical Methods for SDEs
==========================

.. currentmodule:: brainpy.integrators.sde
.. automodule:: brainpy.integrators.sde

.. autosummary::
:toctree: _autosummary

euler
heun
milstein
exponential_euler
srk1w1_scalar
srk2w1_scalar
KlPl_scalar
11 changes: 2 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ Comprehensive examples of BrainPy please see
`BrainModels <https://brainmodels.readthedocs.io/en/latest/>`_.


.. Hint::

“Do you know calculus?”

“You had better learn it. It’s the language God talks.”

-- Richard Feynman


.. toctree::
:maxdepth: 2
:caption: Quickstart
Expand Down Expand Up @@ -59,6 +50,8 @@ Comprehensive examples of BrainPy please see
:maxdepth: 1
:caption: API documentation

apis/integrators
apis/connectivity
apis/inputs_module
apis/changelog

Expand Down

0 comments on commit ec9e6dd

Please sign in to comment.