Sha256: b316afda6adb23cdb3fccac71e78d261b9111ed8eafb2b1d856e2486cc4e61b5

Contents?: true

Size: 940 Bytes

Versions: 2

Compression:

Stored size: 940 Bytes

Contents

use magnus::{IntoValue, Value};
use polars_core;
use polars_core::fmt::FloatFmt;
use polars_core::prelude::IDX_DTYPE;
use polars_core::POOL;

use crate::conversion::Wrap;
use crate::{RbResult, RbValueError};

pub fn get_idx_type() -> Value {
    Wrap(IDX_DTYPE).into_value()
}

pub fn threadpool_size() -> usize {
    POOL.current_num_threads()
}

pub fn set_float_fmt(fmt: String) -> RbResult<()> {
    let fmt = match fmt.as_str() {
        "full" => FloatFmt::Full,
        "mixed" => FloatFmt::Mixed,
        e => {
            return Err(RbValueError::new_err(format!(
                "fmt must be one of {{'full', 'mixed'}}, got {e}",
            )))
        }
    };
    polars_core::fmt::set_float_fmt(fmt);
    Ok(())
}

pub fn get_float_fmt() -> RbResult<String> {
    let strfmt = match polars_core::fmt::get_float_fmt() {
        FloatFmt::Full => "full",
        FloatFmt::Mixed => "mixed",
    };
    Ok(strfmt.to_string())
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polars-df-0.8.0 ext/polars/src/functions/meta.rs
polars-df-0.7.0 ext/polars/src/functions/meta.rs