Unverified Commit 5efb13e3 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

DOC Document undocumented parameters and add CI check(#1248)

parent a7e93c15
...@@ -577,6 +577,18 @@ jobs: ...@@ -577,6 +577,18 @@ jobs:
target=${tag:-master} target=${tag:-master}
~/workspace/.circleci/build_docs/commit_docs.sh ~/workspace $target ~/workspace/.circleci/build_docs/commit_docs.sh ~/workspace $target
docstring_parameters_sync:
<<: *binary_common
docker:
- image: circleci/python:3.8
steps:
- checkout
- run:
name: Check parameters docstring sync
command: |
pip install --user pydocstyle
pydocstyle torchaudio
workflows: workflows:
build: build:
jobs: jobs:
...@@ -678,6 +690,11 @@ workflows: ...@@ -678,6 +690,11 @@ workflows:
python_version: '3.8' python_version: '3.8'
requires: requires:
- build_docs - build_docs
- docstring_parameters_sync:
name: docstring_parameters_sync
python_version: '3.8'
requires:
- binary_linux_wheel_py3.8
unittest: unittest:
jobs: jobs:
- download_third_parties_nix: - download_third_parties_nix:
......
...@@ -577,6 +577,18 @@ jobs: ...@@ -577,6 +577,18 @@ jobs:
target=${tag:-master} target=${tag:-master}
~/workspace/.circleci/build_docs/commit_docs.sh ~/workspace $target ~/workspace/.circleci/build_docs/commit_docs.sh ~/workspace $target
docstring_parameters_sync:
<<: *binary_common
docker:
- image: circleci/python:3.8
steps:
- checkout
- run:
name: Check parameters docstring sync
command: |
pip install --user pydocstyle
pydocstyle torchaudio
workflows: workflows:
build: build:
jobs: jobs:
......
...@@ -36,6 +36,8 @@ def build_workflows(prefix='', upload=False, filter_branch=None, indentation=6): ...@@ -36,6 +36,8 @@ def build_workflows(prefix='', upload=False, filter_branch=None, indentation=6):
# Build on every pull request, but upload only on nightly and tags # Build on every pull request, but upload only on nightly and tags
w += build_doc_job(None) w += build_doc_job(None)
w += upload_doc_job('nightly') w += upload_doc_job('nightly')
w += docstring_parameters_sync_job(None)
return indent(indentation, w) return indent(indentation, w)
...@@ -100,6 +102,18 @@ def upload_doc_job(filter_branch): ...@@ -100,6 +102,18 @@ def upload_doc_job(filter_branch):
return [{"upload_docs": job}] return [{"upload_docs": job}]
def docstring_parameters_sync_job(filter_branch):
job = {
"name": "docstring_parameters_sync",
"python_version": "3.8",
"requires": ["binary_linux_wheel_py3.8", ],
}
if filter_branch:
job["filters"] = gen_filter_branch_tree(filter_branch)
return [{"docstring_parameters_sync": job}]
def generate_base_workflow(base_workflow_name, python_version, filter_branch, os_type, btype): def generate_base_workflow(base_workflow_name, python_version, filter_branch, os_type, btype):
d = { d = {
......
...@@ -63,7 +63,7 @@ class WSJ0Mix(Dataset): ...@@ -63,7 +63,7 @@ class WSJ0Mix(Dataset):
def __getitem__(self, key: int) -> SampleType: def __getitem__(self, key: int) -> SampleType:
"""Load the n-th sample from the dataset. """Load the n-th sample from the dataset.
Args: Args:
n (int): The index of the sample to be loaded key (int): The index of the sample to be loaded
Returns: Returns:
tuple: ``(sample_rate, mix_waveform, list_of_source_waveforms)`` tuple: ``(sample_rate, mix_waveform, list_of_source_waveforms)``
""" """
......
[pydocstyle]
select = D417 # Missing argument descriptions in the docstring
...@@ -18,11 +18,10 @@ def run_kaldi(command, input_type, input_value): ...@@ -18,11 +18,10 @@ def run_kaldi(command, input_type, input_value):
"""Run provided Kaldi command, pass a tensor and get the resulting tensor """Run provided Kaldi command, pass a tensor and get the resulting tensor
Args: Args:
input_type: str command (list of str): The command with arguments
'ark' or 'scp' input_type (str): 'ark' or 'scp'
input_value: input_value (Tensor for 'ark', string for 'scp'): The input to pass.
Tensor for 'ark' Must be a path to an audio file for 'scp'.
string for 'scp' (path to an audio file)
""" """
import kaldi_io import kaldi_io
......
...@@ -41,7 +41,8 @@ def deprecated(direction: str, version: Optional[str] = None): ...@@ -41,7 +41,8 @@ def deprecated(direction: str, version: Optional[str] = None):
"""Decorator to add deprecation message """Decorator to add deprecation message
Args: Args:
direction: Migration steps to be given to users. direction (str): Migration steps to be given to users.
version (str or int): The version when the object will be removed
""" """
def decorator(func): def decorator(func):
......
...@@ -240,15 +240,14 @@ def save( ...@@ -240,15 +240,14 @@ def save(
This functionalso handles ``pathlib.Path`` objects, but is annotated as ``str`` This functionalso handles ``pathlib.Path`` objects, but is annotated as ``str``
for the consistency with "sox_io" backend, which has a restriction on type annotation for the consistency with "sox_io" backend, which has a restriction on type annotation
for TorchScript compiler compatiblity. for TorchScript compiler compatiblity.
tensor (torch.Tensor): Audio data to save. must be 2D tensor. src (torch.Tensor): Audio data to save. must be 2D tensor.
sample_rate (int): sampling rate sample_rate (int): sampling rate
channels_first (bool): channels_first (bool): If ``True``, the given tensor is interpreted as ``[channel, time]``,
If ``True``, the given tensor is interpreted as ``[channel, time]``,
otherwise ``[time, channel]``. otherwise ``[time, channel]``.
compression (Optional[float]): compression (Optional[float]): Not used.
Not used. It is here only for interface compatibility reson with "sox_io" backend. It is here only for interface compatibility reson with "sox_io" backend.
format (str, optional): format (str, optional): Output audio format.
Output audio format. This is required when the output audio format cannot be infered from This is required when the output audio format cannot be infered from
``filepath``, (such as file extension or ``name`` attribute of the given file object). ``filepath``, (such as file extension or ``name`` attribute of the given file object).
""" """
if src.ndim != 2: if src.ndim != 2:
......
...@@ -205,16 +205,15 @@ def save( ...@@ -205,16 +205,15 @@ def save(
and corresponding codec libraries such as ``libmad`` or ``libmp3lame`` etc. and corresponding codec libraries such as ``libmad`` or ``libmp3lame`` etc.
Args: Args:
filepath (str or pathlib.Path): filepath (str or pathlib.Path): Path to save file.
Path to save file. This function also handles ``pathlib.Path`` objects, but is annotated This function also handles ``pathlib.Path`` objects, but is annotated
as ``str`` for TorchScript compiler compatibility. as ``str`` for TorchScript compiler compatibility.
tensor (torch.Tensor): Audio data to save. must be 2D tensor. src (torch.Tensor): Audio data to save. must be 2D tensor.
sample_rate (int): sampling rate sample_rate (int): sampling rate
channels_first (bool): channels_first (bool): If ``True``, the given tensor is interpreted as ``[channel, time]``,
If ``True``, the given tensor is interpreted as ``[channel, time]``,
otherwise ``[time, channel]``. otherwise ``[time, channel]``.
compression (Optional[float]): compression (Optional[float]): Used for formats other than WAV.
Used for formats other than WAV. This corresponds to ``-C`` option of ``sox`` command. This corresponds to ``-C`` option of ``sox`` command.
* | ``MP3``: Either bitrate (in ``kbps``) with quality factor, such as ``128.2``, or * | ``MP3``: Either bitrate (in ``kbps``) with quality factor, such as ``128.2``, or
| VBR encoding with quality factor such as ``-4.2``. Default: ``-4.5``. | VBR encoding with quality factor such as ``-4.2``. Default: ``-4.5``.
...@@ -224,11 +223,10 @@ def save( ...@@ -224,11 +223,10 @@ def save(
| and lowest quality. Default: ``3``. | and lowest quality. Default: ``3``.
See the detail at http://sox.sourceforge.net/soxformat.html. See the detail at http://sox.sourceforge.net/soxformat.html.
format (str, optional): format (str, optional): Output audio format.
Output audio format. This is required when the output audio format cannot be infered from This is required when the output audio format cannot be infered from
``filepath``, (such as file extension or ``name`` attribute of the given file object). ``filepath``, (such as file extension or ``name`` attribute of the given file object).
dtype (str, optional) dtype (str, optional): Output tensor dtype.
Output tensor dtype.
Valid values: ``"uint8", "int16", "int32", "float32", "float64", None`` Valid values: ``"uint8", "int16", "int32", "float32", "float64", None``
``dtype=None`` means no conversion is performed. ``dtype=None`` means no conversion is performed.
``dtype`` parameter is only effective for ``float32`` Tensor. ``dtype`` parameter is only effective for ``float32`` Tensor.
......
...@@ -446,7 +446,7 @@ def _apply_probability_distribution( ...@@ -446,7 +446,7 @@ def _apply_probability_distribution(
or Gaussian curve, typical of dither generated by analog sources. or Gaussian curve, typical of dither generated by analog sources.
Args: Args:
waveform (Tensor): Tensor of audio of dimension (..., time) waveform (Tensor): Tensor of audio of dimension (..., time)
probability_density_function (str, optional): The density function of a density_function (str, optional): The density function of a
continuous random variable (Default: ``"TPDF"``) continuous random variable (Default: ``"TPDF"``)
Options: Triangular Probability Density Function - `TPDF` Options: Triangular Probability Density Function - `TPDF`
Rectangular Probability Density Function - `RPDF` Rectangular Probability Density Function - `RPDF`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment