Skip to content

Commit

Permalink
Convert docstrings to numpydoc style (#140)
Browse files Browse the repository at this point in the history
* add numpydoc dependency

* add numpydoc extension to conf.py

* fix typo

* convert docstrings to numpydoc style

* configure numpydoc to not show inherited members by default

* configure numpydoc to not show inherited members by default

* move examples to the __init__ docstring

* it's note plural !

* use sphinx.ext.napoleon instead of numpydoc

* remove vestiges of the numpy extension

* convert docstrings to numpydoc style
  • Loading branch information
rocco8773 authored Jul 9, 2024
1 parent 1acd0d1 commit d43f13f
Show file tree
Hide file tree
Showing 48 changed files with 1,949 additions and 1,215 deletions.
36 changes: 21 additions & 15 deletions bapsflib/_hdf/maps/controls/map_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@ class HDFMapControls(dict):
A dictionary that contains mapping objects for all the discovered
control devices in the HDF5 data group. The dictionary keys are
the names of the discovered control devices.
:Example:
>>> from bapsflib import lapd
>>> from bapsflib._hdf.maps import HDFMapControls
>>> f = lapd.File('sample.hdf5')
>>> # 'Raw data + config' is the LaPD HDF5 group name for the
... # group housing digitizer and control devices
... control_map = HDFMapControls(f['Raw data + config'])
>>> control_map['6K Compumotor']
<bapsflib._hdf.maps.controls.sixk.HDFMapControl6K>
"""

_defined_mapping_classes = {
Expand All @@ -62,7 +51,22 @@ class HDFMapControls(dict):

def __init__(self, data_group: h5py.Group):
"""
:param data_group: HDF5 group object
Parameters
----------
data_group : `h5py.Group`
HDF5 group object to be mapped
Examples
--------
>>> from bapsflib import lapd
>>> from bapsflib._hdf.maps import HDFMapControls
>>> f = lapd.File('sample.hdf5')
>>> # 'Raw data + config' is the LaPD HDF5 group name for the
... # group housing digitizer and control devices
... control_map = HDFMapControls(f['Raw data + config'])
>>> control_map['6K Compumotor']
<bapsflib._hdf.maps.controls.sixk.HDFMapControl6K>
"""
# condition data_group arg
if not isinstance(data_group, h5py.Group):
Expand Down Expand Up @@ -100,10 +104,12 @@ def __build_dict(self) -> Dict[str, ControlMap]:
"""
Discovers the HDF5 control devices and builds the dictionary
containing the control device mapping objects. This is the
dictionary used to initialize :code:`self`.
dictionary used to initialize ``self``.
:return: control device mapping dictionary
:rtype: dict
Returns
-------
dict
control device mapping dictionary
"""
control_dict = {}
for name in self.data_group_subgnames:
Expand Down
5 changes: 4 additions & 1 deletion bapsflib/_hdf/maps/controls/n5700ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class HDFMapControlN5700PS(HDFMapControlCLTemplate):

def __init__(self, group: h5py.Group):
"""
:param group: the HDF5 control device group
Parameters
----------
group : `h5py.Group`
the HDF5 control device group
"""
# initialize
HDFMapControlCLTemplate.__init__(self, group)
Expand Down
5 changes: 4 additions & 1 deletion bapsflib/_hdf/maps/controls/nixyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ class HDFMapControlNIXYZ(HDFMapControlTemplate):

def __init__(self, group: h5py.Group):
"""
:param group: the HDF5 control device group
Parameters
----------
group : `h5py.Group`
the HDF5 control device group
"""
HDFMapControlTemplate.__init__(self, group)

Expand Down
5 changes: 4 additions & 1 deletion bapsflib/_hdf/maps/controls/nixz.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ class HDFMapControlNIXZ(HDFMapControlTemplate):

def __init__(self, group: h5py.Group):
"""
:param group: the HDF5 control device group
Parameters
----------
group : `h5py.Group`
the HDF5 control device group
"""
HDFMapControlTemplate.__init__(self, group)

Expand Down
35 changes: 25 additions & 10 deletions bapsflib/_hdf/maps/controls/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class CLParse(object):

def __init__(self, command_list: Union[str, Iterable[str]]):
"""
:param command_list: the command list for a control device
:type command_list: list of strings
Parameters
----------
command_list : Union[str, Iterable[str]]
the command list for a control device
"""
super().__init__()

Expand All @@ -56,15 +58,26 @@ def __init__(self, command_list: Union[str, Iterable[str]]):

def apply_patterns(self, patterns: Union[str, Iterable[str]]):
"""
Applies a the REs defined in `patterns` to parse the command
list.
Applies the regular expressions defined in `patterns` to parse
the command list.
:param patterns: list or raw strings defining REs for parsing
Parameters
----------
patterns : Union[str, Iterable[str]]
list of raw strings defining regular expressions for parsing
the command list
:type patterns: str or list of strings
:return: (bool, dict)
:Example:
Returns
-------
bool
`True` if the command list is parsed successfully, `False`
otherwise.
dict
results from the command list parsing
Examples
--------
>>> # define a command list
>>> cl = ['VOLT 20.0', 'VOLT 25.0', 'VOLT 30.0']
Expand Down Expand Up @@ -275,9 +288,11 @@ def try_patterns(self, patterns: Union[str, Iterable[str]]):
Prints to the results of applying the REs in patterns to the
command list. Pretty print of :meth:`apply_patterns`.
:param patterns: list or raw strings defining REs for parsing
Parameters
----------
patterns : Union[str, Iterable[str]]
list of raw strings defining regular expressions for parsing
the command list
:type patterns: str or list of strings
"""
# TODO: clean method and format print better
#
Expand Down
27 changes: 22 additions & 5 deletions bapsflib/_hdf/maps/controls/sixk.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class HDFMapControl6K(HDFMapControlTemplate):

def __init__(self, group: h5py.Group):
"""
:param group: the HDF5 control device group
Parameters
----------
group : `h5py.Group`
the HDF5 control device group
"""
HDFMapControlTemplate.__init__(self, group)

Expand Down Expand Up @@ -212,8 +215,15 @@ def _analyze_motionlist(self, gname: str) -> dict:
Determines if `gname` matches the RE for a motion list group
name. It yes, then it gathers the motion list info.
:param str gname: name of potential motion list group
:return: dictionary with `'name'` and `'config'` keys
Parameters
----------
gname : `str`
name of potential motion list group
Returns
-------
dict
dictionary with ``'name'`` and ``'config'`` keys
"""
# Define RE pattern
# - A motion list group follows the naming scheme of:
Expand Down Expand Up @@ -340,8 +350,15 @@ def _analyze_probelist(self, gname: str) -> dict:
Determines if `gname` matches the RE for a probe list group
name. If yes, then it gathers the probe info.
:param str gname: name of potential probe list group
:return: dictionary with `'probe-id'` and `'config'` keys
Parameters
----------
gname : `str`
name of potential probe list group
Returns
-------
dict
dictionary with ``'probe-id'`` and ``'config'`` keys
"""
# Define RE pattern
# - A probe list group follows the naming scheme of:
Expand Down
Loading

0 comments on commit d43f13f

Please sign in to comment.