From cb21724cb2a4654762ded4844406a9dff9f29265 Mon Sep 17 00:00:00 2001 From: moto <855818+mthrok@users.noreply.github.com> Date: Mon, 5 Apr 2021 23:16:28 +0000 Subject: [PATCH 1/2] Add warning about complex tensor to spectrogram --- torchaudio/functional/functional.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/torchaudio/functional/functional.py b/torchaudio/functional/functional.py index 38cfda2097..0a818821a4 100644 --- a/torchaudio/functional/functional.py +++ b/torchaudio/functional/functional.py @@ -84,6 +84,14 @@ def spectrogram( ``n_fft // 2 + 1`` and ``n_fft`` is the number of Fourier bins, and time is the number of window hops (n_frame). """ + if power is None and not return_complex: + warnings.warn( + "spectrogram now supports returning native complex tensor " + "when `power=None` by setting `return_complex=True`. " + "Currently, the function returns pseudo complex type (..., 2) by default, " + "but this will change in the future and `return_complex` would be set to True by default. " + "Please refer to https://github.com/pytorch/audio/issues/1337 for the detail.") + if power is not None and return_complex: raise ValueError( 'When `power` is provided, the return value is real-valued. ' From 9c1da49656fcfa2ff1e42d8f0fe4d624d13a0c71 Mon Sep 17 00:00:00 2001 From: moto <855818+mthrok@users.noreply.github.com> Date: Wed, 7 Apr 2021 01:27:21 +0000 Subject: [PATCH 2/2] Update message --- torchaudio/functional/functional.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/torchaudio/functional/functional.py b/torchaudio/functional/functional.py index 0a818821a4..7062ed13ba 100644 --- a/torchaudio/functional/functional.py +++ b/torchaudio/functional/functional.py @@ -86,11 +86,13 @@ def spectrogram( """ if power is None and not return_complex: warnings.warn( - "spectrogram now supports returning native complex tensor " + "Spectrogram now supports returning native complex tensor " "when `power=None` by setting `return_complex=True`. " - "Currently, the function returns pseudo complex type (..., 2) by default, " - "but this will change in the future and `return_complex` would be set to True by default. " - "Please refer to https://github.com/pytorch/audio/issues/1337 for the detail.") + "Currently, this function returns pseudo complex type (..., 2) by default, " + "but this will change in the future and `return_complex` " + "will be set to True by default. Please refer to " + "https://github.com/pytorch/audio/issues/1337 " + "for more details about the migration plan.") if power is not None and return_complex: raise ValueError(