Skip to content

Commit

Permalink
DOC: utils.hash() is not influenced by names (#443)
Browse files Browse the repository at this point in the history
* DOC: utils.hash() is not influenced by names

* Improve wording
  • Loading branch information
hagenw authored Jun 24, 2024
1 parent f10c2ed commit 642984d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion audformat/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ def hash(
Objects with the same elements
produce the same hash string
independent of the ordering of the elements.
independent of the ordering of the elements,
and level or column names.
Args:
obj: object
Expand Down
32 changes: 32 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,38 @@ def test_expand_file_path(tmpdir, index, root, expected):
),
"-103439349488189352",
),
(pd.Index([0, 1], name="idx"), "6238072747940578789"),
(pd.Index([0, 1], name="name"), "6238072747940578789"),
(
pd.MultiIndex.from_arrays(
[[0, 1], ["a", "b"]],
names=["idx1", "idx2"],
),
"8378370490910668918",
),
(
pd.MultiIndex.from_arrays(
[[0, 1], ["a", "b"]],
names=["name1", "name2"],
),
"8378370490910668918",
),
(
pd.Series([0, 1], name="series"),
"-7179254265801896228",
),
(
pd.Series([0, 1], name="name"),
"-7179254265801896228",
),
(
pd.DataFrame([0, 1], columns=["frame"]),
"-7179254265801896228",
),
(
pd.DataFrame([0, 1], columns=["name"]),
"-7179254265801896228",
),
],
)
def test_hash(obj, expected):
Expand Down

0 comments on commit 642984d

Please sign in to comment.