diff --git a/polars/lazy/functions.ts b/polars/lazy/functions.ts index 2cd8692d..f8b63dec 100644 --- a/polars/lazy/functions.ts +++ b/polars/lazy/functions.ts @@ -150,7 +150,7 @@ export function intRange(opts: { low: any; high: any; step: number; - eager: boolean; + eager?: boolean; }); export function intRange( low: any, @@ -177,8 +177,7 @@ export function intRange(opts: any, high?, step = 1, eager?): Series | Expr { .select(intRange(low, high, step).alias("intRange") as any) .getColumn("intRange") as any; } - - return _Expr(pli.intRange(low, high, step)); + return _Expr(pli.intRange(low, high, step, eager)); } } /** Alias for `pl.col("*")` */ diff --git a/src/conversion.rs b/src/conversion.rs index 37d6f9e4..db61c9d5 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -624,11 +624,8 @@ impl FromNapiValue for Wrap { }; Ok(Wrap(dtype)) - // Ok(Wrap(Schema::from(fields))) - } - _ => { - todo!() } + _ => Err(Error::new(Status::InvalidArg, "not a valid conversion to 'DataType'".to_owned())) } } } diff --git a/src/lazy/dsl.rs b/src/lazy/dsl.rs index 8c4b8fe8..addb260d 100644 --- a/src/lazy/dsl.rs +++ b/src/lazy/dsl.rs @@ -1525,13 +1525,13 @@ pub fn dtype_cols(dtypes: Vec>) -> crate::lazy::dsl::JsExpr { #[cfg(feature = "range")] #[napi(catch_unwind)] -pub fn int_range(start: Wrap, end: Wrap, step: i64, dtype: Wrap) -> JsExpr { - let dtype = dtype.0; +pub fn int_range(start: Wrap, end: Wrap, step: i64, dtype: Option>) -> JsExpr { + let dtype = dtype.map(|d| d.0 as DataType); let mut result = dsl::int_range(start.0, end.0, step); - if dtype != DataType::Int64 { - result = result.cast(dtype) + if dtype.is_some() && dtype.clone().unwrap() != DataType::Int64 { + result = result.cast(dtype.clone().unwrap()); } result.into() @@ -1539,13 +1539,13 @@ pub fn int_range(start: Wrap, end: Wrap, step: i64, dtype: Wrap, end: Wrap, step: i64, dtype: Wrap) -> JsExpr { - let dtype = dtype.0; +pub fn int_ranges(start: Wrap, end: Wrap, step: i64, dtype: Option>) -> JsExpr { + let dtype = dtype.map(|d| d.0 as DataType); let mut result = dsl::int_ranges(start.0, end.0, step); - if dtype != DataType::Int64 { - result = result.cast(DataType::List(Box::new(dtype))) + if dtype.is_some() && dtype.clone().unwrap() != DataType::Int64 { + result = result.cast(DataType::List(Box::new(dtype.clone().unwrap()))); } result.into()