Skip to content

Commit ed305cc

Browse files
committed
Organized docstrings a bit.
1 parent 5b928ef commit ed305cc

1 file changed

Lines changed: 36 additions & 22 deletions

File tree

rtanalysis/rtanalysis.py

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
1-
"""example function to analyze reaction times
2-
- given a data frame with RT and accuracy,
3-
compute mean RT for correct trials and mean accuracy
1+
"""Example class to analyze reaction times.
2+
3+
Given a data frame with RT and accuracy, compute mean RT for correct trials and
4+
mean accuracy.
45
"""
56
# %%
67
import pandas as pd
78

89

910
# %%
1011
class RTAnalysis:
11-
"""[summary]"""
12+
"""Response time (RT) analysis."""
1213

1314
def __init__(self, outlier_cutoff_sd=None):
14-
"""
15-
RT analysis
15+
"""Initialize a new RTAnalysis instance.
1616
17-
Parameters:
18-
-----------
19-
outlier_cutoff_sd: standard deviation cutoff for long RT outliers (default: no cutoff)
17+
Parameters
18+
----------
19+
outlier_cutoff_sd : float, optional
20+
Standard deviation cutoff for long RT outliers, by default None
2021
"""
2122
self.outlier_cutoff_sd = outlier_cutoff_sd
2223
self.meanrt_ = None
2324
self.meanacc_ = None
2425

2526
def fit(self, rt, accuracy, verbose=True):
26-
"""[summary]
27-
28-
Args:
29-
rt (Series of floats): response times for each trial
30-
accuracy (Series of booleans): accuracy for each trial
27+
"""Fit response time to accuracy.
28+
29+
Parameters
30+
----------
31+
rt : pd.Series
32+
Response time per trial
33+
accuracy : pd.Series
34+
Accuracy per trial
35+
verbose : bool, optional
36+
Whether to print verbose output or not, by default True
37+
38+
Raises
39+
------
40+
ValueError
41+
RT/accuracy length mismatch
42+
ValueError
43+
Accuracy is 0
3144
"""
32-
3345
rt = self._ensure_series_type(rt)
3446
accuracy = self._ensure_series_type(accuracy)
3547

@@ -62,16 +74,18 @@ def fit(self, rt, accuracy, verbose=True):
6274

6375
@staticmethod
6476
def _ensure_series_type(var):
65-
"""return variable as a pandas Series or raise exception if
66-
not possible
77+
"""Return variable as a pandas Series.
6778
68-
Args:
69-
var (array-like): variable to convert
79+
Parameters
80+
----------
81+
var : Iterable
82+
Variable to be converted
7083
71-
Returns:
72-
series (pandas Series): converted variable
84+
Returns
85+
-------
86+
pd.Series
87+
Variable values as a pandas Series
7388
"""
74-
7589
if type(var) is not pd.core.series.Series:
7690
var = pd.Series(var)
7791
return var

0 commit comments

Comments
 (0)