[
https://issues.apache.org/jira/browse/ARROW-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16406057#comment-16406057
]
ASF GitHub Bot commented on ARROW-640:
--------------------------------------
pitrou commented on a change in pull request #1765: ARROW-640: [Python]
Implement __hash__ and equality for Array scalar values Arrow scalar values
URL: https://github.com/apache/arrow/pull/1765#discussion_r175709705
##########
File path: python/pyarrow/tests/test_scalars.py
##########
@@ -171,3 +171,37 @@ def test_dictionary(self):
categorical.categories)
for i, c in enumerate(values):
assert v[i].as_py() == c
+
+ def test_int_hash(self):
+ # ARROW-640
+ arr = pa.array([1, 1, 2, 1])
+ arr2 = pa.array([1, 1, 2, 1])
+ assert arr[0].__hash__() == arr2[0].__hash__()
Review comment:
Tests should call the built-in `hash()` function, not the `__hash__` method.
Also you need to check that hashing produces identical values to standard
Python values, so for example `hash(arr[0]) == hash(1)`.
(if you were to write a custom hash implementation instead of delegating to
`as_py()`, you would also need to test for many more int values, including
"interesting" values like `-1`, `2**61`, etc.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [Python] Arrow scalar values should have a sensible __hash__ and comparison
> ---------------------------------------------------------------------------
>
> Key: ARROW-640
> URL: https://issues.apache.org/jira/browse/ARROW-640
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Reporter: Miki Tebeka
> Assignee: Alex Hagerman
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.10.0
>
>
> {noformat}
> In [86]: arr = pa.from_pylist([1, 1, 1, 2])
> In [87]: set(arr)
> Out[87]: {1, 2, 1, 1}
> In [88]: arr[0] == arr[1]
> Out[88]: False
> In [89]: arr
> Out[89]:
> <pyarrow.array.Int64Array object at 0x7f8c8c739e08>
> [
> 1,
> 1,
> 1,
> 2
> ]
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)