Skip to content

Commit

Permalink
fix: compatibility audio do with new scipy (#2733)
Browse files Browse the repository at this point in the history
* compatibility audio do with new `scipy`
* smaller array to fix torch.unique case

---------

Co-authored-by: Nicki Skafte Detlefsen <[email protected]>
  • Loading branch information
Borda and SkafteNicki committed Sep 11, 2024
1 parent 640c664 commit 86ca3f0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/torchmetrics/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@
_ONNXRUNTIME_AVAILABLE,
_PESQ_AVAILABLE,
_PYSTOI_AVAILABLE,
_SCIPI_AVAILABLE,
_TORCHAUDIO_AVAILABLE,
_TORCHAUDIO_GREATER_EQUAL_0_10,
)

if _SCIPI_AVAILABLE:
import scipy.signal

# back compatibility patch due to SMRMpy using scipy.signal.hamming
if not hasattr(scipy.signal, "hamming"):
scipy.signal.hamming = scipy.signal.windows.hamming

__all__ = [
"PermutationInvariantTraining",
"ScaleInvariantSignalDistortionRatio",
Expand Down
8 changes: 8 additions & 0 deletions src/torchmetrics/functional/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@
_ONNXRUNTIME_AVAILABLE,
_PESQ_AVAILABLE,
_PYSTOI_AVAILABLE,
_SCIPI_AVAILABLE,
_TORCHAUDIO_AVAILABLE,
_TORCHAUDIO_GREATER_EQUAL_0_10,
)

if _SCIPI_AVAILABLE:
import scipy.signal

# back compatibility patch due to SMRMpy using scipy.signal.hamming
if not hasattr(scipy.signal, "hamming"):
scipy.signal.hamming = scipy.signal.windows.hamming

__all__ = [
"permutation_invariant_training",
"pit_permutate",
Expand Down
8 changes: 8 additions & 0 deletions src/torchmetrics/functional/nominal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
)
from torchmetrics.functional.nominal.theils_u import theils_u, theils_u_matrix
from torchmetrics.functional.nominal.tschuprows import tschuprows_t, tschuprows_t_matrix
from torchmetrics.utilities.imports import _SCIPI_AVAILABLE

if _SCIPI_AVAILABLE:
import scipy.signal

# back compatibility patch due to SMRMpy using scipy.signal.hamming
if not hasattr(scipy.signal, "hamming"):
scipy.signal.hamming = scipy.signal.windows.hamming

__all__ = [
"cramers_v",
Expand Down
8 changes: 8 additions & 0 deletions src/torchmetrics/nominal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
from torchmetrics.nominal.pearson import PearsonsContingencyCoefficient
from torchmetrics.nominal.theils_u import TheilsU
from torchmetrics.nominal.tschuprows import TschuprowsT
from torchmetrics.utilities.imports import _SCIPI_AVAILABLE

if _SCIPI_AVAILABLE:
import scipy.signal

# back compatibility patch due to SMRMpy using scipy.signal.hamming
if not hasattr(scipy.signal, "hamming"):
scipy.signal.hamming = scipy.signal.windows.hamming

__all__ = [
"CramersV",
Expand Down

0 comments on commit 86ca3f0

Please sign in to comment.