From 3025cee8adf0a691ec3d75c3ecaed0c1d089d6d1 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 2 Mar 2024 23:25:12 -0800 Subject: [PATCH] Moved more functions [skip ci] --- ext/polars/src/lib.rs | 82 ++++++++++++++++++------------------ lib/polars/config.rb | 4 +- lib/polars/data_frame.rb | 2 +- lib/polars/functions.rb | 2 +- lib/polars/io.rb | 4 +- lib/polars/lazy_functions.rb | 4 +- lib/polars/series.rb | 2 +- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/ext/polars/src/lib.rs b/ext/polars/src/lib.rs index b6eda39807..6ddcc49559 100644 --- a/ext/polars/src/lib.rs +++ b/ext/polars/src/lib.rs @@ -48,47 +48,6 @@ type RbResult = Result; #[magnus::init] fn init(ruby: &Ruby) -> RbResult<()> { let module = define_module("Polars")?; - module.define_singleton_method("_rb_duration", function!(functions::lazy::duration, 9))?; - module.define_singleton_method("_ipc_schema", function!(functions::io::read_ipc_schema, 1))?; - module.define_singleton_method( - "_parquet_schema", - function!(functions::io::read_parquet_schema, 1), - )?; - module.define_singleton_method("_collect_all", function!(functions::lazy::collect_all, 1))?; - module.define_singleton_method("_rb_date_range", function!(functions::range::date_range, 6))?; - module.define_singleton_method( - "_dtype_str_repr", - function!(functions::misc::dtype_str_repr, 1), - )?; - module.define_singleton_method("_get_idx_type", function!(functions::meta::get_idx_type, 0))?; - module.define_singleton_method( - "_threadpool_size", - function!(functions::meta::threadpool_size, 0), - )?; - module.define_singleton_method( - "_enable_string_cache", - function!(functions::string_cache::enable_string_cache, 0), - )?; - module.define_singleton_method( - "_disable_string_cache", - function!(functions::string_cache::disable_string_cache, 0), - )?; - module.define_singleton_method( - "_using_string_cache", - function!(functions::string_cache::using_string_cache, 0), - )?; - module.define_singleton_method( - "_set_float_fmt", - function!(functions::meta::set_float_fmt, 1), - )?; - module.define_singleton_method( - "_get_float_fmt", - function!(functions::meta::get_float_fmt, 0), - )?; - module.define_singleton_method( - "_set_random_seed", - function!(functions::random::set_random_seed, 1), - )?; let class = module.define_class("RbBatchedCsv", ruby.class_object())?; class.define_singleton_method("new", function!(RbBatchedCsv::new, -1))?; @@ -643,6 +602,47 @@ fn init(ruby: &Ruby) -> RbResult<()> { "concat_series", function!(functions::eager::concat_series, 1), )?; + class.define_singleton_method("duration", function!(functions::lazy::duration, 9))?; + class.define_singleton_method("ipc_schema", function!(functions::io::read_ipc_schema, 1))?; + class.define_singleton_method( + "parquet_schema", + function!(functions::io::read_parquet_schema, 1), + )?; + class.define_singleton_method("collect_all", function!(functions::lazy::collect_all, 1))?; + class.define_singleton_method("date_range", function!(functions::range::date_range, 6))?; + class.define_singleton_method( + "dtype_str_repr", + function!(functions::misc::dtype_str_repr, 1), + )?; + class.define_singleton_method("get_idx_type", function!(functions::meta::get_idx_type, 0))?; + class.define_singleton_method( + "threadpool_size", + function!(functions::meta::threadpool_size, 0), + )?; + class.define_singleton_method( + "enable_string_cache", + function!(functions::string_cache::enable_string_cache, 0), + )?; + class.define_singleton_method( + "disable_string_cache", + function!(functions::string_cache::disable_string_cache, 0), + )?; + class.define_singleton_method( + "using_string_cache", + function!(functions::string_cache::using_string_cache, 0), + )?; + class.define_singleton_method( + "set_float_fmt", + function!(functions::meta::set_float_fmt, 1), + )?; + class.define_singleton_method( + "get_float_fmt", + function!(functions::meta::get_float_fmt, 0), + )?; + class.define_singleton_method( + "set_random_seed", + function!(functions::random::set_random_seed, 1), + )?; let class = module.define_class("RbLazyFrame", ruby.class_object())?; class.define_singleton_method("read_json", function!(RbLazyFrame::read_json, 1))?; diff --git a/lib/polars/config.rb b/lib/polars/config.rb index 640dd5b9be..62a9bc6e2e 100644 --- a/lib/polars/config.rb +++ b/lib/polars/config.rb @@ -21,7 +21,7 @@ class Config "POLARS_VERBOSE" ] - POLARS_CFG_DIRECT_VARS = {"set_fmt_float" => Polars.method(:_get_float_fmt)} + POLARS_CFG_DIRECT_VARS = {"set_fmt_float" => Plr.method(:get_float_fmt)} # Initialize a Config object instance for context manager usage. def initialize(restore_defaults: false, **options) @@ -163,7 +163,7 @@ def self.set_auto_structify(active = true) # # @return [Config] def self.set_fmt_float(fmt = "mixed") - Polars._set_float_fmt(fmt) + Plr.set_float_fmt(fmt) self end diff --git a/lib/polars/data_frame.rb b/lib/polars/data_frame.rb index e610685701..89c7a61932 100644 --- a/lib/polars/data_frame.rb +++ b/lib/polars/data_frame.rb @@ -4948,7 +4948,7 @@ def _pos_idx(idx, dim) end def _pos_idxs(idxs, dim) - idx_type = Polars._get_idx_type + idx_type = Plr.get_idx_type if idxs.is_a?(Series) if idxs.dtype == idx_type diff --git a/lib/polars/functions.rb b/lib/polars/functions.rb index f8b4690a99..3a0e0ff5c1 100644 --- a/lib/polars/functions.rb +++ b/lib/polars/functions.rb @@ -178,7 +178,7 @@ def date_range( stop_rbexpr = Utils.parse_as_expression(stop) result = Utils.wrap_expr( - _rb_date_range(start_rbexpr, stop_rbexpr, interval, closed, time_unit, time_zone) + Plr.date_range(start_rbexpr, stop_rbexpr, interval, closed, time_unit, time_zone) ) result = result.alias(name.to_s) diff --git a/lib/polars/io.rb b/lib/polars/io.rb index 00bcb15dba..d2d73aa806 100644 --- a/lib/polars/io.rb +++ b/lib/polars/io.rb @@ -842,7 +842,7 @@ def read_ipc_schema(source) source = Utils.normalise_filepath(source) end - _ipc_schema(source) + Plr.ipc_schema(source) end # Get a schema of the Parquet file without reading data. @@ -856,7 +856,7 @@ def read_parquet_schema(source) source = Utils.normalise_filepath(source) end - _parquet_schema(source) + Plr.parquet_schema(source) end private diff --git a/lib/polars/lazy_functions.rb b/lib/polars/lazy_functions.rb index 209caaefc9..114666035f 100644 --- a/lib/polars/lazy_functions.rb +++ b/lib/polars/lazy_functions.rb @@ -1457,7 +1457,7 @@ def duration( end Utils.wrap_expr( - _rb_duration( + Plr.duration( weeks, days, hours, @@ -1640,7 +1640,7 @@ def collect_all( prepared << ldf end - out = _collect_all(prepared) + out = Plr.collect_all(prepared) # wrap the rbdataframes into dataframe result = out.map { |rbdf| Utils.wrap_df(rbdf) } diff --git a/lib/polars/series.rb b/lib/polars/series.rb index 6dfe13465a..698e9d41dd 100644 --- a/lib/polars/series.rb +++ b/lib/polars/series.rb @@ -4154,7 +4154,7 @@ def coerce(other) end def _pos_idxs(idxs) - idx_type = Polars._get_idx_type + idx_type = Plr.get_idx_type if idxs.is_a?(Series) if idxs.dtype == idx_type