Skip to content

Commit

Permalink
feat: Upgrade polars to v0.39
Browse files Browse the repository at this point in the history
This uses the new sorting API.
  • Loading branch information
jetuk committed Apr 25, 2024
1 parent 7cd980e commit aade2ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ thiserror = "1.0.25"
num = "0.4.0"
float-cmp = "0.9.0"
ndarray = "0.15.3"
polars = { version = "0.38.1", features = ["lazy", "rows", "ndarray"] }
polars = { version = "0.39", features = ["lazy", "rows", "ndarray"] }
pyo3-polars = "0.12.0"
pyo3 = { version = "0.20.2", default-features = false }
pyo3-log = "0.9.0"
Expand Down
6 changes: 5 additions & 1 deletion pywr-schema/src/timeseries/align_and_resample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ pub fn align_and_resample(
domain: &ModelDomain,
) -> Result<DataFrame, TimeseriesError> {
// Ensure type of time column is datetime and that it is sorted
let sort_options = SortMultipleOptions::default()
.with_order_descending(false)
.with_maintain_order(true);

let df = df
.clone()
.lazy()
.with_columns([col(time_col).cast(DataType::Datetime(TimeUnit::Nanoseconds, None))])
.collect()?
.sort([time_col], false, true)?;
.sort([time_col], sort_options)?;

// Ensure that df start aligns with models start for any resampling
let df = slice_start(df, time_col, domain)?;
Expand Down

0 comments on commit aade2ec

Please sign in to comment.