From ca31f2d7ef9208ed195b63092818c355504d0983 Mon Sep 17 00:00:00 2001 From: Marshall Crumiller Date: Fri, 25 Aug 2023 17:07:24 -0400 Subject: [PATCH] Fix downstream tests affected by f64 conversion --- crates/polars-core/src/chunked_array/ops/unique/rank.rs | 4 ++-- py-polars/tests/unit/namespaces/test_list.py | 8 ++++---- py-polars/tests/unit/series/test_series.py | 2 +- py-polars/tests/unit/test_exprs.py | 2 +- py-polars/tests/unit/test_lazy.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/polars-core/src/chunked_array/ops/unique/rank.rs b/crates/polars-core/src/chunked_array/ops/unique/rank.rs index 8604e862589d..4549b9bf71ad 100644 --- a/crates/polars-core/src/chunked_array/ops/unique/rank.rs +++ b/crates/polars-core/src/chunked_array/ops/unique/rank.rs @@ -289,10 +289,10 @@ pub(crate) fn rank(s: &Series, method: RankMethod, descending: bool, seed: Optio Average => { // SAFETY: in bounds. let a = unsafe { count.take_unchecked((&dense).into()) } - .cast(&DataType::Float32) + .cast(&DataType::Float64) .unwrap(); let b = unsafe { count.take_unchecked((&(dense - 1)).into()) } - .cast(&DataType::Float32) + .cast(&DataType::Float64) .unwrap() + 1.0; (&a + &b) * 0.5 diff --git a/py-polars/tests/unit/namespaces/test_list.py b/py-polars/tests/unit/namespaces/test_list.py index 6e2c8518fa59..11f6b3d3fc1e 100644 --- a/py-polars/tests/unit/namespaces/test_list.py +++ b/py-polars/tests/unit/namespaces/test_list.py @@ -168,10 +168,10 @@ def test_list_eval_dtype_inference() -> None: .list.first() ] ).to_series().to_list() == [ - 0.3333333432674408, - 0.6666666865348816, - 0.6666666865348816, - 0.3333333432674408, + 0.3333333333333333, + 0.6666666666666666, + 0.6666666666666666, + 0.3333333333333333, ] diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index 84402e3abbba..bab062df55f3 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -1307,7 +1307,7 @@ def test_rank() -> None: ) assert s.rank(method="average").dtype == pl.Float64 - assert pl.Series([1, 2, 3]).rank(method="max").dtype == pl.get_index_type() + assert s.rank(method="max").dtype == pl.get_index_type() def test_diff() -> None: diff --git a/py-polars/tests/unit/test_exprs.py b/py-polars/tests/unit/test_exprs.py index eb44b171ce64..c5e77223fbd5 100644 --- a/py-polars/tests/unit/test_exprs.py +++ b/py-polars/tests/unit/test_exprs.py @@ -368,7 +368,7 @@ def test_rank() -> None: s = df.select(pl.col("a").rank(method="max").alias("b")).to_series() assert s.to_list() == [2, 2, 4, 4, 5] - assert s.dtype == pl.Float64 + assert s.dtype == pl.get_index_type() def test_rank_so_4109() -> None: diff --git a/py-polars/tests/unit/test_lazy.py b/py-polars/tests/unit/test_lazy.py index 6b56bbde16f4..015b18d2f9b3 100644 --- a/py-polars/tests/unit/test_lazy.py +++ b/py-polars/tests/unit/test_lazy.py @@ -1016,9 +1016,9 @@ def test_spearman_corr_ties() -> None: ) expected = pl.DataFrame( [ - pl.Series("a1", [-0.19048483669757843], dtype=pl.Float32), + pl.Series("a1", [-0.19048482943986483], dtype=pl.Float64), pl.Series("a2", [-0.17223653586587362], dtype=pl.Float64), - pl.Series("a3", [-0.19048483669757843], dtype=pl.Float32), + pl.Series("a3", [-0.19048482943986483], dtype=pl.Float64), ] ) assert_frame_equal(result, expected)