"git@developer.sourcefind.cn:OpenDAS/ktransformers.git" did not exist on "0da3792b2770643d5bbf0b8f5071b573097453f0"
Unverified Commit 68318cc1 authored by Caroline Chen's avatar Caroline Chen Committed by GitHub
Browse files

Update CONTRIBUTING with doc conventions (#1898)

parent 7a0d866e
...@@ -138,27 +138,37 @@ The built docs should now be available in `docs/build/html` ...@@ -138,27 +138,37 @@ The built docs should now be available in `docs/build/html`
## Conventions ## Conventions
As a good software development practice, we try to stick to existing variable As a good software development practice, we try to stick to existing variable
names and shape (for tensors). names and shape (for tensors), and maintain consistent docstring standards.
The following are some of the conventions that we follow. The following are some of the conventions that we follow.
- We use an ellipsis "..." as a placeholder for the rest of the dimensions of a - Tensor
tensor, e.g. optional batching and channel dimensions. If batching, the - We use an ellipsis "..." as a placeholder for the rest of the dimensions of a
"batch" dimension should come in the first diemension. tensor, e.g. optional batching and channel dimensions. If batching, the
- Tensors are assumed to have "channel" dimension coming before the "time" "batch" dimension should come in the first diemension.
dimension. The bins in frequency domain (freq and mel) are assumed to come - Tensors are assumed to have "channel" dimension coming before the "time"
before the "time" dimension but after the "channel" dimension. These dimension. The bins in frequency domain (freq and mel) are assumed to come
ordering makes the tensors consistent with PyTorch's dimensions. before the "time" dimension but after the "channel" dimension. These
- For size names, the prefix `n_` is used (e.g. "a tensor of size (`n_freq`, ordering makes the tensors consistent with PyTorch's dimensions.
`n_mels`)") whereas dimension names do not have this prefix (e.g. "a tensor of - For size names, the prefix `n_` is used (e.g. "a tensor of size (`n_freq`,
dimension (channel, time)") `n_mels`)") whereas dimension names do not have this prefix (e.g. "a tensor of
dimension (channel, time)")
- Docstring
- Tensor dimensions are enclosed with single backticks.
``waveform (Tensor): Tensor of audio of dimension `(..., time)` ``
- Parameter type for variable of type `T` with a default value: `(T, optional)`
- Parameter type for variable of type `Optional[T]`: `(T or None)`
- Return type for a tuple or list of known elements:
`(element1, element2)` or `[element1, element2]`
- Return type for a tuple or list with an arbitrary number of elements
of type T: `Tuple[T]` or `List[T]`
Here are some of the examples of commonly used variables with thier names, Here are some of the examples of commonly used variables with thier names,
meanings, and shapes (or units): meanings, and shapes (or units):
* `waveform`: a tensor of audio samples with dimensions (..., channel, time) * `waveform`: a tensor of audio samples with dimensions `(..., channel, time)`
* `sample_rate`: the rate of audio dimensions (samples per second) * `sample_rate`: the rate of audio dimensions `(samples per second)`
* `specgram`: a tensor of spectrogram with dimensions (..., channel, freq, time) * `specgram`: a tensor of spectrogram with dimensions `(..., channel, freq, time)`
* `mel_specgram`: a mel spectrogram with dimensions (..., channel, mel, time) * `mel_specgram`: a mel spectrogram with dimensions `(..., channel, mel, time)`
* `hop_length`: the number of samples between the starts of consecutive frames * `hop_length`: the number of samples between the starts of consecutive frames
* `n_fft`: the number of Fourier bins * `n_fft`: the number of Fourier bins
* `n_mels`, `n_mfcc`: the number of mel and MFCC bins * `n_mels`, `n_mfcc`: the number of mel and MFCC bins
......
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