Skip to content

Commit

Permalink
fix: Fix Series constructor failure for Array types for large integers
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed May 4, 2024
1 parent e17ef46 commit 75173e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion py-polars/polars/_utils/construction/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ def sequence_to_pyseries(
# flat data
if (
dtype is not None
and dtype not in (List, Struct, Unknown)
and is_polars_dtype(dtype)
and not dtype.is_nested()
and dtype != Unknown
and (python_dtype is None)
):
constructor = polars_type_to_constructor(dtype)
Expand Down
9 changes: 9 additions & 0 deletions py-polars/tests/unit/constructors/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,12 @@ def test_large_timedelta(dtype: pl.DataType | None) -> None:
# Microsecond precision is lost
expected = [timedelta.min, timedelta.max - timedelta(microseconds=999)]
assert s.to_list() == expected


def test_array_large_u64() -> None:
u64_max = 2**64 - 1
values = [[u64_max]]
dtype = pl.Array(pl.UInt64, 1)
s = pl.Series(values, dtype=dtype)
assert s.dtype == dtype
assert s.to_list() == values

0 comments on commit 75173e6

Please sign in to comment.