Skip to content

Commit 09136ab

Browse files
committed
Update docstring parameter sections to use 'Parameters::'
Replaces NumPy-style 'Parameters' and 'Returns' docstring sections (using '----------') with reStructuredText-style 'Parameters::' and 'Returns::' across multiple modules. This improves consistency and compatibility with documentation tools that expect reST formatting.
1 parent 13dea6c commit 09136ab

105 files changed

Lines changed: 1431 additions & 1472 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

brainpy/_src/_delay.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class Delay(DynamicalSystem):
3434
delay = length-1 data
3535
delay = length data ]
3636
37-
Parameters
38-
----------
37+
Parameters::
38+
3939
latest: Variable
4040
The initial delay data.
4141
length: int
@@ -221,8 +221,8 @@ def _check_delay(self, delay_len):
221221
def retrieve(self, delay_step, *indices):
222222
"""Retrieve the delay data according to the delay length.
223223
224-
Parameters
225-
----------
224+
Parameters::
225+
226226
delay_step: int, ArrayType
227227
The delay length used to retrieve the data.
228228
"""

brainpy/_src/analysis/highdim/slow_points.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class SlowPointFinder(base.DSAnalyzer):
4646
- exclude any non-unique fixed points according to a tolerance
4747
- exclude any far-away "outlier" fixed points
4848
49-
Parameters
50-
----------
49+
Parameters::
50+
5151
f_cell : callable, function, DynamicalSystem
5252
The target of computing the recurrent units.
5353
@@ -307,8 +307,8 @@ def find_fps_with_gd_method(
307307
):
308308
"""Optimize fixed points with gradient descent methods.
309309
310-
Parameters
311-
----------
310+
Parameters::
311+
312312
candidates : ArrayType, dict
313313
The array with the shape of (batch size, state dim) of hidden states
314314
of RNN to start training for fixed points.
@@ -409,8 +409,8 @@ def find_fps_with_opt_solver(
409409
):
410410
"""Optimize fixed points with nonlinear optimization solvers.
411411
412-
Parameters
413-
----------
412+
Parameters::
413+
414414
candidates: ArrayType, dict
415415
The candidate (initial) fixed points.
416416
opt_solver: str
@@ -453,8 +453,8 @@ def find_fps_with_opt_solver(
453453
def filter_loss(self, tolerance: float = 1e-5):
454454
"""Filter fixed points whose speed larger than a given tolerance.
455455
456-
Parameters
457-
----------
456+
Parameters::
457+
458458
tolerance: float
459459
Discard fixed points with squared speed larger than this value.
460460
"""
@@ -478,8 +478,8 @@ def filter_loss(self, tolerance: float = 1e-5):
478478
def keep_unique(self, tolerance: float = 2.5e-2):
479479
"""Filter unique fixed points by choosing a representative within tolerance.
480480
481-
Parameters
482-
----------
481+
Parameters::
482+
483483
tolerance: float
484484
Tolerance for determination of identical fixed points.
485485
"""
@@ -500,8 +500,8 @@ def keep_unique(self, tolerance: float = 2.5e-2):
500500
def exclude_outliers(self, tolerance: float = 1e0):
501501
"""Exclude points whose closest neighbor is further than threshold.
502502
503-
Parameters
504-
----------
503+
Parameters::
504+
505505
tolerance: float
506506
Any point whose closest fixed point is greater than tol is an outlier.
507507
"""
@@ -545,8 +545,8 @@ def compute_jacobians(
545545
):
546546
"""Compute the Jacobian matrices at the points.
547547
548-
Parameters
549-
----------
548+
Parameters::
549+
550550
points: np.ndarray, bm.ArrayType, jax.ndarray
551551
The fixed points with the shape of (num_point, num_dim).
552552
stack_dict_var: bool
@@ -605,17 +605,17 @@ def compute_jacobians(
605605
def decompose_eigenvalues(matrices, sort_by='magnitude', do_compute_lefts=False):
606606
"""Compute the eigenvalues of the matrices.
607607
608-
Parameters
609-
----------
608+
Parameters::
609+
610610
matrices: np.ndarray, bm.ArrayType, jax.ndarray
611611
A 3D array with the shape of (num_matrices, dim, dim).
612612
sort_by: str
613613
The method of sorting.
614614
do_compute_lefts: bool
615615
Compute the left eigenvectors? Requires a pseudo-inverse call.
616616
617-
Returns
618-
-------
617+
Returns::
618+
619619
decompositions : list
620620
A list of dictionaries with sorted eigenvalues components:
621621
(eigenvalues, right eigenvectors, and left eigenvectors).

brainpy/_src/analysis/lowdim/lowdim_analyzer.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class LowDimAnalyzer(DSAnalyzer):
3939
.. note::
4040
``LowDimAnalyzer`` cannot analyze dynamical system depends on time :math:`t`.
4141
42-
Parameters
43-
----------
42+
Parameters::
43+
4444
model : Any, ODEIntegrator, sequence of ODEIntegrator, DynamicalSystem
4545
A model of the population, the integrator function,
4646
or a list/tuple of integrator functions.
@@ -346,15 +346,14 @@ def _get_fixed_points(self, candidates, *args, num_seg=None, tol_aux=1e-7, loss_
346346
>>> all_par1.append(jnp.ones_like(xs) * p1)
347347
>>> all_par2.append(jnp.ones_like(xs) * p2)
348348
349-
Parameters
350-
----------
349+
Parameters::
350+
351351
candidates
352352
args
353353
tol_aux
354354
loss_screen
355355
356-
Returns
357-
-------
356+
Returns::
358357
359358
"""
360359
# candidates: xs, a vector with the length of self.resolutions[self.x_var]
@@ -913,8 +912,8 @@ def _get_fixed_points(self, candidates, *args, tol_aux=1e-7,
913912
>>> all_par1.append(jnp.ones_like(nullcline_points) * p1)
914913
>>> all_par2.append(jnp.ones_like(nullcline_points) * p2)
915914
916-
Parameters
917-
----------
915+
Parameters::
916+
918917
candidates: np.ndarray, jnp.ndarray
919918
The candidate points (batched) to optimize, like the nullcline points.
920919
args : tuple
@@ -923,8 +922,8 @@ def _get_fixed_points(self, candidates, *args, tol_aux=1e-7,
923922
tol_unique : float
924923
tol_opt_candidate : float, optional
925924
926-
Returns
927-
-------
925+
Returns::
926+
928927
res : tuple
929928
The fixed point results.
930929
"""

brainpy/_src/analysis/lowdim/lowdim_bifurcation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def plot_bifurcation(self, with_plot=True, show=False, with_return=False,
174174
select_candidates='aux_rank', num_rank=100):
175175
"""Make the bifurcation analysis.
176176
177-
Parameters
178-
----------
177+
Parameters::
178+
179179
with_plot: bool
180180
Whether plot the bifurcation figure.
181181
show: bool
@@ -211,8 +211,8 @@ def plot_bifurcation(self, with_plot=True, show=False, with_return=False,
211211
The number of candidates to be used to optimize the fixed points.
212212
rank to use.
213213
214-
Returns
215-
-------
214+
Returns::
215+
216216
results : tuple
217217
Return a tuple of analyzed results:
218218

brainpy/_src/analysis/lowdim/lowdim_phase_plane.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class PhasePlane1D(Num1DAnalyzer):
2727
- Vector fields
2828
- Fixed points
2929
30-
Parameters
31-
----------
30+
Parameters::
31+
3232
model : Any
3333
A model of the population, the integrator function,
3434
or a list/tuple of integrator functions.
@@ -123,8 +123,8 @@ def plot_fixed_point(self, show=False, with_plot=True, with_return=False):
123123
class PhasePlane2D(Num2DAnalyzer):
124124
"""Phase plane analyzer for 2D dynamical system.
125125
126-
Parameters
127-
----------
126+
Parameters::
127+
128128
model : Any
129129
A model of the population, the integrator function,
130130
or a list/tuple of integrator functions.
@@ -169,8 +169,8 @@ def plot_vector_field(self, with_plot=True, with_return=False,
169169
plot_method='streamplot', plot_style=None, show=False):
170170
"""Plot the vector field.
171171
172-
Parameters
173-
----------
172+
Parameters::
173+
174174
with_plot: bool
175175
with_return : bool
176176
show : bool
@@ -364,8 +364,8 @@ def plot_trajectory(self, initials, duration, plot_durations=None, axes='v-v',
364364
dt=None, show=False, with_plot=True, with_return=False, **kwargs):
365365
"""Plot trajectories according to the settings.
366366
367-
Parameters
368-
----------
367+
Parameters::
368+
369369
initials : list, tuple, dict
370370
The initial value setting of the targets. It can be a tuple/list of floats to specify
371371
each value of dynamical variables (for example, ``(a, b)``). It can also be a
@@ -460,8 +460,8 @@ def plot_trajectory(self, initials, duration, plot_durations=None, axes='v-v',
460460
def plot_limit_cycle_by_sim(self, initials, duration, tol=0.01, show=False, dt=None):
461461
"""Plot trajectories according to the settings.
462462
463-
Parameters
464-
----------
463+
Parameters::
464+
465465
initials : list, tuple
466466
The initial value setting of the targets.
467467

brainpy/_src/analysis/stability.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,17 @@ def stability_analysis(derivatives):
8383
8484
The analysis is referred to [1]_.
8585
86-
Parameters
87-
----------
86+
Parameters::
87+
8888
derivatives : float, tuple, list, np.ndarray
8989
The derivative of the f.
9090
91-
Returns
92-
-------
91+
Returns::
92+
9393
fp_type : str
9494
The type of the fixed point.
9595
96-
References
97-
----------
96+
References::
9897
9998
.. [1] http://www.egwald.ca/nonlineardynamics/twodimensionaldynamics.php
10099

brainpy/_src/analysis/utils/measurement.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ def euclidean_distance(points: np.ndarray, num_point=None):
4747
>>> from scipy.spatial.distance import squareform, pdist
4848
>>> f = lambda points: squareform(pdist(points, metric="euclidean"))
4949
50-
Parameters
51-
----------
50+
Parameters::
51+
5252
points: ArrayType
5353
The points.
5454
55-
Returns
56-
-------
55+
Returns::
56+
5757
dist_matrix: jnp.ndarray
5858
The distance matrix.
5959
"""
@@ -94,14 +94,14 @@ def euclidean_distance_jax(points: Union[jnp.ndarray, bm.ndarray], num_point=Non
9494
>>> from scipy.spatial.distance import squareform, pdist
9595
>>> f = lambda points: squareform(pdist(points, metric="euclidean"))
9696
97-
Parameters
98-
----------
97+
Parameters::
98+
9999
points: ArrayType
100100
The points.
101101
num_point: int
102102
103-
Returns
104-
-------
103+
Returns::
104+
105105
dist_matrix: ArrayType
106106
The distance matrix.
107107
"""

brainpy/_src/analysis/utils/optimization.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ def scipy_minimize_with_jax(fun, x0,
229229
"""
230230
A simple wrapper for scipy.optimize.minimize using JAX.
231231
232-
Parameters
233-
----------
232+
Parameters::
233+
234234
fun: function
235235
The objective function to be minimized, written in JAX code
236236
so that it is automatically differentiable. It is of type,
@@ -326,8 +326,8 @@ def scipy_minimize_with_jax(fun, x0,
326326
```callback(xk)```
327327
where `xk` is the current parameter vector, represented as a PyTree.
328328
329-
Returns
330-
-------
329+
Returns::
330+
331331
res : The optimization result represented as a ``OptimizeResult`` object.
332332
Important attributes are:
333333
``x``: the solution array, represented as a JAX PyTree
@@ -423,8 +423,8 @@ def numpy_brentq(f, a, b, args=(), xtol=2e-14, maxiter=200, rtol=4 * np.finfo(fl
423423
Uses the classic Brent's method to find a zero of the function `f` on
424424
the sign changing interval [a , b].
425425
426-
Parameters
427-
----------
426+
Parameters::
427+
428428
f : callable
429429
Python function returning a number. `f` must be continuous.
430430
a : number
@@ -545,15 +545,15 @@ def numpy_brentq(f, a, b, args=(), xtol=2e-14, maxiter=200, rtol=4 * np.finfo(fl
545545
def find_root_of_1d_numpy(f, f_points, args=(), tol=1e-8):
546546
"""Find the roots of the given function by numerical methods.
547547
548-
Parameters
549-
----------
548+
Parameters::
549+
550550
f : callable
551551
The function.
552552
f_points : np.ndarray, list, tuple
553553
The value points.
554554
555-
Returns
556-
-------
555+
Returns::
556+
557557
roots : list
558558
The roots.
559559
"""

0 commit comments

Comments
 (0)