Skip to content

Commit

Permalink
standardize docstrings using numpydoc format
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Jul 26, 2022
1 parent 30f369c commit 3e9fbd9
Show file tree
Hide file tree
Showing 17 changed files with 190 additions and 149 deletions.
36 changes: 18 additions & 18 deletions neo/core/analogsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,13 @@ def time_shift(self, t_shift):
"""
Shifts a :class:`AnalogSignal` to start at a new time.
Parameters:
-----------
Parameters
----------
t_shift: Quantity (time)
Amount of time by which to shift the :class:`AnalogSignal`.
Returns:
--------
Returns
-------
new_sig: :class:`AnalogSignal`
New instance of a :class:`AnalogSignal` object starting at t_shift later than the
original :class:`AnalogSignal` (the original :class:`AnalogSignal` is not modified).
Expand Down Expand Up @@ -538,19 +538,19 @@ def downsample(self, downsampling_factor, **kwargs):
arguments, except for specifying the axis of resampling, which is fixed to the first axis
here.
Parameters:
-----------
downsampling_factor: integer
Parameters
----------
downsampling_factor: int
Factor used for decimation of samples. Scipy recommends to call decimate multiple times
for downsampling factors higher than 13 when using IIR downsampling (default).
Returns:
--------
Returns
-------
downsampled_signal: :class:`AnalogSignal`
New instance of a :class:`AnalogSignal` object containing the resampled data points.
The original :class:`AnalogSignal` is not modified.
Note:
Notes
-----
For resampling the signal with a fixed number of samples, see `resample` method.
"""
Expand Down Expand Up @@ -581,19 +581,19 @@ def resample(self, sample_count, **kwargs):
arguments, except for specifying the axis of resampling which is fixed to the first axis
here, and the sample positions. .
Parameters:
-----------
sample_count: integer
Parameters
----------
sample_count: int
Number of desired samples. The resulting signal starts at the same sample as the
original and is sampled regularly.
Returns:
--------
Returns
-------
resampled_signal: :class:`AnalogSignal`
New instance of a :class:`AnalogSignal` object containing the resampled data points.
The original :class:`AnalogSignal` is not modified.
Note:
Notes
-----
For reducing the number of samples to a fraction of the original, see `downsample` method
"""
Expand Down Expand Up @@ -625,8 +625,8 @@ def rectify(self, **kwargs):
This method is a wrapper of numpy.absolute() and accepts the same set of keyword
arguments.
Returns:
--------
Returns
-------
resampled_signal: :class:`AnalogSignal`
New instance of a :class:`AnalogSignal` object containing the rectified data points.
The original :class:`AnalogSignal` is not modified.
Expand Down
26 changes: 16 additions & 10 deletions neo/core/dataobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@ def _normalize_array_annotations(value, length):
Recursively check that value is either an array or list containing only "simple" types
(number, string, date/time) or is a dict of those.
Args:
:value: (np.ndarray, list or dict) value to be checked for consistency
:length: (int) required length of the array annotation
Returns:
np.ndarray The array_annotations from value in correct form
Raises:
ValueError: In case value is not accepted as array_annotation(s)
Parameters
----------
value : np.ndarray or list or dict
Value to be checked for consistency.
length : int
Required length of the array annotation.
Returns
-------
np.ndarray
The array_annotations from value in correct form
Raises
------
ValueError
In case value is not accepted as array_annotation(s)
"""

# First stage, resolve dict of annotations into single annotations
Expand Down
8 changes: 4 additions & 4 deletions neo/core/epoch.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ def time_shift(self, t_shift):
"""
Shifts an :class:`Epoch` by an amount of time.
Parameters:
-----------
Parameters
----------
t_shift: Quantity (time)
Amount of time by which to shift the :class:`Epoch`.
Returns:
--------
Returns
-------
epoch: :class:`Epoch`
New instance of an :class:`Epoch` object starting at t_shift later than the
original :class:`Epoch` (the original :class:`Epoch` is not modified).
Expand Down
8 changes: 4 additions & 4 deletions neo/core/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ def time_shift(self, t_shift):
"""
Shifts an :class:`Event` by an amount of time.
Parameters:
-----------
Parameters
----------
t_shift: Quantity (time)
Amount of time by which to shift the :class:`Event`.
Returns:
--------
Returns
-------
epoch: Event
New instance of an :class:`Event` object starting at t_shift later than the
original :class:`Event` (the original :class:`Event` is not modified).
Expand Down
18 changes: 9 additions & 9 deletions neo/core/irregularlysampledsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,14 @@ def resample(self, sample_count, **kwargs):
arguments, except for specifying the axis of resampling which is fixed to the first axis
here, and the sample positions. .
Parameters:
-----------
sample_count: integer
Parameters
----------
sample_count: int
Number of desired samples. The resulting signal starts at the same sample as the
original and is sampled regularly.
Returns:
--------
Returns
-------
resampled_signal: :class:`AnalogSignal`
New instance of a :class:`AnalogSignal` object containing the resampled data points.
The original :class:`AnalogSignal` is not modified.
Expand Down Expand Up @@ -431,13 +431,13 @@ def time_shift(self, t_shift):
"""
Shifts a :class:`IrregularlySampledSignal` to start at a new time.
Parameters:
-----------
Parameters
----------
t_shift: Quantity (time)
Amount of time by which to shift the :class:`IrregularlySampledSignal`.
Returns:
--------
Returns
-------
new_sig: :class:`SpikeTrain`
New instance of a :class:`IrregularlySampledSignal` object
starting at t_shift later than the original :class:`IrregularlySampledSignal`
Expand Down
15 changes: 6 additions & 9 deletions neo/core/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,22 @@ def time_slice(self, t_start=None, t_stop=None, reset_time=False, **kwargs):
Creates a time slice of a Segment containing slices of all child
objects.
Parameters:
-----------
Parameters
----------
t_start: Quantity
Starting time of the sliced time window.
t_stop: Quantity
Stop time of the sliced time window.
reset_time: bool
reset_time: bool, optional, default: False
If True the time stamps of all sliced objects are set to fall
in the range from t_start to t_stop.
If False, original time stamps are retained.
Default is False.
Keyword Arguments:
------------------
**kwargs
Additional keyword arguments used for initialization of the sliced
Segment object.
Returns:
--------
Returns
-------
subseg: Segment
Temporal slice of the original Segment from t_start to t_stop.
"""
Expand Down
8 changes: 4 additions & 4 deletions neo/core/spiketrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,13 @@ def time_shift(self, t_shift):
"""
Shifts a :class:`SpikeTrain` to start at a new time.
Parameters:
-----------
Parameters
----------
t_shift: Quantity (time)
Amount of time by which to shift the :class:`SpikeTrain`.
Returns:
--------
Returns
-------
spiketrain: :class:`SpikeTrain`
New instance of a :class:`SpikeTrain` object starting at t_shift later than the
original :class:`SpikeTrain` (the original :class:`SpikeTrain` is not modified).
Expand Down
11 changes: 7 additions & 4 deletions neo/io/axonio.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class AxonIO(AxonRawIO, BaseFromRaw):
- `AxonIO._sampling_rate`
The current AxonIO.read_protocol() method utilizes a subset of these.
In particular I know it doesn't consider `nDigitalEnable`, `EpochInfo`, or `nActiveDACChannel` and it doesn't account
In particular I know it doesn't consider `nDigitalEnable`, `EpochInfo`, or `nActiveDACChannel` and it doesn't account
for different types of Epochs offered by Clampex/pClamp other than discrete steps (such as ramp, pulse train, etc and
encoded by `nEpochType` in the EpochInfoPerDAC section). I'm currently parsing a superset of the properties used
encoded by `nEpochType` in the EpochInfoPerDAC section). I'm currently parsing a superset of the properties used
by read_protocol() in my analysis scripts, but that code still doesn't parse the full information and isn't in a state
where it could be committed and I can't currently prioritize putting together all the code that would parse the full
set of data. The `AxonIO._axon_info['EpochInfo']` section doesn't currently exist.
Expand All @@ -47,8 +47,11 @@ def read_protocol(self):
Read the protocol waveform of the file, if present;
function works with ABF2 only. Protocols can be reconstructed
from the ABF1 header.
Returns: list of segments (one for every episode)
with list of analog signls (one for every DAC).
Returns
-------
segments : list of segments
Segments, one for every episode, with list of analog signls (one for every DAC).
"""
sigs_by_segments, sig_names, sig_units = self.read_raw_protocol()
segments = []
Expand Down
34 changes: 21 additions & 13 deletions neo/io/elphyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3811,8 +3811,10 @@ def read_block(self, lazy=False, ):
"""
Return :class:`Block`.
Parameters:
lazy : postpone actual reading of the file.
Parameters
----------
lazy : bool
Postpone actual reading of the file.
"""
assert not lazy, 'Do not support lazy'

Expand Down Expand Up @@ -4211,9 +4213,11 @@ def get_annotations_dict(self, annotations, prefix, items, name='', idx=0):
def read_segment(self, episode):
"""
Internal method used to return :class:`Segment` data to the main read method.
Parameters:
elphy_file : is the elphy object.
episode : number of elphy episode, roughly corresponding to a segment
Parameters
----------
episode : int
Number of elphy episode, roughly corresponding to a segment
"""
# print "name:",self.elphy_file.layout.get_episode_name(episode)
episode_name = self.elphy_file.layout.get_episode_name(episode)
Expand Down Expand Up @@ -4254,10 +4258,12 @@ def read_event(self, episode, evt):
Internal method used to return a list of elphy :class:`EventArray` acquired from event
channels.
Parameters:
elphy_file : is the elphy object.
episode : number of elphy episode, roughly corresponding to a segment.
evt : index of the event.
Parameters
----------
episode : int
Number of elphy episode, roughly corresponding to a segment.
evt : int
Index of the event.
"""
event = self.elphy_file.get_event(episode, evt)
neo_event = Event(
Expand All @@ -4270,10 +4276,12 @@ def read_spiketrain(self, episode, spk):
"""
Internal method used to return an elphy object :class:`SpikeTrain`.
Parameters:
elphy_file : is the elphy object.
episode : number of elphy episode, roughly corresponding to a segment.
spk : index of the spike array.
Parameters
----------
episode : int
Number of elphy episode, roughly corresponding to a segment.
spk : int
Index of the spike array.
"""
block = self.elphy_file.layout.episode_block(episode)
spike = self.elphy_file.get_spiketrain(episode, spk)
Expand Down
18 changes: 12 additions & 6 deletions neo/io/igorproio.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,21 @@ def key_value_string_parser(itemsep=";", kvsep=":"):
"""
Parses a string into a dict.
Arguments:
itemsep - character which separates items
kvsep - character which separates the key and value within an item
Returns:
Parameters
----------
itemsep : str
Character which separates items
kvsep : str
Character which separates the key and value within an item
Returns
-------
callable
a function which takes the string to be parsed as the sole argument
and returns a dict.
Example:
Examples
--------
>>> parse = key_value_string_parser(itemsep=";", kvsep=":")
>>> parse("a:2;b:3")
Expand Down
9 changes: 6 additions & 3 deletions neo/io/kwikio.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def read_block(self,
"""
Reads a block with segments and groups
Parameters:
Parameters
----------
get_waveforms: bool, default = False
Wether or not to get the waveforms
get_raw_data: bool, default = False
Expand Down Expand Up @@ -152,7 +153,8 @@ def read_analogsignal(self, model, units='uV', lazy=False):
"""
Reads analogsignals
Parameters:
Parameters
----------
units: str, default = "uV"
SI units of the raw trace according to voltage_gain given to klusta
"""
Expand All @@ -172,7 +174,8 @@ def read_spiketrain(self, cluster_id, model,
"""
Reads sorted spiketrains
Parameters:
Parameters
----------
get_waveforms: bool, default = False
Wether or not to get the waveforms
cluster_id: int,
Expand Down
Loading

0 comments on commit 3e9fbd9

Please sign in to comment.