Skip to content

Commit

Permalink
Make sure overwrite wins
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Oct 25, 2023
1 parent 947438a commit 283797e
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion tests/test_utils_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ def test_concat(objs, overwrite, expected):
pd.testing.assert_frame_equal(obj, expected)


#
@pytest.mark.parametrize(
'objs, aggregate_function, expected',
[
Expand Down Expand Up @@ -900,3 +899,64 @@ def test_concat_aggregate_function(objs, aggregate_function, expected):
pd.testing.assert_series_equal(obj, expected)
else:
pd.testing.assert_frame_equal(obj, expected)


@pytest.mark.parametrize(
'objs, aggregate_function, expected',
[
# empty
(
[],
None,
pd.Series([], pd.Index([]), dtype='object'),
),
# identical values
(
[
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
],
None,
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
),
(
[
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
],
np.mean,
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
),
# different values
(
[
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
pd.Series([2, 3], pd.Index(['a', 'b']), dtype='float'),
],
None,
pd.Series([2, 3], pd.Index(['a', 'b']), dtype='float'),
),
(
[
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
pd.Series([2, 3], pd.Index(['a', 'b']), dtype='float'),
],
np.mean,
pd.Series([2, 3], pd.Index(['a', 'b']), dtype='float'),
),
]
)
def test_concat_overwrite_aggregate_function(
objs,
aggregate_function,
expected,
):
obj = audformat.utils.concat(
objs,
overwrite=True,
aggregate_function=aggregate_function,
)
if isinstance(obj, pd.Series):
pd.testing.assert_series_equal(obj, expected)
else:
pd.testing.assert_frame_equal(obj, expected)

0 comments on commit 283797e

Please sign in to comment.