Skip to content

Commit e9ae377

Browse files
committed
add test
1 parent f1ab71a commit e9ae377

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

pandas/tests/dtypes/cast/test_construct_ndarray.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,31 @@
1414
(["1", "2", None], None, np.array(["1", "2", None])),
1515
(["1", "2", None], np.dtype("str"), np.array(["1", "2", None])),
1616
([1, 2, None], np.dtype("str"), np.array(["1", "2", None])),
17+
(
18+
np.ma.masked_array([1, 2, 3], mask=[False, True, False]),
19+
"int64",
20+
np.array([1, 2, 3], dtype=np.int64),
21+
),
22+
(
23+
np.ma.masked_array([1, 2, 3], mask=[False, True, False]),
24+
"float64",
25+
np.array([1, 2, 3], dtype=np.float64),
26+
),
27+
(
28+
np.ma.masked_array([1, 2, 3], mask=[False, True, False]),
29+
"UInt64",
30+
np.array([1, 2, 3], dtype=np.uint64),
31+
),
32+
(
33+
np.ma.masked_array([1.0, 2.0, 3.0], mask=[False, True, False]),
34+
"float64",
35+
np.array([1.0, 2.0, 3.0], dtype=np.float64),
36+
),
37+
(
38+
np.ma.masked_array([1.0, 2.0, 3.0], mask=[False, True, False]),
39+
"Int64",
40+
np.array([1, 2, 3], dtype=np.int64),
41+
),
1742
],
1843
)
1944
def test_construct_1d_ndarray_preserving_na(
@@ -34,3 +59,8 @@ def test_construct_1d_ndarray_preserving_na_datetimelike(dtype):
3459

3560
result = sanitize_array(arr, index=None, dtype=np.dtype(object))
3661
tm.assert_numpy_array_equal(result, expected)
62+
63+
64+
def test_sanitize_masked_array_with_masked_ea(values, dtype, expected):
65+
result = sanitize_array(values, dtype=dtype)
66+
tm.assert_numpy_array_equal(result, expected)

0 commit comments

Comments
 (0)