Skip to content

Commit b1ee317

Browse files
author
Nicolas Legrand
authored
Use pydocstyle in pre-commit (#9)
* use pydocstyle in precommit * remove type annotation in docstrings and fix pydocstyle issues
1 parent 3897b11 commit b1ee317

File tree

10 files changed

+284
-275
lines changed

10 files changed

+284
-275
lines changed

.github/workflows/linting.yml

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,23 @@
11
name: Linting
22

3-
on: [push, pull_request]
4-
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- "*"
510
jobs:
6-
test:
11+
lint:
712
runs-on: ubuntu-latest
813
strategy:
914
matrix:
10-
python-version: [3.9]
15+
python-version: ["3.10"]
1116
steps:
12-
- uses: actions/checkout@v2
13-
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v2
15-
with:
16-
python-version: ${{ matrix.python-version }}
17-
- uses: actions/cache@v2
18-
name: Configure pip caching
19-
with:
20-
path: ~/.cache/pip
21-
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
22-
restore-keys: |
23-
${{ runner.os }}-pip-
24-
- name: Install dependencies
25-
run: |
26-
pip install -r requirements-tests.txt
27-
pip install isort flake8 black
28-
pip install mypy==0.982
29-
pip install types-setuptools
30-
- name: Run tests and coverage
31-
run: |
32-
mypy ./metadpy/ --ignore-missing-imports
33-
flake8 ./metadpy/
34-
black ./metadpy/
35-
isort ./metadpy/
17+
- uses: actions/checkout@v3
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Run lint
23+
uses: pre-commit/action@v3.0.0

.github/workflows/test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
name: Test
22

3-
on: [push, pull_request]
4-
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- "*"
510
jobs:
611
test:
712
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ repos:
2121
hooks:
2222
- id: mypy
2323
files: ^metadpy/
24-
args: [--ignore-missing-imports]
24+
args: [--ignore-missing-imports]
25+
- repo: https://github.com/pycqa/pydocstyle
26+
rev: 6.3.0
27+
hooks:
28+
- id: pydocstyle
29+
args: ['--ignore', 'D213,D100,D203,D104']
30+
files: ^metadpy/

metadpy/bayesian.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -107,58 +107,57 @@ def hmetad(
107107
num_chains: int = 4,
108108
**kwargs
109109
):
110-
"""Estimate parameters of the Bayesian meta-d' model with hyperparametes at the
111-
group level.
110+
"""Bayesian meta-d' model with hyperparametes at the group level.
112111
113112
Parameters
114113
----------
115-
data : :py:class:`pandas.DataFrame` | None
114+
data :
116115
Dataframe. Note that this function can also directly be used as a Pandas
117116
method, in which case this argument is no longer needed.
118-
nR_S1 : 1d array-like, list, string | None
117+
nR_S1 :
119118
Confience ratings (stimuli 1, correct and incorrect).
120-
nR_S2 : 1d array-like, list, string | None
119+
nR_S2 :
121120
Confience ratings (stimuli 2, correct and incorrect).
122-
stimuli : string | None
121+
stimuli :
123122
Name of the column containing the stimuli.
124-
accuracy : string | None
123+
accuracy :
125124
Name of the columns containing the accuracy.
126-
confidence : string | None
125+
confidence :
127126
Name of the column containing the confidence ratings.
128-
nRatings : int | None
127+
nRatings :
129128
Number of discrete ratings. If a continuous rating scale was used, and
130129
the number of unique ratings does not match `nRatings`, will convert to
131130
discrete ratings using :py:func:`metadpy.utils.discreteRatings`.
132-
within : string | None
131+
within :
133132
Name of column containing the within factor (condition comparison).
134-
between : string | None
133+
between :
135134
Name of column containing the between subject factor (group
136135
comparison).
137-
subject : string | None
136+
subject :
138137
Name of column containing the subject identifier (only required if a
139138
within-subject or a between-subject factor is provided).
140-
nbins : int
139+
nbins :
141140
If a continuous rating scale was using, `nbins` define the number of
142141
discrete ratings when converting using
143142
:py:func:`metadpy.utils.discreteRatings`. The default value is `4`.
144-
padding : boolean
143+
padding :
145144
If `True`, each response count in the output has the value of padAmount
146145
added to it. Padding cells is desirable if trial counts of 0 interfere
147146
with model fitting. If False, trial counts are not manipulated and 0s
148147
may be present in the response count output. Default value for padding
149148
is `False`.
150-
padAmount : float or None
149+
padAmount :
151150
The value to add to each response count if padCells is set to 1.
152151
Default value is 1/(2*nRatings)
153-
sample_model : boolean
152+
sample_model :
154153
If `False`, only the model is returned without sampling.
155-
output : str
154+
output :
156155
The kind of outpute expected. If `"model"`, will return the model function and
157156
the traces. If `"dataframe"`, will return a dataframe containing `d` (dprime),
158157
`c` (criterion), `meta_d` (the meta-d prime) and `m_ratio` (`meta_d/d`).
159-
num_samples : int
158+
num_samples :
160159
The number of samples per chains to draw (defaults to `1000`).
161-
num_chains : int
160+
num_chains :
162161
The number of chains (defaults to `4`).
163162
**kwargs : keyword arguments
164163
All keyword arguments are passed to `func::pymc.sampling.sample`.
@@ -167,16 +166,15 @@ def hmetad(
167166
-------
168167
If `output="model"`:
169168
170-
model : :py:class:`pymc.Model` instance
169+
model :
171170
The model PyMC as a :py:class:`pymc.Model`.
172-
traces : :py:class:`pymc.backends.base.MultiTrace` |
173-
:py:class:`arviz.InferenceData` | None
171+
traces :
174172
A `MultiTrace` or `ArviZ InferenceData` object that contains the samples. Only
175173
returned if `sample_model` is set to `True`, otherwise set to None.
176174
177175
or
178176
179-
results : pd.DataFrame
177+
results :
180178
If `output="dataframe"`, :py:class:`pandas.DataFrame` containing the values for
181179
the following variables:
182180
@@ -327,26 +325,27 @@ def extractParameters(
327325
328326
Parameters
329327
----------
330-
nR_S1, nR_S2 : 1d array-like or list
328+
nR_S1, nR_S2 :
331329
Total number of responses in each response category, conditional on
332330
presentation of S1 and S2. e.g. if `nR_S1 = [100 50 20 10 5 1]`, then
333331
when stimulus S1 was presented, the subject had the following response
334332
counts:
335-
* responded S1, rating=3 : 100 times
336-
* responded S1, rating=2 : 50 times
337-
* responded S1, rating=1 : 20 times
338-
* responded S2, rating=1 : 10 times
339-
* responded S2, rating=2 : 5 times
340-
* responded S2, rating=3 : 1 time
333+
* responded S1, rating=3 : 100 times
334+
* responded S1, rating=2 : 50 times
335+
* responded S1, rating=1 : 20 times
336+
* responded S2, rating=1 : 10 times
337+
* responded S2, rating=2 : 5 times
338+
* responded S2, rating=3 : 1 time
341339
342340
Return
343341
------
344-
data : dict
342+
data :
345343
Dictionary of rates and task parameters.
346344
347-
See also
345+
See Also
348346
--------
349347
hmetad
348+
350349
"""
351350
if isinstance(nR_S1, list):
352351
nR_S1 = np.array(nR_S1, dtype=float)

metadpy/datasets/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def load_dataset(dataset):
7-
"""Load simulated dataset
7+
"""Load simulated dataset.
88
99
Parameters
1010
----------
@@ -15,6 +15,7 @@ def load_dataset(dataset):
1515
-------
1616
df : :py:class:`pandas.DataFrame`
1717
Pandas dataframe.
18+
1819
"""
1920
return pd.read_csv(
2021
(

0 commit comments

Comments
 (0)