Skip to content

Commit

Permalink
reverse polars-time -> polars-core dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 27, 2022
1 parent d9736cf commit d0d25c6
Show file tree
Hide file tree
Showing 45 changed files with 360 additions and 316 deletions.
12 changes: 9 additions & 3 deletions polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rows = ["polars-core/rows"]
simd = ["polars-core/simd"]
avx512 = ["polars-core/avx512"]
docs = ["polars-core/docs"]
temporal = ["polars-core/temporal", "polars-lazy/temporal", "polars-io/temporal"]
temporal = ["polars-core/temporal", "polars-lazy/temporal", "polars-io/temporal", "polars-time"]
random = ["polars-core/random", "polars-lazy/random"]
default = [
"docs",
Expand Down Expand Up @@ -126,8 +126,13 @@ dtype-slim = [
]

# opt-in datatypes for Series
dtype-date = ["polars-core/dtype-date", "polars-lazy/dtype-date", "polars-io/dtype-date"]
dtype-datetime = ["polars-core/dtype-datetime", "polars-lazy/dtype-datetime", "polars-io/dtype-datetime"]
dtype-date = ["polars-core/dtype-date", "polars-lazy/dtype-date", "polars-io/dtype-date", "polars-time/dtype-date"]
dtype-datetime = [
"polars-core/dtype-datetime",
"polars-lazy/dtype-datetime",
"polars-io/dtype-datetime",
"polars-time/dtype-datetime",
]
dtype-duration = ["polars-core/dtype-duration", "polars-lazy/dtype-duration"]
dtype-time = ["polars-core/dtype-time", "polars-io/dtype-time"]
dtype-i8 = ["polars-core/dtype-i8", "polars-lazy/dtype-i8"]
Expand Down Expand Up @@ -188,6 +193,7 @@ bench = [
polars-core = { version = "0.19.1", path = "./polars-core", features = ["docs", "private"], default-features = false }
polars-io = { version = "0.19.1", path = "./polars-io", features = ["private"], default-features = false, optional = true }
polars-lazy = { version = "0.19.1", path = "./polars-lazy", features = ["private"], default-features = false, optional = true }
polars-time = { version = "0.1.1", path = "./polars-time", default-features = false, optional = true }

[dev-dependencies]
ahash = "0.7"
Expand Down
7 changes: 3 additions & 4 deletions polars/polars-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description = "Core of the Polars DataFrame library"
simd = ["arrow/simd"]
avx512 = []
docs = []
temporal = ["regex", "polars-time"]
temporal = ["regex", "chrono"]
random = ["rand", "rand_distr"]
default = ["docs", "temporal", "performant", "private"]
lazy = ["sort_multiple"]
Expand Down Expand Up @@ -77,7 +77,7 @@ ewma = ["polars-utils"]
dataframe_arithmetic = []
product = []

dynamic_groupby = ["polars-time", "dtype-datetime", "dtype-date"]
dynamic_groupby = ["dtype-datetime", "dtype-date"]

# opt-in datatypes for Series
dtype-date = ["temporal"]
Expand Down Expand Up @@ -135,8 +135,8 @@ docs-selection = [
[dependencies]
ahash = "0.7"
anyhow = "1.0"

base64 = { version = "0.13", optional = true }
chrono = { version = "0.4", optional = true }
comfy-table = { version = "5.0", optional = true }
hashbrown = { version = "0.12", features = ["rayon"] }
hex = { version = "0.4", optional = true }
Expand All @@ -146,7 +146,6 @@ ndarray = { version = "0.15", optional = true, default_features = false }
num = "^0.4"
num_cpus = "1"
polars-arrow = { version = "0.19.1", path = "../polars-arrow", features = ["compute"] }
polars-time = { version = "0.1.1", path = "../polars-time", optional = true }
polars-utils = { version = "0.1.0", path = "../polars-utils", optional = true }
prettytable-rs = { version = "0.8.0", optional = true }
rand = { version = "0.8", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/chunked_array/kernels/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use arrow::temporal_conversions::time64ns_to_time;
use arrow::temporal_conversions::{
date32_to_datetime, timestamp_ms_to_datetime, timestamp_ns_to_datetime,
};
use polars_time::export::chrono::{Datelike, NaiveDate, NaiveDateTime, Timelike};
use chrono::{Datelike, NaiveDate, NaiveDateTime, Timelike};
use std::sync::Arc;

trait PolarsWeekDay {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arrow::temporal_conversions::time64ns_to_time;
use arrow::temporal_conversions::{
timestamp_ms_to_datetime, timestamp_ns_to_datetime, MILLISECONDS,
};
use polars_time::export::chrono::{NaiveDateTime, NaiveTime};
use chrono::{NaiveDateTime, NaiveTime};

/// Number of seconds in a day
pub(crate) const SECONDS_IN_DAY: i64 = 86_400;
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/chunked_array/temporal/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl DatetimeChunked {
#[cfg(test)]
mod test {
use crate::prelude::*;
use polars_time::export::chrono::NaiveDateTime;
use chrono::NaiveDateTime;

#[test]
fn from_datetime() {
Expand Down
4 changes: 1 addition & 3 deletions polars/polars-core/src/chunked_array/temporal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ mod datetime;
mod duration;
#[cfg(feature = "dtype-time")]
mod time;
#[cfg(feature = "temporal")]
pub mod truncate;
mod utf8;

pub use self::conversion::*;
use crate::chunked_array::kernels::temporal::*;
use polars_time::export::chrono::{NaiveDate, NaiveDateTime, NaiveTime};
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};

pub fn unix_time() -> NaiveDateTime {
NaiveDateTime::from_timestamp(0, 0)
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/chunked_array/temporal/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::chunked_array::kernels::temporal::{
use crate::prelude::*;
use crate::utils::NoNull;
use arrow::temporal_conversions::{time64ns_to_time, NANOSECONDS};
use polars_time::export::chrono::Timelike;
use chrono::Timelike;

pub(crate) fn time_to_time64ns(time: &NaiveTime) -> i64 {
time.second() as i64 * NANOSECONDS + time.nanosecond() as i64
Expand Down
4 changes: 2 additions & 2 deletions polars/polars-core/src/chunked_array/temporal/utf8.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::*;
#[cfg(feature = "dtype-time")]
use crate::chunked_array::temporal::time::time_to_time64ns;
use crate::export::chrono::ParseError;
use crate::prelude::*;
use polars_time::export::chrono;
use chrono;
use chrono::ParseError;

#[cfg(feature = "dtype-time")]
fn time_pattern<F, K>(val: &str, convert: F) -> Option<&'static str>
Expand Down
8 changes: 0 additions & 8 deletions polars/polars-core/src/datatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,14 +586,6 @@ impl TimeUnit {
TimeUnit::Milliseconds => ArrowTimeUnit::Millisecond,
}
}

#[cfg(any(feature = "temporal", feature = "dynamic_groupby"))]
pub(crate) fn to_polars_time(self) -> polars_time::groupby::TimeUnit {
match self {
TimeUnit::Nanoseconds => polars_time::groupby::TimeUnit::Nanoseconds,
TimeUnit::Milliseconds => polars_time::groupby::TimeUnit::Milliseconds,
}
}
}

pub type TimeZone = String;
Expand Down
4 changes: 3 additions & 1 deletion polars/polars-core/src/export.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub use arrow;
#[cfg(all(feature = "private", feature = "temporal"))]
pub use polars_time::export::chrono;
pub use chrono;

#[cfg(feature = "private")]
pub use lazy_static;
#[cfg(feature = "private")]
pub use rayon;
2 changes: 1 addition & 1 deletion polars/polars-core/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl Display for AnyValue<'_> {
},
#[cfg(feature = "dtype-time")]
AnyValue::Time(_) => {
let nt: polars_time::export::chrono::NaiveTime = self.into();
let nt: chrono::NaiveTime = self.into();
write!(f, "{}", nt)
}
#[cfg(feature = "dtype-categorical")]
Expand Down
19 changes: 4 additions & 15 deletions polars/polars-core/src/frame/groupby/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,18 @@ use std::hash::Hash;
use std::ops::Deref;

pub mod aggregations;
#[cfg(feature = "dynamic_groupby")]
mod dynamic;
pub(crate) mod hashing;
#[cfg(feature = "rows")]
pub(crate) mod pivot;
mod proxy;

#[cfg(feature = "rows")]
pub use pivot::PivotAgg;
#[cfg(not(feature = "dynamic_groupby"))]
#[derive(Clone, Debug)]
pub struct DynamicGroupOptions {
pub index_column: String,
}
#[cfg(not(feature = "dynamic_groupby"))]
#[derive(Clone, Debug)]
pub struct RollingGroupOptions {
pub index_column: String,
}

pub use proxy::*;

pub type GroupedMap<T> = HashMap<T, Vec<u32>, RandomState>;

#[cfg(feature = "dynamic_groupby")]
pub use dynamic::*;

/// Used to create the tuples for a groupby operation.
pub trait IntoGroupsProxy {
/// Create the tuples need for a groupby operation.
Expand Down Expand Up @@ -572,6 +557,10 @@ impl<'df> GroupBy<'df> {
&mut self.groups
}

pub fn take_groups(self) -> GroupsProxy {
self.groups
}

pub fn keys(&self) -> Vec<Series> {
POOL.install(|| {
self.selected_keys
Expand Down
3 changes: 2 additions & 1 deletion polars/polars-core/src/frame/groupby/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ impl Default for GroupsProxy {
}

impl GroupsProxy {
pub(crate) fn into_idx(self) -> GroupsIdx {
#[cfg(feature = "private")]
pub fn into_idx(self) -> GroupsIdx {
match self {
GroupsProxy::Idx(groups) => groups,
GroupsProxy::Slice(groups) => groups
Expand Down
2 changes: 0 additions & 2 deletions polars/polars-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ pub mod series;
pub mod testing;
#[cfg(test)]
mod tests;
#[cfg(all(feature = "temporal", feature = "dtype-datetime"))]
pub mod time;
pub(crate) mod vector_hasher;

#[cfg(any(feature = "dtype-categorical", feature = "object"))]
Expand Down
3 changes: 0 additions & 3 deletions polars/polars-core/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ pub use crate::chunked_array::ops::unique::rank::{RankMethod, RankOptions};
#[cfg(feature = "rolling_window")]
pub use crate::chunked_array::ops::rolling_window::RollingOptions;

#[cfg(feature = "dynamic_groupby")]
pub use polars_time::{groupby::ClosedWindow, Duration};

#[cfg(feature = "ewma")]
pub use polars_arrow::kernels::ewm::EWMOptions;

Expand Down

0 comments on commit d0d25c6

Please sign in to comment.