Skip to content

Commit 3d3a2a6

Browse files
committed
reupdated str[python] catch after git shenanigans
1 parent 13ed0d6 commit 3d3a2a6

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed

pandas/tests/arrays/string_/test_string.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ def string_dtype_highest_priority(dtype1, dtype2):
6161
return DTYPE_HIERARCHY[max(h1, h2)]
6262

6363

64+
def test_dtype_constructor():
65+
pytest.importorskip("pyarrow")
66+
67+
with tm.assert_produces_warning(FutureWarning):
68+
dtype = pd.StringDtype("pyarrow_numpy")
69+
assert dtype == pd.StringDtype("pyarrow", na_value=np.nan)
70+
71+
6472
def test_dtype_equality():
6573
pytest.importorskip("pyarrow")
6674

@@ -531,8 +539,7 @@ def test_astype_float(dtype, any_float_dtype):
531539
# Don't compare arrays (37974)
532540
ser = pd.Series(["1.1", pd.NA, "3.3"], dtype=dtype)
533541
result = ser.astype(any_float_dtype)
534-
item = np.nan if isinstance(result.dtype, np.dtype) else pd.NA
535-
expected = pd.Series([1.1, item, 3.3], dtype=any_float_dtype)
542+
expected = pd.Series([1.1, np.nan, 3.3], dtype=any_float_dtype)
536543
tm.assert_series_equal(result, expected)
537544

538545

@@ -846,30 +853,3 @@ def test_string_array_view_type_error():
846853
arr = pd.array(["a", "b", "c"], dtype="string")
847854
with pytest.raises(TypeError, match="Cannot change data-type for string array."):
848855
arr.view("i8")
849-
850-
851-
@pytest.mark.parametrize("box", [pd.Series, pd.array])
852-
def test_numpy_array_ufunc(dtype, box):
853-
arr = box(["a", "bb", "ccc"], dtype=dtype)
854-
855-
# custom ufunc that works with string (object) input -> returning numeric
856-
str_len_ufunc = np.frompyfunc(lambda x: len(x), 1, 1)
857-
result = str_len_ufunc(arr)
858-
expected_cls = pd.Series if box is pd.Series else np.array
859-
# TODO we should infer int64 dtype here?
860-
expected = expected_cls([1, 2, 3], dtype=object)
861-
tm.assert_equal(result, expected)
862-
863-
# custom ufunc returning strings
864-
str_multiply_ufunc = np.frompyfunc(lambda x: x * 2, 1, 1)
865-
result = str_multiply_ufunc(arr)
866-
expected = box(["aa", "bbbb", "cccccc"], dtype=dtype)
867-
if dtype.storage == "pyarrow":
868-
# TODO ArrowStringArray should also preserve the class / dtype
869-
if box is pd.array:
870-
expected = np.array(["aa", "bbbb", "cccccc"], dtype=object)
871-
else:
872-
# not specifying the dtype because the exact dtype is not yet preserved
873-
expected = pd.Series(["aa", "bbbb", "cccccc"])
874-
875-
tm.assert_equal(result, expected)

0 commit comments

Comments
 (0)