Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed May 21, 2024
1 parent ba2ae64 commit a5c40eb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions py-polars/tests/unit/interop/numpy/test_to_numpy_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ def test_series_to_numpy_list(chunked: bool) -> None:
assert_allow_copy_false_raises(s)


def test_series_to_numpy_struct_numeric_supertype() -> None:
values = [{"a": 1, "b": 2.0}, {"a": 3, "b": 4.0}, {"a": 5, "b": None}]
s = pl.Series(values)
result = s.to_numpy(use_pyarrow=False)

expected = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, np.nan]])
assert_array_equal(result, expected)
assert result.dtype == np.float64
assert_allow_copy_false_raises(s)


def test_to_numpy_null() -> None:
s = pl.Series([None, None], dtype=pl.Null)
result = s.to_numpy(use_pyarrow=False)
Expand Down

0 comments on commit a5c40eb

Please sign in to comment.