From cd2da5b05b40136ad8e82713a43df5f8ad6db9bc Mon Sep 17 00:00:00 2001 From: Ritchie Vink Date: Mon, 23 Dec 2024 21:20:07 +0100 Subject: [PATCH 1/2] ci: Remove emscripten wheel before publishing to pypi (#20429) --- .github/workflows/release-python.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 87b530aa3178..2681c5c93a66 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -384,6 +384,9 @@ jobs: path: dist merge-multiple: true + - name: Remove Emscripten wheel + run: rm -f dist/*emscripten-wasm32*.whl + - name: Publish to PyPI if: inputs.dry-run == false uses: pypa/gh-action-pypi-publish@release/v1 From 606e187be789d1cf6e7e7897bdd1aed0a2ff7092 Mon Sep 17 00:00:00 2001 From: Luke Manley Date: Wed, 25 Dec 2024 17:44:12 -0500 Subject: [PATCH 2/2] fix: Fix `mode` panicking for String dtype --- crates/polars-ops/src/chunked_array/mode.rs | 5 ++++- py-polars/tests/unit/series/test_series.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/polars-ops/src/chunked_array/mode.rs b/crates/polars-ops/src/chunked_array/mode.rs index bd1269eea719..87b5fc5e5134 100644 --- a/crates/polars-ops/src/chunked_array/mode.rs +++ b/crates/polars-ops/src/chunked_array/mode.rs @@ -61,7 +61,10 @@ pub fn mode(s: &Series) -> PolarsResult { DataType::Boolean => mode_primitive(s_phys.bool().unwrap())?.into_series(), DataType::Float32 => mode_f32(s_phys.f32().unwrap())?.into_series(), DataType::Float64 => mode_64(s_phys.f64().unwrap())?.into_series(), - DataType::String => mode_primitive(&s_phys.str().unwrap().as_binary())?.into_series(), + DataType::String => { + let ca = mode_primitive(&s_phys.str().unwrap().as_binary())?; + unsafe { ca.to_string_unchecked() }.into_series() + }, dt if dt.is_integer() => { with_match_physical_integer_polars_type!(dt, |$T| { let ca: &ChunkedArray<$T> = s_phys.as_ref().as_ref().as_ref(); diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index f545b1290943..40df19738f6e 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -994,6 +994,7 @@ def test_mode() -> None: == "bar" ) assert pl.Series([1.0, 2.0, 3.0, 2.0]).mode().item() == 2.0 + assert pl.Series(["a", "b", "c", "b"]).mode().item() == "b" # sorted data assert set(pl.int_range(0, 3, eager=True).mode().to_list()) == {0, 1, 2}