You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We will have to do some type conversion manually like this:
#[polars_expr(output_type_func=same_output_type)]
fn abs_numeric(inputs: &[Series]) -> PolarsResult<Series> {
let s = &inputs[0];
match s.dtype() {
DataType::Int32 => Ok(impl_abs_numeric(s.i32().unwrap()).into_series()),
DataType::Int64 => Ok(impl_abs_numeric(s.i64().unwrap()).into_series()),
DataType::Float32 => Ok(impl_abs_numeric(s.f32().unwrap()).into_series()),
DataType::Float64 => Ok(impl_abs_numeric(s.f64().unwrap()).into_series()),
dtype => {
polars_bail!(InvalidOperation:format!("dtype {dtype} not \
supported for abs_numeric, expected Int32, Int64, Float32, Float64."))
}
}
}
I think this will be used commonly enough and wonder if there is already a macro provided in this library that will do this? If not, I am happy to help contribute to one.
I am thinking about one that takes in a numeric series and returns a corresponding ChunkedArray type. Something like:
let ca = to_chunkerd_array!(input[0])?;
Instead of a huge match cause:
let ca = match input.dtype() {
DataType::Int32 => input.i32()?,
DataType::Int64 => input.i64()?,
DataType::Float32 => input.f32()?,
DataType::Float64 => input.f64()?,
dtype => {
polars_bail!(InvalidOperation:format!("dtype {dtype} not \
supported, expected Int32, Int64, Float32 or Float64."))
}
}
I have been digging around a little bit, and from the tutorial here:
https://marcogorelli.github.io/polars-plugins-tutorial/abs/
We will have to do some type conversion manually like this:
I think this will be used commonly enough and wonder if there is already a macro provided in this library that will do this? If not, I am happy to help contribute to one.
I am thinking about one that takes in a numeric series and returns a corresponding ChunkedArray type. Something like:
Instead of a huge match cause:
CC @MarcoGorelli
The text was updated successfully, but these errors were encountered: