Skip to content

BUG: nan-objects lookup fails in Python3.10 #41953

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

Closed
3 tasks done
realead opened this issue Jun 11, 2021 · 0 comments · Fixed by #41988
Closed
3 tasks done

BUG: nan-objects lookup fails in Python3.10 #41953

realead opened this issue Jun 11, 2021 · 0 comments · Fixed by #41988
Labels
Milestone

Comments

@realead
Copy link
Contributor

realead commented Jun 11, 2021

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Due to this change in CPython: python/cpython@a07da09

the following assumption is no longer true:

// For PyObject_Hash holds:
// hash(0.0) == 0 == hash(-0.0)
// hash(X) == 0 if X is a NaN-value
// so it is OK to use it directly for doubles
Py_hash_t hash = PyObject_Hash(key);

Here is a failing example:

_____________________ TestIsin.test_different_nan_objects ______________________

self = <pandas.tests.test_algos.TestIsin object at 0x7f9ba1fe7250>

    def test_different_nan_objects(self):
        # GH 22119
        comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object)
        vals = np.array([float("nan")], dtype=object)
        expected = np.array([False, False, True])
        result = algos.isin(comps, vals)
>       tm.assert_numpy_array_equal(expected, result)

pandas/tests/test_algos.py:1039: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

left = array([False, False,  True]), right = array([False, False, False])
@realead realead added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 11, 2021
@lithomas1 lithomas1 added hashing hash_pandas_object Python 3.10 and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 11, 2021
@lithomas1 lithomas1 added this to the 1.4 milestone Jun 11, 2021
@jreback jreback modified the milestones: 1.4, 1.3 Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants