-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add deterministic hash methods to all types (#573)
### Summary of Changes - feat: add deterministic `__hash__` methods to the all types - test: add tests to all new hash implementations - feat: add `__eq__` method to `TaggedTable` and `TimeSeries` The `__hash__`-Implementation is needed to more efficiently check whether data may be the same. A deterministic implementation is used (based on `xxhash`, a fast non-cryptographic hash algorithm) to allow these comparisons to be performed across different interpreters (processes). The implementation of the Schema was updated to be deterministic.
- Loading branch information
Showing
24 changed files
with
764 additions
and
6 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Any | ||
|
||
import pytest | ||
from safeds.data.tabular.containers import Column, Row | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("column1", "column2"), | ||
[ | ||
(Column("a"), Column("a")), | ||
(Column("a", [1, 2, 3]), Column("a", [1, 2, 3])), | ||
(Column("a", [1, 2, 3]), Column("a", [1, 2, 4])), | ||
], | ||
ids=[ | ||
"empty columns", | ||
"equal columns", | ||
"different values", | ||
], | ||
) | ||
def test_should_return_same_hash_for_equal_columns(column1: Column, column2: Column) -> None: | ||
assert hash(column1) == hash(column2) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("column1", "column2"), | ||
[ | ||
(Column("a"), Column("b")), | ||
(Column("a", [1, 2, 3]), Column("a", ["1", "2", "3"])), | ||
], | ||
ids=[ | ||
"different names", | ||
"different types", | ||
], | ||
) | ||
def test_should_return_different_hash_for_unequal_columns(column1: Column, column2: Column) -> None: | ||
assert hash(column1) != hash(column2) |
Oops, something went wrong.