|
5 | 5 | import numpy as np
|
6 | 6 | import pytest
|
7 | 7 |
|
8 |
| -from pandas._config import using_string_dtype |
9 |
| - |
10 | 8 | import pandas as pd
|
11 | 9 | import pandas._testing as tm
|
12 | 10 | from pandas.api.extensions import register_extension_dtype
|
@@ -215,21 +213,43 @@ def test_dt64_array(dtype_unit):
|
215 | 213 | .construct_array_type()
|
216 | 214 | ._from_sequence(["a", None], dtype=pd.StringDtype()),
|
217 | 215 | ),
|
| 216 | + ( |
| 217 | + ["a", None], |
| 218 | + "str", |
| 219 | + pd.StringDtype(na_value=np.nan) |
| 220 | + .construct_array_type() |
| 221 | + ._from_sequence(["a", None], dtype=pd.StringDtype(na_value=np.nan)), |
| 222 | + ), |
218 | 223 | (
|
219 | 224 | ["a", None],
|
220 | 225 | pd.StringDtype(),
|
221 | 226 | pd.StringDtype()
|
222 | 227 | .construct_array_type()
|
223 | 228 | ._from_sequence(["a", None], dtype=pd.StringDtype()),
|
224 | 229 | ),
|
| 230 | + ( |
| 231 | + ["a", None], |
| 232 | + pd.StringDtype(na_value=np.nan), |
| 233 | + pd.StringDtype(na_value=np.nan) |
| 234 | + .construct_array_type() |
| 235 | + ._from_sequence(["a", None], dtype=pd.StringDtype(na_value=np.nan)), |
| 236 | + ), |
225 | 237 | (
|
226 | 238 | # numpy array with string dtype
|
227 | 239 | np.array(["a", "b"], dtype=str),
|
228 |
| - None, |
| 240 | + pd.StringDtype(), |
229 | 241 | pd.StringDtype()
|
230 | 242 | .construct_array_type()
|
231 | 243 | ._from_sequence(["a", "b"], dtype=pd.StringDtype()),
|
232 | 244 | ),
|
| 245 | + ( |
| 246 | + # numpy array with string dtype |
| 247 | + np.array(["a", "b"], dtype=str), |
| 248 | + pd.StringDtype(na_value=np.nan), |
| 249 | + pd.StringDtype(na_value=np.nan) |
| 250 | + .construct_array_type() |
| 251 | + ._from_sequence(["a", "b"], dtype=pd.StringDtype(na_value=np.nan)), |
| 252 | + ), |
233 | 253 | # Boolean
|
234 | 254 | (
|
235 | 255 | [True, None],
|
@@ -287,7 +307,6 @@ def test_array_copy():
|
287 | 307 | assert tm.shares_memory(a, b)
|
288 | 308 |
|
289 | 309 |
|
290 |
| -@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False) |
291 | 310 | @pytest.mark.parametrize(
|
292 | 311 | "data, expected",
|
293 | 312 | [
|
@@ -387,6 +406,13 @@ def test_array_copy():
|
387 | 406 | .construct_array_type()
|
388 | 407 | ._from_sequence(["a", None], dtype=pd.StringDtype()),
|
389 | 408 | ),
|
| 409 | + ( |
| 410 | + # numpy array with string dtype |
| 411 | + np.array(["a", "b"], dtype=str), |
| 412 | + pd.StringDtype() |
| 413 | + .construct_array_type() |
| 414 | + ._from_sequence(["a", "b"], dtype=pd.StringDtype()), |
| 415 | + ), |
390 | 416 | # Boolean
|
391 | 417 | ([True, False], BooleanArray._from_sequence([True, False], dtype="boolean")),
|
392 | 418 | ([True, None], BooleanArray._from_sequence([True, None], dtype="boolean")),
|
|
0 commit comments