Skip to content

Commit

Permalink
Remove deprecated unit argument from Feature (#168)
Browse files Browse the repository at this point in the history
* Remove deprecated unit argument from Feature

* Fix linter
  • Loading branch information
hagenw authored Mar 25, 2024
1 parent 49090e6 commit 78a10d4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 55 deletions.
29 changes: 0 additions & 29 deletions audinterface/core/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import inspect
import os
import typing
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -244,35 +243,7 @@ def __init__(
num_workers: typing.Optional[int] = 1,
multiprocessing: bool = False,
verbose: bool = False,
**kwargs,
):
# ------
# Handle deprecated 'unit' keyword argument
def add_unit(dur, unit):
if unit == "samples":
return str(dur)
else:
return f"{dur}{unit}"

if "unit" in kwargs:
message = (
"'unit' argument is deprecated "
"and will be removed with version '1.2.0'."
"The unit can now directly specified "
"within the 'win_dur' and 'hop_dur' arguments."
)
warnings.warn(
message,
category=UserWarning,
stacklevel=2,
)
unit = kwargs.pop("unit")
if win_dur is not None:
win_dur = add_unit(win_dur, unit)
if hop_dur is not None:
hop_dur = add_unit(hop_dur, unit)
# ------

if mixdown or isinstance(channels, int):
num_channels = 1
else:
Expand Down
26 changes: 0 additions & 26 deletions tests/test_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,6 @@ def mean_sliding_window_mono(signal, sampling_rate, win_dur, hop_dur):
return frames.mean(axis=1, keepdims=False)


def test_deprecated_unit_argument():
if audeer.LooseVersion(audinterface.__version__) < audeer.LooseVersion("1.2.0"):
with pytest.warns(UserWarning, match="is deprecated"):
interface = audinterface.Feature(
["a"],
win_dur=1000,
unit="samples",
sampling_rate=16000,
)
assert interface.win_dur == "1000"
interface = audinterface.Feature(
["a"],
win_dur=1000,
hop_dur=500,
unit="milliseconds",
)
assert interface.win_dur == "1000milliseconds"
assert interface.hop_dur == "500milliseconds"
else:
with pytest.raises(TypeError, match="unexpected keyword argument"):
audinterface.Feature(
["a"],
unit="samples",
)


def test_feature():
# You have to specify sampling rate when win_dur is in samples
with pytest.raises(ValueError):
Expand Down

0 comments on commit 78a10d4

Please sign in to comment.