Skip to content

Commit

Permalink
Remove deprecated kwargs for process_func_args (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw authored Mar 13, 2023
1 parent 89aa217 commit 2f8d40e
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 80 deletions.
11 changes: 1 addition & 10 deletions audinterface/core/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,6 @@ def process_func(signal, _):
dtype=object,
)

process_func_args = process_func_args or {}
if kwargs:
warnings.warn(
utils.kwargs_deprecation_warning,
category=UserWarning,
stacklevel=2,
)
for key, value in kwargs.items():
process_func_args[key] = value

if win_dur is None and hop_dur is not None:
raise ValueError(
"You have to specify 'win_dur' if 'hop_dur' is given."
Expand All @@ -347,6 +337,7 @@ def process_func(signal, _):

# add 'win_dur' and 'hop_dur' to process_func_args
# if expected by function but not yet set
process_func_args = process_func_args or {}
signature = inspect.signature(process_func)
if (
'win_dur' in signature.parameters
Expand Down
13 changes: 1 addition & 12 deletions audinterface/core/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import itertools
import os
import typing
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -153,7 +152,6 @@ def __init__(
num_workers: typing.Optional[int] = 1,
multiprocessing: bool = False,
verbose: bool = False,
**kwargs,
):
if channels is not None:
channels = audeer.to_list(channels)
Expand All @@ -162,16 +160,6 @@ def __init__(
def process_func(signal, _):
return signal

process_func_args = process_func_args or {}
if kwargs:
warnings.warn(
utils.kwargs_deprecation_warning,
category=UserWarning,
stacklevel=2,
)
for key, value in kwargs.items():
process_func_args[key] = value

if resample and sampling_rate is None:
raise ValueError(
'sampling_rate has to be provided for resample = True.'
Expand All @@ -187,6 +175,7 @@ def process_func(signal, _):
# figure out if special arguments
# to pass to the processing function
signature = inspect.signature(process_func)
process_func_args = process_func_args or {}
self._process_func_special_args = {
'idx': False,
'root': False,
Expand Down
13 changes: 1 addition & 12 deletions audinterface/core/process_with_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import inspect
import itertools
import typing
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -105,7 +104,6 @@ def __init__(
channels: typing.Union[int, typing.Sequence[int]] = None,
mixdown: bool = False,
verbose: bool = False,
**kwargs,
):
if channels is not None:
channels = audeer.to_list(channels)
Expand All @@ -116,16 +114,6 @@ def process_func(signal, _, starts, ends):
signal[:, start:end] for start, end in zip(starts, ends)
]

process_func_args = process_func_args or {}
if kwargs:
warnings.warn(
utils.kwargs_deprecation_warning,
category=UserWarning,
stacklevel=2,
)
for key, value in kwargs.items():
process_func_args[key] = value

if resample and sampling_rate is None:
raise ValueError(
'sampling_rate has to be provided for resample = True.'
Expand All @@ -134,6 +122,7 @@ def process_func(signal, _, starts, ends):
# figure out if special arguments
# to pass to the processing function
signature = inspect.signature(process_func)
process_func_args = process_func_args or {}
self._process_func_special_args = {
'idx': False,
'root': False,
Expand Down
12 changes: 0 additions & 12 deletions audinterface/core/segment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import errno
import os
import typing
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -212,18 +211,7 @@ def __init__(
num_workers: typing.Optional[int] = 1,
multiprocessing: bool = False,
verbose: bool = False,
**kwargs,
):
process_func_args = process_func_args or {}
if kwargs:
warnings.warn(
utils.kwargs_deprecation_warning,
category=UserWarning,
stacklevel=2,
)
for key, value in kwargs.items():
process_func_args[key] = value

# avoid cycling imports
from audinterface.core.process import Process
process = Process(
Expand Down
7 changes: 0 additions & 7 deletions audinterface/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ def is_scalar(value: typing.Any) -> bool:
(isinstance(value, str) or not hasattr(value, '__len__'))


kwargs_deprecation_warning = (
"The use of **kwargs is deprecated "
"and will be removed with version 1.0.0. "
"Use 'process_func_args' instead."
)


def preprocess_signal(
signal: np.ndarray,
sampling_rate: int,
Expand Down
7 changes: 0 additions & 7 deletions tests/test_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,6 @@ def process_func(s, sr, arg1, arg2):
'arg2': 'bar',
}
)
with pytest.warns(UserWarning):
audinterface.Feature(
feature_names=('o1', 'o2', 'o3'),
process_func=process_func,
arg1='foo',
arg2='bar',
)


@pytest.mark.parametrize('preserve_index', [False, True])
Expand Down
7 changes: 0 additions & 7 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,6 @@ def process_func(s, sr, arg1, arg2):
'arg2': 'bar',
}
)
with pytest.warns(UserWarning):
audinterface.Process(
feature_names=('o1', 'o2', 'o3'),
process_func=process_func,
arg1='foo',
arg2='bar',
)


@pytest.mark.parametrize('preserve_index', [False, True])
Expand Down
7 changes: 0 additions & 7 deletions tests/test_process_with_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ def process_func(s, sr, starts, ends, arg1, arg2):
'arg2': 'bar',
}
)
with pytest.warns(UserWarning):
audinterface.ProcessWithContext(
feature_names=('o1', 'o2', 'o3'),
process_func=process_func,
arg1='foo',
arg2='bar',
)


def test_process_index(tmpdir):
Expand Down
6 changes: 0 additions & 6 deletions tests/test_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,6 @@ def segment_func(s, sr, arg1, arg2):
'arg2': 'bar',
}
)
with pytest.warns(UserWarning):
audinterface.Segment(
process_func=segment_func,
arg1='foo',
arg2='bar',
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 2f8d40e

Please sign in to comment.