Skip to content

Commit

Permalink
Moved more functions [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Mar 3, 2024
1 parent c807b36 commit 8933198
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
36 changes: 18 additions & 18 deletions ext/polars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,7 @@ type RbResult<T> = Result<T, Error>;
#[magnus::init]
fn init(ruby: &Ruby) -> RbResult<()> {
let module = define_module("Polars")?;
module.define_singleton_method(
"_concat_lf_diagonal",
function!(functions::lazy::concat_lf_diagonal, 4),
)?;
module.define_singleton_method("_rb_duration", function!(functions::lazy::duration, 9))?;
module.define_singleton_method("_concat_df", function!(functions::eager::concat_df, 1))?;
module.define_singleton_method("_concat_lf", function!(functions::lazy::concat_lf, 4))?;
module.define_singleton_method(
"_concat_df_diagonal",
function!(functions::eager::concat_df_diagonal, 1),
)?;
module.define_singleton_method(
"_concat_df_horizontal",
function!(functions::eager::concat_df_horizontal, 1),
)?;
module.define_singleton_method(
"_concat_series",
function!(functions::eager::concat_series, 1),
)?;
module.define_singleton_method("_ipc_schema", function!(functions::io::read_ipc_schema, 1))?;
module.define_singleton_method(
"_parquet_schema",
Expand Down Expand Up @@ -643,6 +625,24 @@ fn init(ruby: &Ruby) -> RbResult<()> {
class.define_singleton_method("as_struct", function!(functions::lazy::as_struct, 1))?;
class.define_singleton_method("coalesce_exprs", function!(functions::lazy::coalesce, 1))?;
class.define_singleton_method("arg_where", function!(functions::lazy::arg_where, 1))?;
class.define_singleton_method(
"concat_lf_diagonal",
function!(functions::lazy::concat_lf_diagonal, 4),
)?;
class.define_singleton_method("concat_df", function!(functions::eager::concat_df, 1))?;
class.define_singleton_method("concat_lf", function!(functions::lazy::concat_lf, 4))?;
class.define_singleton_method(
"concat_df_diagonal",
function!(functions::eager::concat_df_diagonal, 1),
)?;
class.define_singleton_method(
"concat_df_horizontal",
function!(functions::eager::concat_df_horizontal, 1),
)?;
class.define_singleton_method(
"concat_series",
function!(functions::eager::concat_series, 1),
)?;

let class = module.define_class("RbLazyFrame", ruby.class_object())?;
class.define_singleton_method("read_json", function!(RbLazyFrame::read_json, 1))?;
Expand Down
14 changes: 7 additions & 7 deletions lib/polars/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@ def concat(items, rechunk: true, how: "vertical", parallel: true)
first = items[0]
if first.is_a?(DataFrame)
if how == "vertical"
out = Utils.wrap_df(_concat_df(items))
out = Utils.wrap_df(Plr.concat_df(items))
elsif how == "diagonal"
out = Utils.wrap_df(_concat_df_diagonal(items))
out = Utils.wrap_df(Plr.concat_df_diagonal(items))
elsif how == "horizontal"
out = Utils.wrap_df(_concat_df_horizontal(items))
out = Utils.wrap_df(Plr.concat_df_horizontal(items))
else
raise ArgumentError, "how must be one of {{'vertical', 'diagonal', 'horizontal'}}, got #{how}"
end
elsif first.is_a?(LazyFrame)
if how == "vertical"
return Utils.wrap_ldf(_concat_lf(items, rechunk, parallel, false))
return Utils.wrap_ldf(Plr.concat_lf(items, rechunk, parallel, false))
elsif how == "vertical_relaxed"
return Utils.wrap_ldf(_concat_lf(items, rechunk, parallel, true))
return Utils.wrap_ldf(Plr.concat_lf(items, rechunk, parallel, true))
elsif how == "diagonal"
return Utils.wrap_ldf(_concat_lf_diagonal(items, rechunk, parallel, false))
return Utils.wrap_ldf(Plr.concat_lf_diagonal(items, rechunk, parallel, false))
else
raise ArgumentError, "Lazy only allows 'vertical', 'vertical_relaxed', and 'diagonal' concat strategy."
end
elsif first.is_a?(Series)
# TODO
out = Utils.wrap_s(_concat_series(items))
out = Utils.wrap_s(Plr.concat_series(items))
elsif first.is_a?(Expr)
out = first
items[1..-1].each do |e|
Expand Down

0 comments on commit 8933198

Please sign in to comment.