From a535465d831ce143def36d3b6dba291350474dca Mon Sep 17 00:00:00 2001 From: Luke Shingles Date: Fri, 16 Aug 2024 12:08:54 +0100 Subject: [PATCH] Fix compilation errors for features: dtype-struct and dtype-full (#99) --- pyo3-polars/Cargo.toml | 2 +- pyo3-polars/src/types.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pyo3-polars/Cargo.toml b/pyo3-polars/Cargo.toml index 3c32e5f..20322d6 100644 --- a/pyo3-polars/Cargo.toml +++ b/pyo3-polars/Cargo.toml @@ -27,7 +27,7 @@ thiserror = "1" [features] lazy = ["polars/serde-lazy", "polars-plan", "polars-lazy/serde", "ciborium"] derive = ["pyo3-polars-derive", "polars-plan", "polars-ffi", "serde-pickle", "serde"] -dtype-full = ["polars/dtype-full", "dtype-decimal", "dtype-array", "dtype-categorical"] +dtype-full = ["polars/dtype-full", "dtype-decimal", "dtype-array", "dtype-struct", "dtype-categorical"] object = ["polars/object"] dtype-decimal = ["polars/dtype-decimal"] dtype-struct = ["polars/dtype-struct"] diff --git a/pyo3-polars/src/types.rs b/pyo3-polars/src/types.rs index a7aafad..8d26ba7 100644 --- a/pyo3-polars/src/types.rs +++ b/pyo3-polars/src/types.rs @@ -460,7 +460,7 @@ impl ToPyObject for PyDataType { let categories = rev_map.as_ref().unwrap().get_categories(); let class = pl.getattr(intern!(py, "Enum")).unwrap(); let s = Series::from_arrow("category", categories.clone().boxed()).unwrap(); - let series = to_series(py, s.into()); + let series = to_series(py, PySeries(s)); return class.call1((series,)).unwrap().into(); } DataType::Time => pl.getattr(intern!(py, "Time")).unwrap().into(), @@ -577,7 +577,9 @@ impl<'py> FromPyObject<'py> for PyDataType { let ordering = match ordering.extract::<&str>()? { "physical" => CategoricalOrdering::Physical, "lexical" => CategoricalOrdering::Lexical, - ordering => PyValueError::new_err(format!("invalid ordering argument: {ordering}")) + ordering => { + return Err(PyValueError::new_err(format!("invalid ordering argument: {ordering}"))) + } }; DataType::Categorical(None, ordering)