Skip to content

Commit 5e770b5

Browse files
authored
Add numpydoc pre-commit. (#3677)
* Follow numpydoc convention. * Follow numpydoc convention. * Fix doc.
1 parent 68d1c76 commit 5e770b5

File tree

9 files changed

+68
-37
lines changed

9 files changed

+68
-37
lines changed

.pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ repos:
6363
- id: blacken-docs
6464
additional_dependencies: [black==23.9.1]
6565

66+
67+
# - repo: https://github.com/numpy/numpydoc
68+
# rev: v1.6.0
69+
# hooks:
70+
# - id: numpydoc-validation
71+
6672
# - repo: https://github.com/pycqa/pydocstyle
6773
# rev: 6.1.1
6874
# hooks:

doc/source/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ def setup(app):
158158
"GL10", # reST directives {directives} must be followed by two colons
159159
# Return
160160
"RT04", # Return value description should start with a capital letter"
161-
"RT05", # Return value description should finish with "."'
161+
"RT05", # Return value description should finish with "."
162162
# Summary
163163
"SS01", # No summary found
164164
"SS02", # Summary does not start with a capital letter
165165
"SS03", # Summary does not end with a period
166166
"SS04", # Summary contains heading whitespaces
167167
"SS05", # Summary must start with infinitive verb, not third person
168168
# Parameters
169-
"PR10", # Parameter "{param_name}" requires a space before the colon '
169+
"PR10", # Parameter "{param_name}" requires a space before the colon
170170
# separating the parameter name and type",
171171
}
172172

pyaedt/application/Variables.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def decompose_variable_value(variable_value, full_variables={}):
263263
Returns
264264
-------
265265
tuples
266-
tuples made of the float value of the variable and the units exposed as a string.
266+
Tuples made of the float value of the variable and the units exposed as a string.
267267
"""
268268
# set default return values - then check for valid units
269269
float_value = variable_value
@@ -323,7 +323,7 @@ def generate_validation_errors(property_names, expected_settings, actual_setting
323323
List of property names.
324324
expected_settings : List[str]
325325
List of the expected settings.
326-
actual_settings: List[str]
326+
actual_settings : List[str]
327327
List of actual settings.
328328
329329
Returns
@@ -1761,7 +1761,7 @@ def __mul__(self, other):
17611761
"""Multiply the variable with a number or another variable and return a new object.
17621762
17631763
Parameters
1764-
---------
1764+
----------
17651765
other : numbers.Number or variable
17661766
Object to be multiplied.
17671767
@@ -1820,7 +1820,7 @@ def __add__(self, other):
18201820
"""Add the variable to another variable to return a new object.
18211821
18221822
Parameters
1823-
---------
1823+
----------
18241824
other : class:`pyaedt.application.Variables.Variable`
18251825
Object to be multiplied.
18261826
@@ -1861,7 +1861,7 @@ def __sub__(self, other):
18611861
"""Subtract another variable from the variable to return a new object.
18621862
18631863
Parameters
1864-
---------
1864+
----------
18651865
other : class:`pyaedt.application.Variables.Variable`
18661866
Object to be subtracted.
18671867
@@ -1904,7 +1904,7 @@ def __truediv__(self, other):
19041904
"""Divide the variable by a number or another variable to return a new object.
19051905
19061906
Parameters
1907-
---------
1907+
----------
19081908
other : numbers.Number or variable
19091909
Object by which to divide.
19101910
@@ -1948,7 +1948,7 @@ def __rtruediv__(self, other):
19481948
"""Divide another object by this object.
19491949
19501950
Parameters
1951-
---------
1951+
----------
19521952
other : numbers.Number or variable
19531953
Object to divide by.
19541954

pyaedt/emit_core/results/revision.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _load_revision(self):
7979
Load this revision.
8080
8181
Examples
82-
----------
82+
--------
8383
>>> aedtapp.results.revision.load_revision()
8484
"""
8585
if self.revision_loaded:
@@ -105,7 +105,7 @@ def result_mode_error():
105105
@pyaedt_function_handler()
106106
def get_interaction(self, domain):
107107
"""
108-
Creates a new interaction for a domain.
108+
Create a new interaction for a domain.
109109
110110
Parameters
111111
----------
@@ -118,7 +118,7 @@ def get_interaction(self, domain):
118118
Interaction object.
119119
120120
Examples
121-
----------
121+
--------
122122
>>> domain = aedtapp.results.interaction_domain()
123123
>>> rev.get_interaction(domain)
124124
@@ -146,7 +146,7 @@ def run(self, domain):
146146
Interaction object.
147147
148148
Examples
149-
----------
149+
--------
150150
>>> domain = aedtapp.results.interaction_domain()
151151
>>> rev.run(domain)
152152
@@ -180,7 +180,7 @@ def is_domain_valid(self, domain):
180180
``InteractionDomain`` object for constraining the analysis parameters.
181181
182182
Examples
183-
----------
183+
--------
184184
>>> domain = aedtapp.interaction_domain()
185185
>>> aedtapp.results.current_revision.is_domain_valid(domain)
186186
True
@@ -200,12 +200,12 @@ def get_instance_count(self, domain):
200200
``InteractionDomain`` object for constraining the analysis parameters.
201201
202202
Returns
203-
--------
203+
-------
204204
count : int
205205
Number of instances in the domain for the current revision.
206206
207207
Examples
208-
----------
208+
--------
209209
>>> domain = aedtapp.interaction_domain()
210210
>>> num_instances = aedtapp.results.current_revision.get_instance_count(domain)
211211
"""
@@ -228,7 +228,7 @@ def get_receiver_names(self):
228228
List of receiver names.
229229
230230
Examples
231-
----------
231+
--------
232232
>>> rxs = aedtapp.results.current_revision.get_reciver_names()
233233
"""
234234
if self.revision_loaded:
@@ -262,7 +262,7 @@ def get_interferer_names(self, interferer_type=None):
262262
List of interfering systems' names.
263263
264264
Examples
265-
----------
265+
--------
266266
>>> transmitters = aedtapp.results.current_revision.get_interferer_names(InterfererType.TRANSMITTERS)
267267
>>> emitters = aedtapp.results.current_revision.get_interferer_names(InterfererType.EMITTERS)
268268
>>> both = aedtapp.results.current_revision.get_interferer_names(InterfererType.TRANSMITTERS_AND_EMITTERS)
@@ -301,7 +301,7 @@ def get_band_names(self, radio_name, tx_rx_mode=None):
301301
List of ``tx`` or ``rx`` band/waveform names.
302302
303303
Examples
304-
----------
304+
--------
305305
>>> bands = aedtapp.results.current_revision.get_band_names('Bluetooth', TxRxMode.RX)
306306
>>> waveforms = aedtapp.results.current_revision.get_band_names('USB_3.x', TxRxMode.TX)
307307
"""
@@ -340,7 +340,7 @@ def get_active_frequencies(self, radio_name, band_name, tx_rx_mode, units=""):
340340
List of ``tx`` or ``rx`` radio/emitter frequencies.
341341
342342
Examples
343-
----------
343+
--------
344344
>>> freqs = aedtapp.results.current_revision.get_active_frequencies(
345345
'Bluetooth', 'Rx - Base Data Rate', TxRxMode.RX)
346346
"""
@@ -361,7 +361,7 @@ def notes(self):
361361
Add notes to the revision.
362362
363363
Examples
364-
----------
364+
--------
365365
>>> aedtapp.results.current_revision.notes = "Added a filter to the WiFi Radio."
366366
>>> aedtapp.results.current_revision.notes
367367
'Added a filter to the WiFi Radio.'
@@ -383,7 +383,7 @@ def n_to_1_limit(self):
383383
- A value of ``-1`` allows unlimited N to 1. (N is set to the maximum.)
384384
385385
Examples
386-
----------
386+
--------
387387
>>> aedtapp.results.current_revision.n_to_1_limit = 2**20
388388
>>> aedtapp.results.current_revision.n_to_1_limit
389389
1048576

pyaedt/hfss.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def _create_boundary(self, name, props, boundary_type):
321321
"""Create a boundary.
322322
323323
Parameters
324-
---------
324+
----------
325325
name : str
326326
Name of the boundary.
327327
props : list

pyaedt/maxwell.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ def _create_boundary(self, name, props, boundary_type):
22612261
"""Create a boundary.
22622262
22632263
Parameters
2264-
---------
2264+
----------
22652265
name : str
22662266
Name of the boundary.
22672267
props : list

pyaedt/modeler/modeler3d.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ def change_region_padding(self, padding_data, padding_type, direction=None, regi
13901390
``True`` if successful, else ``None``.
13911391
13921392
Examples
1393-
----------
1393+
--------
13941394
>>> import pyaedt
13951395
>>> app = pyaedt.Icepak()
13961396
>>> app.modeler.change_region_padding("10mm", padding_type="Absolute Offset", direction="-X")
@@ -1474,7 +1474,7 @@ def change_region_coordinate_system(self, region_cs="Global", region_name="Regio
14741474
``True`` if successful, else ``None``.
14751475
14761476
Examples
1477-
----------
1477+
--------
14781478
>>> import pyaedt
14791479
>>> app = pyaedt.Icepak()
14801480
>>> app.modeler.create_coordinate_system(origin=[1, 1, 1], name="NewCS")

pyaedt/modules/Boundary.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def targetcs(self):
225225
Returns
226226
-------
227227
str
228-
Native Component Coordinate System
228+
Native Component Coordinate System.
229229
"""
230230
if "TargetCS" in list(self.props.keys()):
231231
return self.props["TargetCS"]
@@ -3690,7 +3690,7 @@ def auto_update(self, b):
36903690
36913691
Parameters
36923692
----------
3693-
b: bool
3693+
b : bool
36943694
Whether to enable auto-update.
36953695
36963696
"""
@@ -3848,7 +3848,7 @@ def name(self, new_network_name):
38483848
38493849
Parameters
38503850
----------
3851-
new_network_name: str
3851+
new_network_name : str
38523852
New name of the network.
38533853
"""
38543854
bound_names = [b.name for b in self._app.boundaries]
@@ -3929,11 +3929,11 @@ def add_boundary_node(self, name, assignment_type, value):
39293929
39303930
Parameters
39313931
----------
3932-
name: str
3932+
name : str
39333933
Name of the node.
3934-
assignment_type: str
3934+
assignment_type : str
39353935
Type assignment. Options are ``"Power"`` and ``"Temperature"``.
3936-
value: str or float or dict
3936+
value : str or float or dict
39373937
String, float, or dictionary containing the value of the assignment.
39383938
If a float is passed the ``"W"`` or ``"cel"`` unit is used, depending on
39393939
the selection for the ``assignment_type`` parameter. If ``"Power"`
@@ -3943,7 +3943,7 @@ def add_boundary_node(self, name, assignment_type, value):
39433943
Returns
39443944
-------
39453945
bool
3946-
True if successful.
3946+
``True`` if successful.
39473947
39483948
Examples
39493949
--------
@@ -4082,7 +4082,7 @@ def add_nodes_from_dictionaries(self, nodes_dict):
40824082
Add nodes to the network from dictionary.
40834083
40844084
Parameters
4085-
-------
4085+
----------
40864086
nodes_dict : list or dict
40874087
A dictionary or list of dictionaries containing nodes to add to the network. Different
40884088
node types require different key and value pairs:
@@ -4431,8 +4431,8 @@ def props(self, props):
44314431
Set properties of the node.
44324432
44334433
Parameters
4434-
-------
4435-
props: dict
4434+
----------
4435+
props : dict
44364436
Node properties.
44374437
"""
44384438
self._props = props

pyproject.toml

+26-1
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,29 @@ testpaths = [
180180
"_unittest",
181181
]
182182

183-
183+
[tool.numpydoc_validation]
184+
checks = [
185+
"GL06", # Found unknown section
186+
"GL07", # Sections are in the wrong order.
187+
"GL08", # The object does not have a docstring
188+
"GL09", # Deprecation warning should precede extended summary
189+
"GL10", # reST directives {directives} must be followed by two colons
190+
# Return
191+
"RT04", # Return value description should start with a capital letter"
192+
"RT05", # Return value description should finish with "."
193+
# Summary
194+
"SS01", # No summary found
195+
"SS02", # Summary does not start with a capital letter
196+
"SS03", # Summary does not end with a period
197+
"SS04", # Summary contains heading whitespaces
198+
"SS05", # Summary must start with infinitive verb, not third person
199+
# Parameters
200+
"PR10", # Parameter "{param_name}" requires a space before the colon
201+
# separating the parameter name and type",
202+
]
203+
exclude = [
204+
'\.AEDTMessageManager.add_message$', # bad SS05
205+
'\.Modeler3D\.create_choke$', # bad RT05
206+
'\._unittest\', # missing docstring for tests
207+
'HistoryProps.', # bad RT05 because of the base class named OrderedDict
208+
]

0 commit comments

Comments
 (0)