Skip to content

assert_numpy_array_equal raises TypeError for pd.NA #31881

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
WillAyd opened this issue Feb 11, 2020 · 0 comments · Fixed by #31910
Closed

assert_numpy_array_equal raises TypeError for pd.NA #31881

WillAyd opened this issue Feb 11, 2020 · 0 comments · Fixed by #31910
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@WillAyd
Copy link
Member

WillAyd commented Feb 11, 2020

Discovered in #31799

>>> arr1 = np.array([True, False])
>>> arr2 = np.array([True, pd.NA])
>>> tm.assert_numpy_array_equal(arr1, arr2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/williamayd/clones/pandas/pandas/_testing.py", line 1001, in assert_numpy_array_equal
    if not array_equivalent(left, right, strict_nan=strict_nan):
  File "/Users/williamayd/clones/pandas/pandas/core/dtypes/missing.py", line 447, in array_equivalent
    ensure_object(left.ravel()), ensure_object(right.ravel())
  File "pandas/_libs/lib.pyx", line 583, in pandas._libs.lib.array_equivalent_object
    raise
  File "pandas/_libs/lib.pyx", line 574, in pandas._libs.lib.array_equivalent_object
    elif not (PyObject_RichCompareBool(x, y, Py_EQ) or
  File "pandas/_libs/missing.pyx", line 360, in pandas._libs.missing.NAType.__bool__
    raise TypeError("boolean value of NA is ambiguous")
TypeError: boolean value of NA is ambiguous

Should yield an AssertionError instead of a TypeError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant