Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: utils.hash() is not influenced by names #443

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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