From fe8d090887b356fdd7a6fbfd00578309e1c34ded Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Tue, 25 Jun 2024 13:05:10 +0200 Subject: [PATCH] DOC: utils.hash() can change with pandas>=2.2 (#442) * DOC: utils.hash() can change with pandas>=2.2 * Fix rebasing --- audformat/core/utils.py | 6 ++++++ tests/test_utils.py | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/audformat/core/utils.py b/audformat/core/utils.py index b201808a..8945357d 100644 --- a/audformat/core/utils.py +++ b/audformat/core/utils.py @@ -672,6 +672,12 @@ def hash( independent of the ordering of the elements, and level or column names. + .. warning:: + + If ``obj`` is a dataframe or series + with data type ``"Int64"``, + the returned hash value changes with ``pandas>=2.2.0``. + Args: obj: object diff --git a/tests/test_utils.py b/tests/test_utils.py index d124e057..79cd6028 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -509,6 +509,50 @@ def test_expand_file_path(tmpdir, index, root, expected): pd.DataFrame([0, 1], columns=["name"]), "-7179254265801896228", ), + pytest.param( + pd.DataFrame( + [0, 1, 2], + pd.Index([0, 1, 2], dtype="Int64"), + ), + "5440931770055407318", + marks=pytest.mark.skipif( + pd.__version__ >= "2.2.0", + reason="Changed in pandas 2.2.0", + ), + ), + pytest.param( + pd.DataFrame( + [0, 1, 2], + pd.Index([0, 1, 2], dtype="Int64"), + ), + "-5491649331962632325", + marks=pytest.mark.skipif( + pd.__version__ < "2.2.0", + reason="Changed in pandas 2.2.0", + ), + ), + pytest.param( + pd.Series( + [0, 1, 2], + pd.Index([0, 1, 2], dtype="Int64"), + ), + "5440931770055407318", + marks=pytest.mark.skipif( + pd.__version__ >= "2.2.0", + reason="Changed in pandas 2.2.0", + ), + ), + pytest.param( + pd.Series( + [0, 1, 2], + pd.Index([0, 1, 2], dtype="Int64"), + ), + "-5491649331962632325", + marks=pytest.mark.skipif( + pd.__version__ < "2.2.0", + reason="Changed in pandas 2.2.0", + ), + ), ], ) def test_hash(obj, expected):