Skip to content

Commit

Permalink
Merge branch 'main' into non-keyword-to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
rsm-23 authored Aug 17, 2023
2 parents 3bbb22e + 7c9ba89 commit c93bd87
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
5 changes: 5 additions & 0 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1996,3 +1996,8 @@ def warsaw(request) -> str:
tzinfo for Europe/Warsaw using pytz, dateutil, or zoneinfo.
"""
return request.param


@pytest.fixture()
def arrow_string_storage():
return ("pyarrow",)
20 changes: 10 additions & 10 deletions pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def test_add(dtype):
tm.assert_series_equal(result, expected)


def test_add_2d(dtype, request):
if dtype.storage == "pyarrow":
def test_add_2d(dtype, request, arrow_string_storage):
if dtype.storage in arrow_string_storage:
reason = "Failed: DID NOT RAISE <class 'ValueError'>"
mark = pytest.mark.xfail(raises=None, reason=reason)
request.node.add_marker(mark)
Expand Down Expand Up @@ -144,8 +144,8 @@ def test_add_sequence(dtype):
tm.assert_extension_array_equal(result, expected)


def test_mul(dtype, request):
if dtype.storage == "pyarrow":
def test_mul(dtype, request, arrow_string_storage):
if dtype.storage in arrow_string_storage:
reason = "unsupported operand type(s) for *: 'ArrowStringArray' and 'int'"
mark = pytest.mark.xfail(raises=NotImplementedError, reason=reason)
request.node.add_marker(mark)
Expand Down Expand Up @@ -369,8 +369,8 @@ def test_min_max(method, skipna, dtype, request):

@pytest.mark.parametrize("method", ["min", "max"])
@pytest.mark.parametrize("box", [pd.Series, pd.array])
def test_min_max_numpy(method, box, dtype, request):
if dtype.storage == "pyarrow" and box is pd.array:
def test_min_max_numpy(method, box, dtype, request, arrow_string_storage):
if dtype.storage in arrow_string_storage and box is pd.array:
if box is pd.array:
reason = "'<=' not supported between instances of 'str' and 'NoneType'"
else:
Expand All @@ -384,7 +384,7 @@ def test_min_max_numpy(method, box, dtype, request):
assert result == expected


def test_fillna_args(dtype, request):
def test_fillna_args(dtype, request, arrow_string_storage):
# GH 37987

arr = pd.array(["a", pd.NA], dtype=dtype)
Expand All @@ -397,7 +397,7 @@ def test_fillna_args(dtype, request):
expected = pd.array(["a", "b"], dtype=dtype)
tm.assert_extension_array_equal(res, expected)

if dtype.storage == "pyarrow":
if dtype.storage in arrow_string_storage:
msg = "Invalid value '1' for dtype string"
else:
msg = "Cannot set non-string value '1' into a StringArray."
Expand Down Expand Up @@ -503,10 +503,10 @@ def test_use_inf_as_na(values, expected, dtype):
tm.assert_frame_equal(result, expected)


def test_memory_usage(dtype):
def test_memory_usage(dtype, arrow_string_storage):
# GH 33963

if dtype.storage == "pyarrow":
if dtype.storage in arrow_string_storage:
pytest.skip(f"not applicable for {dtype.storage}")

series = pd.Series(["a", "b", "c"], dtype=dtype)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/arrays/string_/test_string_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def test_config_bad_storage_raises():
@skip_if_no_pyarrow
@pytest.mark.parametrize("chunked", [True, False])
@pytest.mark.parametrize("array", ["numpy", "pyarrow"])
def test_constructor_not_string_type_raises(array, chunked):
def test_constructor_not_string_type_raises(array, chunked, arrow_string_storage):
import pyarrow as pa

array = pa if array == "pyarrow" else np
array = pa if array in arrow_string_storage else np

arr = array.array([1, 2, 3])
if chunked:
Expand Down
12 changes: 6 additions & 6 deletions pandas/tests/extension/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def test_is_not_string_type(self, dtype):


class TestInterface(base.BaseInterfaceTests):
def test_view(self, data, request):
if data.dtype.storage == "pyarrow":
def test_view(self, data, request, arrow_string_storage):
if data.dtype.storage in arrow_string_storage:
pytest.skip(reason="2D support not implemented for ArrowStringArray")
super().test_view(data)

Expand All @@ -116,8 +116,8 @@ def test_from_dtype(self, data):


class TestReshaping(base.BaseReshapingTests):
def test_transpose(self, data, request):
if data.dtype.storage == "pyarrow":
def test_transpose(self, data, request, arrow_string_storage):
if data.dtype.storage in arrow_string_storage:
pytest.skip(reason="2D support not implemented for ArrowStringArray")
super().test_transpose(data)

Expand All @@ -127,8 +127,8 @@ class TestGetitem(base.BaseGetitemTests):


class TestSetitem(base.BaseSetitemTests):
def test_setitem_preserves_views(self, data, request):
if data.dtype.storage == "pyarrow":
def test_setitem_preserves_views(self, data, request, arrow_string_storage):
if data.dtype.storage in arrow_string_storage:
pytest.skip(reason="2D support not implemented for ArrowStringArray")
super().test_setitem_preserves_views(data)

Expand Down

0 comments on commit c93bd87

Please sign in to comment.