Skip to content

Commit

Permalink
[docs] Add colab link for documentation notebooks (#614)
Browse files Browse the repository at this point in the history
* Add colab link for documentation notebooks

* [math] Fix can not import `jax.in1d`

* Update requirements
  • Loading branch information
Routhleck committed Feb 8, 2024
1 parent 6de98c1 commit 9990f05
Show file tree
Hide file tree
Showing 63 changed files with 7,423 additions and 6,114 deletions.
18 changes: 17 additions & 1 deletion brainpy/_src/math/compat_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,23 @@ def asfarray(a, dtype=np.float_):
dtype = np.float_
return asarray(a, dtype=dtype)

def in1d(ar1, ar2, assume_unique: bool = False, invert: bool = False) -> Array:
del assume_unique
ar1_flat = ravel(ar1)
ar2_flat = ravel(ar2)
# Note: an algorithm based on searchsorted has better scaling, but in practice
# is very slow on accelerators because it relies on lax control flow. If XLA
# ever supports binary search natively, we should switch to this:
# ar2_flat = jnp.sort(ar2_flat)
# ind = jnp.searchsorted(ar2_flat, ar1_flat)
# if invert:
# return ar1_flat != ar2_flat[ind]
# else:
# return ar1_flat == ar2_flat[ind]
if invert:
return asarray((ar1_flat[:, None] != ar2_flat[None, :]).all(-1))
else:
return asarray((ar1_flat[:, None] == ar2_flat[None, :]).any(-1))

# Others
# ------
Expand Down Expand Up @@ -237,7 +254,6 @@ def asfarray(a, dtype=np.float_):
histogram_bin_edges = _compatible_with_brainpy_array(jnp.histogram_bin_edges)
histogramdd = _compatible_with_brainpy_array(jnp.histogramdd)
i0 = _compatible_with_brainpy_array(jnp.i0)
in1d = _compatible_with_brainpy_array(jnp.in1d)
indices = _compatible_with_brainpy_array(jnp.indices)
insert = _compatible_with_brainpy_array(jnp.insert)
intersect1d = _compatible_with_brainpy_array(jnp.intersect1d)
Expand Down
4 changes: 3 additions & 1 deletion docs/core_concept/brainpy_dynamical_system.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Concept 2: Dynamical System"
"# Concept 2: Dynamical System\n",
"\n",
"[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/brainpy/brainpy/blob/master/docs/core_concept/brainpy_dynamical_system.ipynb)"
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion docs/core_concept/brainpy_transform_concept.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
}
},
"source": [
"# Concept 1: Object-oriented Transformation"
"# Concept 1: Object-oriented Transformation\n",
"\n",
"[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/brainpy/examples/blob/main/docs/core_concept/brainpy_transform_concept.ipynb)"
]
},
{
Expand Down
247 changes: 134 additions & 113 deletions docs/quickstart/analysis.ipynb

Large diffs are not rendered by default.

278 changes: 159 additions & 119 deletions docs/quickstart/simulation.ipynb

Large diffs are not rendered by default.

240 changes: 147 additions & 93 deletions docs/quickstart/training.ipynb

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions docs/tutorial_FAQs/brainpy_ecosystem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# BrainPy Ecosystem for Brain Dynamics Modeling"
"# BrainPy Ecosystem for Brain Dynamics Modeling\n",
"\n",
"[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/brainpy/brainpy/blob/master/docs/tutorial_FAQs/brainpy_ecosystem.ipynb)"
]
},
{
Expand Down Expand Up @@ -54,17 +56,20 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"## 《神经计算建模实战》\n",
"\n",
"[《神经计算建模实战》 (Neural Modeling in Action)](https://github.com/c-xy17/NeuralModeling) is a book for brain dynamics modeling based on BrainPy. It introduces the basic concepts and methods of brain dynamics modeling, and provides comprehensive examples for brain dynamics modeling with BrainPy. \n"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"## 神经计算建模与编程培训班\n",
"\n",
Expand All @@ -76,10 +81,7 @@
"\n",
"This course is based on the textbook [《神经计算建模实战》 (Neural Modeling in Action)](https://github.com/c-xy17/NeuralModeling), supplemented by BrainPy, and based on the theory of \"theory+practice\" combination of teaching and learning. Through this course, students will master the basic concepts, methods and techniques of neural computation modelling, as well as how to use Python programming language to achieve convenient modelling and efficient simulation of neural systems, laying a solid foundation for future research in the field of neural computation or in the field of brain-like intelligence.\n",
"\n"
],
"metadata": {
"collapsed": false
}
]
}
],
"metadata": {
Expand Down

0 comments on commit 9990f05

Please sign in to comment.