Skip to content

Commit 13dea6c

Browse files
committed
Fix docstring formatting issues in sphinx build
- Convert docstring section headers from rst underline format to :: format - Fixes sphinx_autodoc_typehints extension errors - Only modify the problematic Examples, Parameters, Returns sections - Affects 21 core files with docstring formatting issues
1 parent 551d842 commit 13dea6c

21 files changed

Lines changed: 834 additions & 857 deletions

File tree

brainpy/_src/connect/base.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def set_default_dtype(mat_dtype=None, idx_dtype=None):
8888
[0., 1., 0., 1.],
8989
[0., 0., 1., 0.]], dtype=float32)
9090
91-
Parameters
92-
----------
91+
Parameters::
92+
9393
mat_dtype : type
9494
The default dtype for connection matrix.
9595
idx_dtype : type
@@ -173,15 +173,15 @@ def __repr__(self):
173173
def __call__(self, pre_size, post_size):
174174
"""Create the concrete connections between two end objects.
175175
176-
Parameters
177-
----------
176+
Parameters::
177+
178178
pre_size : int, tuple of int, list of int
179179
The size of the pre-synaptic group.
180180
post_size : int, tuple of int, list of int
181181
The size of the post-synaptic group.
182182
183-
Returns
184-
-------
183+
Returns::
184+
185185
conn : TwoEndConnector
186186
Return the self.
187187
"""
@@ -201,8 +201,8 @@ def __call__(self, pre_size, post_size):
201201
def _reset_conn(self, pre_size, post_size):
202202
"""Reset connection attributes.
203203
204-
Parameters
205-
----------
204+
Parameters::
205+
206206
pre_size : int, tuple of int, list of int
207207
The size of the pre-synaptic group.
208208
post_size : int, tuple of int, list of int
@@ -382,9 +382,8 @@ def _make_returns(self, structures, conn_data):
382382
def require(self, *structures):
383383
"""Require all the connection data needed.
384384
385-
Examples
386-
--------
387-
385+
Examples::
386+
388387
>>> import brainpy as bp
389388
>>> conn = bp.connect.FixedProb(0.1)
390389
>>> mat = conn.require(10, 20, 'conn_mat')
@@ -514,8 +513,8 @@ def build_conn(self):
514513
- ``build_coo()``: build a coo sparse connection data.
515514
- ``build_conn()``: deprecated.
516515
517-
Returns
518-
-------
516+
Returns::
517+
519518
conn: tuple, dict
520519
A tuple with two elements: connection type (str) and connection data.
521520
For example: ``return 'csr', (ind, indptr)``
@@ -537,8 +536,8 @@ def build_mat(self):
537536
- ``build_coo()``: build a coo sparse connection data.
538537
- ``build_conn()``: deprecated.
539538
540-
Returns
541-
-------
539+
Returns::
540+
542541
conn: Array
543542
A binary matrix with the shape ``(num_pre, num_post)``.
544543
"""
@@ -548,8 +547,8 @@ def build_mat(self):
548547
def build_csr(self):
549548
"""Build a csr sparse connection data.
550549
551-
Returns
552-
-------
550+
Returns::
551+
553552
conn: tuple
554553
A tuple denoting the ``(indices, indptr)``.
555554
"""
@@ -559,8 +558,8 @@ def build_csr(self):
559558
def build_coo(self):
560559
"""Build a coo sparse connection data.
561560
562-
Returns
563-
-------
561+
Returns::
562+
564563
conn: tuple
565564
A tuple denoting the ``(pre_ids, post_ids)``.
566565
"""

brainpy/_src/dnn/normalization.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class BatchNorm(Layer):
5252
where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the
5353
new observed value.
5454
55-
Parameters
56-
----------
55+
Parameters::
56+
5757
num_features: int
5858
``C`` from an expected input of size ``(..., C)``.
5959
axis: int, tuple, list
@@ -79,8 +79,8 @@ class BatchNorm(Layer):
7979
Specifies how devices are grouped. Valid
8080
only within ``jax.pmap`` collectives.
8181
82-
References
83-
----------
82+
References::
83+
8484
.. [1] Ioffe, Sergey and Christian Szegedy. “Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift.” ArXiv abs/1502.03167 (2015): n. pag.
8585
8686
"""
@@ -177,8 +177,8 @@ class BatchNorm1d(BatchNorm):
177177
where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the
178178
new observed value.
179179
180-
Parameters
181-
----------
180+
Parameters::
181+
182182
num_features: int
183183
``C`` from an expected input of size ``(B, L, C)``.
184184
axis: int, tuple, list
@@ -204,8 +204,8 @@ class BatchNorm1d(BatchNorm):
204204
Specifies how devices are grouped. Valid
205205
only within ``jax.pmap`` collectives.
206206
207-
References
208-
----------
207+
References::
208+
209209
.. [1] Ioffe, Sergey and Christian Szegedy. “Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift.” ArXiv abs/1502.03167 (2015): n. pag.
210210
211211
"""
@@ -260,8 +260,8 @@ class BatchNorm2d(BatchNorm):
260260
where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the
261261
new observed value.
262262
263-
Parameters
264-
----------
263+
Parameters::
264+
265265
num_features: int
266266
``C`` from an expected input of size ``(B, H, W, C)``.
267267
axis: int, tuple, list
@@ -287,8 +287,8 @@ class BatchNorm2d(BatchNorm):
287287
Specifies how devices are grouped. Valid
288288
only within ``jax.pmap`` collectives.
289289
290-
References
291-
----------
290+
References::
291+
292292
.. [1] Ioffe, Sergey and Christian Szegedy. “Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift.” ArXiv abs/1502.03167 (2015): n. pag.
293293
294294
"""
@@ -343,8 +343,8 @@ class BatchNorm3d(BatchNorm):
343343
where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the
344344
new observed value.
345345
346-
Parameters
347-
----------
346+
Parameters::
347+
348348
num_features: int
349349
``C`` from an expected input of size ``(B, H, W, D, C)``.
350350
axis: int, tuple, list
@@ -370,8 +370,8 @@ class BatchNorm3d(BatchNorm):
370370
Specifies how devices are grouped. Valid
371371
only within ``jax.pmap`` collectives.
372372
373-
References
374-
----------
373+
References::
374+
375375
.. [1] Ioffe, Sergey and Christian Szegedy. “Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift.” ArXiv abs/1502.03167 (2015): n. pag.
376376
377377
"""
@@ -422,8 +422,8 @@ class LayerNorm(Layer):
422422
scale and bias to a whole example/whole channel, please use GroupNorm/
423423
InstanceNorm.
424424
425-
Parameters
426-
----------
425+
Parameters::
426+
427427
normalized_shape: int, sequence of int
428428
The input shape from an expected input of size
429429
@@ -444,8 +444,8 @@ class LayerNorm(Layer):
444444
has learnable per-element affine parameters initialized to ones (for weights)
445445
and zeros (for biases). Default: ``True``.
446446
447-
Examples
448-
--------
447+
Examples::
448+
449449
>>> import brainpy as bp
450450
>>> import brainpy.math as bm
451451
>>>
@@ -519,8 +519,8 @@ class GroupNorm(Layer):
519519
The shape of the data should be (b, d1, d2, ..., c), where `d` denotes the batch
520520
size and `c` denotes the feature (channel) size.
521521
522-
Parameters
523-
----------
522+
Parameters::
523+
524524
num_groups: int
525525
The number of groups. It should be a factor of the number of channels.
526526
num_channels: int
@@ -536,8 +536,8 @@ class GroupNorm(Layer):
536536
scale_initializer: Initializer, ArrayType, Callable
537537
An initializer generating the original scaling matrix
538538
539-
Examples
540-
--------
539+
Examples::
540+
541541
>>> import brainpy as bp
542542
>>> import brainpy.math as bm
543543
>>> input = bm.random.randn(20, 10, 10, 6)
@@ -598,8 +598,8 @@ class InstanceNorm(GroupNorm):
598598
This layer normalizes the data within each feature. It can be regarded as
599599
a group normalization layer in which `group_size` equals to 1.
600600
601-
Parameters
602-
----------
601+
Parameters::
602+
603603
num_channels: int
604604
The number of channels expected in input.
605605
epsilon: float

brainpy/_src/dyn/synapses/delay_couplings.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
class DelayCoupling(Projection):
2323
"""Delay coupling.
2424
25-
Parameters
26-
----------
25+
Parameters::
26+
2727
delay_var: Variable
2828
The delay variable.
2929
var_to_output: Variable, sequence of Variable
@@ -121,9 +121,8 @@ class DiffusiveCoupling(DelayCoupling):
121121
target_var += coupling
122122
123123
124-
Examples
125-
--------
126-
124+
Examples::
125+
127126
>>> import brainpy as bp
128127
>>> from brainpy import rates
129128
>>> areas = bp.rates.FHN(80, x_ou_sigma=0.01, y_ou_sigma=0.01, name='fhn')
@@ -132,8 +131,8 @@ class DiffusiveCoupling(DelayCoupling):
132131
>>> initial_delay_data=bp.init.Uniform(0, 0.05))
133132
>>> net = bp.Network(areas, conn)
134133
135-
Parameters
136-
----------
134+
Parameters::
135+
137136
coupling_var1: Variable
138137
The first coupling variable, used for delay.
139138
coupling_var2: Variable
@@ -227,8 +226,8 @@ class AdditiveCoupling(DelayCoupling):
227226
coupling = g * delayed_coupling_var
228227
target_var += coupling
229228
230-
Parameters
231-
----------
229+
Parameters::
230+
232231
coupling_var: Variable
233232
The coupling variable, used for delay.
234233
var_to_output: Variable, sequence of Variable

brainpy/_src/dynold/neurons/fractional_models.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,22 @@ class FractionalFHR(FractionalNeuron):
6060
relatively fixed time of bursting duration. With the increasing of :math:`a`, the
6161
interburst intervals become shorter and periodic bursting changes to tonic spiking.
6262
63-
Examples
64-
--------
65-
63+
Examples::
64+
6665
- [(Mondal, et, al., 2019): Fractional-order FitzHugh-Rinzel bursting neuron model](https://brainpy-examples.readthedocs.io/en/latest/neurons/2019_Fractional_order_FHR_model.html)
6766
6867
69-
Parameters
70-
----------
68+
Parameters::
69+
7170
size: int, sequence of int
7271
The size of the neuron group.
7372
alpha: float, tensor
7473
The fractional order.
7574
num_memory: int
7675
The total number of the short memory.
7776
78-
References
79-
----------
77+
References::
78+
8079
.. [1] Mondal, A., Sharma, S.K., Upadhyay, R.K. *et al.* Firing activities of a fractional-order FitzHugh-Rinzel bursting neuron model and its coupled dynamics. *Sci Rep* **9,** 15721 (2019). https://doi.org/10.1038/s41598-019-52061-4
8180
"""
8281

@@ -223,14 +222,13 @@ class FractionalIzhikevich(FractionalNeuron):
223222
in mV. When the spike reaches its peak value, the membrane voltage :math:`v` and the
224223
recovery variable :math:`u` are reset according to the above condition.
225224
226-
Examples
227-
--------
228-
225+
Examples::
226+
229227
- [(Teka, et. al, 2018): Fractional-order Izhikevich neuron model](https://brainpy-examples.readthedocs.io/en/latest/neurons/2018_Fractional_Izhikevich_model.html)
230228
231229
232-
References
233-
----------
230+
References::
231+
234232
.. [10] Teka, Wondimu W., Ranjit Kumar Upadhyay, and Argha Mondal. "Spiking and
235233
bursting patterns of fractional-order Izhikevich model." Communications
236234
in Nonlinear Science and Numerical Simulation 56 (2018): 161-176.

brainpy/_src/dynsys.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class DynamicalSystem(bm.BrainPyObject, DelayRegister, SupportInputProj):
6262
- ``.update_local_delays()``
6363
- ``.reset_local_delays()``
6464
65-
Parameters
66-
----------
65+
Parameters::
66+
6767
name : optional, str
6868
The name of the dynamical system.
6969
mode: optional, Mode
@@ -431,9 +431,8 @@ def __call__(self, *args, **kwargs):
431431
def __rrshift__(self, other):
432432
"""Support using right shift operator to call modules.
433433
434-
Examples
435-
--------
436-
434+
Examples::
435+
437436
>>> import brainpy as bp
438437
>>> x = bp.math.random.rand((10, 10))
439438
>>> l = bp.layers.Activation(bm.tanh)
@@ -515,9 +514,8 @@ class Sequential(DynamicalSystem, SupportAutoDelay, Container):
515514
On the other hand, the layers in a ``Sequential`` are connected
516515
in a cascading way.
517516
518-
Examples
519-
--------
520-
517+
Examples::
518+
521519
>>> import brainpy as bp
522520
>>> import brainpy.math as bm
523521
>>>

0 commit comments

Comments
 (0)