Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Feb 20, 2024
1 parent a4fdf7a commit 4d51907
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions py-polars/tests/unit/datatypes/test_float.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import polars as pl
import pytest
from polars.testing import assert_series_equal


def test_nan_in_group_by_agg() -> None:
Expand Down Expand Up @@ -32,3 +34,47 @@ def test_nan_aggregations() -> None:
str(df.group_by("b").agg(aggs).to_dict(as_series=False))
== "{'b': [1], 'max': [3.0], 'min': [1.0], 'nan_max': [nan], 'nan_min': [nan]}"
)


@pytest.mark.parametrize(
("s", "expect"),
(
(
pl.Series(
"x",
[
-0.0,
0.0,
float("-nan"),
float("nan"),
1.0,
None,
],
),
pl.Series("x", [None, 0.0, 1.0, float("nan")]),
),
(
# No nulls
pl.Series(
"x",
[
-0.0,
0.0,
float("-nan"),
float("nan"),
1.0,
],
),
pl.Series("x", [0.0, 1.0, float("nan")]),
),
),
)
def test_unique(s: pl.Series, expect: pl.Series) -> None:
out = s.unique()
assert_series_equal(expect, out)

out = s.n_unique()
assert expect.len() == out

out = s.gather(s.arg_unique()).sort()
assert_series_equal(expect, out)

0 comments on commit 4d51907

Please sign in to comment.