Skip to content

Commit 5efb13e

Browse files
authored
DOC Document undocumented parameters and add CI check(#1248)
1 parent a7e93c1 commit 5efb13e

File tree

10 files changed

+68
-26
lines changed

10 files changed

+68
-26
lines changed

.circleci/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,18 @@ jobs:
577577
target=${tag:-master}
578578
~/workspace/.circleci/build_docs/commit_docs.sh ~/workspace $target
579579
580+
docstring_parameters_sync:
581+
<<: *binary_common
582+
docker:
583+
- image: circleci/python:3.8
584+
steps:
585+
- checkout
586+
- run:
587+
name: Check parameters docstring sync
588+
command: |
589+
pip install --user pydocstyle
590+
pydocstyle torchaudio
591+
580592
workflows:
581593
build:
582594
jobs:
@@ -678,6 +690,11 @@ workflows:
678690
python_version: '3.8'
679691
requires:
680692
- build_docs
693+
- docstring_parameters_sync:
694+
name: docstring_parameters_sync
695+
python_version: '3.8'
696+
requires:
697+
- binary_linux_wheel_py3.8
681698
unittest:
682699
jobs:
683700
- download_third_parties_nix:

.circleci/config.yml.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,18 @@ jobs:
577577
target=${tag:-master}
578578
~/workspace/.circleci/build_docs/commit_docs.sh ~/workspace $target
579579

580+
docstring_parameters_sync:
581+
<<: *binary_common
582+
docker:
583+
- image: circleci/python:3.8
584+
steps:
585+
- checkout
586+
- run:
587+
name: Check parameters docstring sync
588+
command: |
589+
pip install --user pydocstyle
590+
pydocstyle torchaudio
591+
580592
workflows:
581593
build:
582594
jobs:

.circleci/regenerate.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def build_workflows(prefix='', upload=False, filter_branch=None, indentation=6):
3636
# Build on every pull request, but upload only on nightly and tags
3737
w += build_doc_job(None)
3838
w += upload_doc_job('nightly')
39+
w += docstring_parameters_sync_job(None)
40+
3941

4042
return indent(indentation, w)
4143

@@ -100,6 +102,18 @@ def upload_doc_job(filter_branch):
100102
return [{"upload_docs": job}]
101103

102104

105+
def docstring_parameters_sync_job(filter_branch):
106+
job = {
107+
"name": "docstring_parameters_sync",
108+
"python_version": "3.8",
109+
"requires": ["binary_linux_wheel_py3.8", ],
110+
}
111+
112+
if filter_branch:
113+
job["filters"] = gen_filter_branch_tree(filter_branch)
114+
return [{"docstring_parameters_sync": job}]
115+
116+
103117
def generate_base_workflow(base_workflow_name, python_version, filter_branch, os_type, btype):
104118

105119
d = {

examples/source_separation/utils/dataset/wsj0mix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __len__(self) -> int:
6363
def __getitem__(self, key: int) -> SampleType:
6464
"""Load the n-th sample from the dataset.
6565
Args:
66-
n (int): The index of the sample to be loaded
66+
key (int): The index of the sample to be loaded
6767
Returns:
6868
tuple: ``(sample_rate, mix_waveform, list_of_source_waveforms)``
6969
"""

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pydocstyle]
2+
select = D417 # Missing argument descriptions in the docstring

test/torchaudio_unittest/common_utils/kaldi_utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ def run_kaldi(command, input_type, input_value):
1818
"""Run provided Kaldi command, pass a tensor and get the resulting tensor
1919
2020
Args:
21-
input_type: str
22-
'ark' or 'scp'
23-
input_value:
24-
Tensor for 'ark'
25-
string for 'scp' (path to an audio file)
21+
command (list of str): The command with arguments
22+
input_type (str): 'ark' or 'scp'
23+
input_value (Tensor for 'ark', string for 'scp'): The input to pass.
24+
Must be a path to an audio file for 'scp'.
2625
"""
2726
import kaldi_io
2827

torchaudio/_internal/module_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def deprecated(direction: str, version: Optional[str] = None):
4141
"""Decorator to add deprecation message
4242
4343
Args:
44-
direction: Migration steps to be given to users.
44+
direction (str): Migration steps to be given to users.
45+
version (str or int): The version when the object will be removed
4546
"""
4647
def decorator(func):
4748

torchaudio/backend/_soundfile_backend.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,14 @@ def save(
240240
This functionalso handles ``pathlib.Path`` objects, but is annotated as ``str``
241241
for the consistency with "sox_io" backend, which has a restriction on type annotation
242242
for TorchScript compiler compatiblity.
243-
tensor (torch.Tensor): Audio data to save. must be 2D tensor.
243+
src (torch.Tensor): Audio data to save. must be 2D tensor.
244244
sample_rate (int): sampling rate
245-
channels_first (bool):
246-
If ``True``, the given tensor is interpreted as ``[channel, time]``,
245+
channels_first (bool): If ``True``, the given tensor is interpreted as ``[channel, time]``,
247246
otherwise ``[time, channel]``.
248-
compression (Optional[float]):
249-
Not used. It is here only for interface compatibility reson with "sox_io" backend.
250-
format (str, optional):
251-
Output audio format. This is required when the output audio format cannot be infered from
247+
compression (Optional[float]): Not used.
248+
It is here only for interface compatibility reson with "sox_io" backend.
249+
format (str, optional): Output audio format.
250+
This is required when the output audio format cannot be infered from
252251
``filepath``, (such as file extension or ``name`` attribute of the given file object).
253252
"""
254253
if src.ndim != 2:

torchaudio/backend/sox_io_backend.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,15 @@ def save(
205205
and corresponding codec libraries such as ``libmad`` or ``libmp3lame`` etc.
206206
207207
Args:
208-
filepath (str or pathlib.Path):
209-
Path to save file. This function also handles ``pathlib.Path`` objects, but is annotated
208+
filepath (str or pathlib.Path): Path to save file.
209+
This function also handles ``pathlib.Path`` objects, but is annotated
210210
as ``str`` for TorchScript compiler compatibility.
211-
tensor (torch.Tensor): Audio data to save. must be 2D tensor.
211+
src (torch.Tensor): Audio data to save. must be 2D tensor.
212212
sample_rate (int): sampling rate
213-
channels_first (bool):
214-
If ``True``, the given tensor is interpreted as ``[channel, time]``,
213+
channels_first (bool): If ``True``, the given tensor is interpreted as ``[channel, time]``,
215214
otherwise ``[time, channel]``.
216-
compression (Optional[float]):
217-
Used for formats other than WAV. This corresponds to ``-C`` option of ``sox`` command.
215+
compression (Optional[float]): Used for formats other than WAV.
216+
This corresponds to ``-C`` option of ``sox`` command.
218217
219218
* | ``MP3``: Either bitrate (in ``kbps``) with quality factor, such as ``128.2``, or
220219
| VBR encoding with quality factor such as ``-4.2``. Default: ``-4.5``.
@@ -224,11 +223,10 @@ def save(
224223
| and lowest quality. Default: ``3``.
225224
226225
See the detail at http://sox.sourceforge.net/soxformat.html.
227-
format (str, optional):
228-
Output audio format. This is required when the output audio format cannot be infered from
226+
format (str, optional): Output audio format.
227+
This is required when the output audio format cannot be infered from
229228
``filepath``, (such as file extension or ``name`` attribute of the given file object).
230-
dtype (str, optional)
231-
Output tensor dtype.
229+
dtype (str, optional): Output tensor dtype.
232230
Valid values: ``"uint8", "int16", "int32", "float32", "float64", None``
233231
``dtype=None`` means no conversion is performed.
234232
``dtype`` parameter is only effective for ``float32`` Tensor.

torchaudio/functional/filtering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def _apply_probability_distribution(
446446
or Gaussian curve, typical of dither generated by analog sources.
447447
Args:
448448
waveform (Tensor): Tensor of audio of dimension (..., time)
449-
probability_density_function (str, optional): The density function of a
449+
density_function (str, optional): The density function of a
450450
continuous random variable (Default: ``"TPDF"``)
451451
Options: Triangular Probability Density Function - `TPDF`
452452
Rectangular Probability Density Function - `RPDF`

0 commit comments

Comments
 (0)