8000 String dtype: avoid surfacing pyarrow exception in binary operations by jorisvandenbossche · Pull Request #59610 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

String dtype: avoid surfacing pyarrow exception in binary operations #59610

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

Merged
Merged
Prev Previous commit
Next Next commit
fix test_sub_fail for infer_string
  • Loading branch information
jorisvandenbossche committed Aug 26, 2024
commit 227b42ab5467fb0b9dd9e5e6e2052149416cfc0a
25 changes: 6 additions & 19 deletions pandas/tests/arithmetic/test_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.compat import HAS_PYARROW
import pandas.util._test_decorators as td

import pandas as pd
Expand Down Expand Up @@ -318,27 +315,17 @@ def test_add(self):
expected = pd.Index(["1a", "1b", "1c"])
tm.assert_index_equal("1" + index, expected)

@pytest.mark.xfail(
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
)
def test_sub_fail(self, using_infer_string):
def test_sub_fail(self):
index = pd.Index([str(i) for i in range(10)])

if using_infer_string:
import pyarrow as pa

err = pa.lib.ArrowNotImplementedError
msg = "has no kernel"
else:
err = TypeError
msg = "unsupported operand type|Cannot broadcast"
with pytest.raises(err, match=msg):
msg = "unsupported operand type|Cannot broadcast|sub' not supported"
with pytest.raises(TypeError, match=msg):
index - "a"
with pytest.raises(err, match=msg):
with pytest.raises(TypeError, match=msg):
index - index
with pytest.raises(err, match=msg):
with pytest.raises(TypeError, match=msg):
index - index.tolist()
with pytest.raises(err, match=msg):
with pytest.raises(TypeError, match=msg):
index.tolist() - index

def test_sub_object(self):
Expand Down
Loading
0