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 8933198 commit 3025cee
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 50 deletions.
82 changes: 41 additions & 41 deletions ext/polars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,47 +48,6 @@ type RbResult<T> = Result<T, Error>;
#[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))?;
Expand Down Expand Up @@ -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))?;
Expand Down
4 changes: 2 additions & 2 deletions lib/polars/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/polars/data_frame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/polars/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/polars/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -856,7 +856,7 @@ def read_parquet_schema(source)
source = Utils.normalise_filepath(source)
end

_parquet_schema(source)
Plr.parquet_schema(source)
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/polars/lazy_functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ def duration(
end

Utils.wrap_expr(
_rb_duration(
Plr.duration(
weeks,
days,
hours,
Expand Down Expand Up @@ -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) }
Expand Down
2 changes: 1 addition & 1 deletion lib/polars/series.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3025cee

Please sign in to comment.