Skip to content

Commit

Permalink
Merge pull request #113 from sp-nitech/ruff
Browse files Browse the repository at this point in the history
Strip isort
  • Loading branch information
takenori-y authored Jan 30, 2025
2 parents b3554b2 + 9280fe7 commit b61b821
Show file tree
Hide file tree
Showing 139 changed files with 232 additions and 302 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
torch: 2.0.0
torchaudio: 2.0.1
- python: 3.12
torch: 2.5.1
torchaudio: 2.5.1
torch: 2.6.0
torchaudio: 2.6.0

steps:
- name: Clone
Expand All @@ -49,10 +49,10 @@ jobs:
run: make test

- name: Coverage
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
file: ./coverage.xml
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ doc-clean:
check: tool
. ./venv/bin/activate && python -m ruff check $(PROJECT) tests
. ./venv/bin/activate && python -m ruff format --check $(PROJECT) tests docs
. ./venv/bin/activate && python -m isort --check $(PROJECT) tests
. ./venv/bin/activate && python -m mdformat --check *.md
. ./venv/bin/activate && cd docs && python -m docstrfmt --check .
./venv/bin/codespell
./tools/taplo/taplo fmt --check *.toml
./tools/yamlfmt/yamlfmt --lint *.cff *.yml .github/workflows/*.yml

format: tool
. ./venv/bin/activate && python -m ruff check --fix $(PROJECT) tests
. ./venv/bin/activate && python -m ruff format $(PROJECT) tests docs
. ./venv/bin/activate && python -m isort $(PROJECT) tests
. ./venv/bin/activate && python -m mdformat *.md
. ./venv/bin/activate && cd docs && python -m docstrfmt .
./tools/taplo/taplo fmt *.toml
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

## Documentation

- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for a reference manual.
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for the reference manual.
- Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.

## Installation
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def fbank(x, n_channel, sample_rate, f_min=0, f_max=None, floor=1e-5, out_format
Minimum mel-filter bank output in linear scale.
out_format : ['y', 'yE', 'y,E']
`y` is mel-filber bank outpus and `E` is energy. If this is `yE`, the two output
`y` is mel-filber bank output and `E` is energy. If this is `yE`, the two output
tensors are concatenated and return the tensor instead of the tuple.
Returns
Expand Down Expand Up @@ -711,7 +711,7 @@ def freqt(c, out_order, alpha=0):
Order of output cepstrum, :math:`M_2`.
alpha : float in (-1, 1)
Frquency warping factor, :math:`\\alpha`.
Frequency warping factor, :math:`\\alpha`.
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/misc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
# limitations under the License. #
# ------------------------------------------------------------------------ #

from importlib import import_module
import logging
import math
from importlib import import_module

import numpy as np
import soundfile as sf
import torch
from torch import nn
import torch.nn.functional as F
import torchaudio
from torch import nn

UNVOICED_SYMBOL = 0
TWO_PI = math.tau
Expand Down
9 changes: 3 additions & 6 deletions diffsptk/modules/acr2csm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
# limitations under the License. #
# ------------------------------------------------------------------------ #

from scipy.special import comb
import torch
from torch import nn
import torch.nn.functional as F
from scipy.special import comb
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import hankel
from ..misc.utils import to
from ..misc.utils import vander
from ..misc.utils import check_size, hankel, to, vander
from .root_pol import PolynomialToRoots


Expand Down
5 changes: 2 additions & 3 deletions diffsptk/modules/ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from torch import nn

from ..misc.utils import UNVOICED_SYMBOL
from ..misc.utils import numpy_to_torch
from ..misc.utils import UNVOICED_SYMBOL, numpy_to_torch


class Aperiodicity(nn.Module):
Expand Down
5 changes: 2 additions & 3 deletions diffsptk/modules/b2mc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# ------------------------------------------------------------------------ #

import torch
from torch import nn
import torch.nn.functional as F
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
from ..misc.utils import check_size, to


class MLSADigitalFilterCoefficientsToMelCepstrum(nn.Module):
Expand Down
3 changes: 1 addition & 2 deletions diffsptk/modules/c2mpir.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import torch
from torch import nn

from ..misc.utils import cexp
from ..misc.utils import check_size
from ..misc.utils import cexp, check_size


class CepstrumToMinimumPhaseImpulseResponse(nn.Module):
Expand Down
3 changes: 1 addition & 2 deletions diffsptk/modules/c2ndps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import torch
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
from ..misc.utils import check_size, to


class CepstrumToNegativeDerivativeOfPhaseSpectrum(nn.Module):
Expand Down
5 changes: 2 additions & 3 deletions diffsptk/modules/chroma.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
from ..misc.utils import check_size, to


class ChromaFilterBankAnalysis(nn.Module):
Expand Down
9 changes: 3 additions & 6 deletions diffsptk/modules/cqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@

import numpy as np
import torch
from torch import nn
import torchaudio
from torch import nn

from ..misc.utils import Lambda
from ..misc.utils import delayed_import
from ..misc.utils import get_resample_params
from ..misc.utils import numpy_to_torch
from ..misc.utils import Lambda, delayed_import, get_resample_params, numpy_to_torch
from .stft import ShortTimeFourierTransform as STFT


Expand Down Expand Up @@ -78,7 +75,7 @@ class ConstantQTransform(nn.Module):
Window function for the basis.
scale : bool
If True, scale the CQT responce by the length of filter.
If True, scale the CQT response by the length of filter.
res_type : ['kaiser_best', 'kaiser_fast'] or None
Resampling type.
Expand Down
3 changes: 1 addition & 2 deletions diffsptk/modules/csm2acr.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import torch
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
from ..misc.utils import check_size, to


class CompositeSinusoidalModelCoefficientsToAutocorrelation(nn.Module):
Expand Down
4 changes: 1 addition & 3 deletions diffsptk/modules/dct.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import torch
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import plateau
from ..misc.utils import to
from ..misc.utils import check_size, plateau, to


class DiscreteCosineTransform(nn.Module):
Expand Down
2 changes: 1 addition & 1 deletion diffsptk/modules/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# ------------------------------------------------------------------------ #

import torch
from torch import nn
import torch.nn.functional as F
from torch import nn

from ..misc.utils import to

Expand Down
6 changes: 2 additions & 4 deletions diffsptk/modules/dfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
# ------------------------------------------------------------------------ #

import torch
from torch import nn
import torch.nn.functional as F
from torch import nn

from ..misc.utils import iir
from ..misc.utils import to
from ..misc.utils import to_3d
from ..misc.utils import iir, to, to_3d


class InfiniteImpulseResponseDigitalFilter(nn.Module):
Expand Down
4 changes: 1 addition & 3 deletions diffsptk/modules/dht.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import torch
from torch import nn

from ..misc.utils import cas
from ..misc.utils import check_size
from ..misc.utils import to
from ..misc.utils import cas, check_size, to


class DiscreteHartleyTransform(nn.Module):
Expand Down
2 changes: 1 addition & 1 deletion diffsptk/modules/drc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import numpy as np
import torch
from torch import nn
import torchcomp
from torch import nn

from ..misc.utils import to_2d

Expand Down
4 changes: 1 addition & 3 deletions diffsptk/modules/dst.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import torch
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import plateau
from ..misc.utils import to
from ..misc.utils import check_size, plateau, to


class DiscreteSineTransform(nn.Module):
Expand Down
5 changes: 2 additions & 3 deletions diffsptk/modules/excite.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# ------------------------------------------------------------------------ #

import torch
from torch import nn
import torch.nn.functional as F
from torch import nn

from ..misc.utils import TWO_PI
from ..misc.utils import UNVOICED_SYMBOL
from ..misc.utils import TWO_PI, UNVOICED_SYMBOL
from .linear_intpl import LinearInterpolation


Expand Down
5 changes: 2 additions & 3 deletions diffsptk/modules/fbank.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import torch
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
from ..misc.utils import check_size, to


class MelFilterBankAnalysis(nn.Module):
Expand Down Expand Up @@ -50,7 +49,7 @@ class MelFilterBankAnalysis(nn.Module):
If True, use power spectrum instead of amplitude spectrum.
out_format : ['y', 'yE', 'y,E']
`y` is mel-filber bank outpus and `E` is energy. If this is `yE`, the two output
`y` is mel-filber bank output and `E` is energy. If this is `yE`, the two output
tensors are concatenated and return the tensor instead of the tuple.
References
Expand Down
2 changes: 1 addition & 1 deletion diffsptk/modules/fftcep.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# ------------------------------------------------------------------------ #

import torch
from torch import nn
import torch.nn.functional as F
from torch import nn

from ..misc.utils import check_size

Expand Down
2 changes: 1 addition & 1 deletion diffsptk/modules/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License. #
# ------------------------------------------------------------------------ #

from torch import nn
import torch.nn.functional as F
from torch import nn


class Frame(nn.Module):
Expand Down
3 changes: 1 addition & 2 deletions diffsptk/modules/freqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import torch
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
from ..misc.utils import check_size, to


class FrequencyTransform(nn.Module):
Expand Down
5 changes: 2 additions & 3 deletions diffsptk/modules/freqt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
import torch
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
from ..misc.utils import check_size, to


class SecondOrderAllPassFrequencyTransform(nn.Module):
"""Second-order all-pass frequecy transform module.
"""Second-order all-pass frequency transform module.
Parameters
----------
Expand Down
6 changes: 2 additions & 4 deletions diffsptk/modules/gmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
from torch import nn
from tqdm import tqdm

from ..misc.utils import get_logger
from ..misc.utils import outer
from ..misc.utils import to_dataloader
from ..misc.utils import get_logger, outer, to_dataloader


class GaussianMixtureModeling(nn.Module):
Expand Down Expand Up @@ -338,7 +336,7 @@ def forward(self, x, return_posterior=False):

# Check convergence.
if self.verbose:
self.logger.info(f"iter {n+1:5d}: average = {log_likelihood / T:g}")
self.logger.info(f"iter {n + 1:5d}: average = {log_likelihood / T:g}")
change = log_likelihood - prev_log_likelihood
if n and change < self.eps:
break
Expand Down
3 changes: 1 addition & 2 deletions diffsptk/modules/gnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import torch
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import get_gamma
from ..misc.utils import check_size, get_gamma


class GeneralizedCepstrumGainNormalization(nn.Module):
Expand Down
5 changes: 2 additions & 3 deletions diffsptk/modules/grpdelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# ------------------------------------------------------------------------ #

import torch
from torch import nn
import torch.nn.functional as F
from torch import nn

from ..misc.utils import remove_gain
from ..misc.utils import to
from ..misc.utils import remove_gain, to


class GroupDelay(nn.Module):
Expand Down
Loading

0 comments on commit b61b821

Please sign in to comment.