From f0cb934130365a99e660425bcd74a75b76e4584b Mon Sep 17 00:00:00 2001 From: Stefano Simonelli <16114781+s-simoncelli@users.noreply.github.com> Date: Sun, 20 Aug 2023 13:29:26 +0100 Subject: [PATCH 1/2] Updated polars to 0.32.0 --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 93c2898b..25d8794f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,8 @@ highs-sys = { git = "https://github.com/jetuk/highs-sys", branch="fix-build-lib # highs-sys = { path = "../../highs-sys" } pyo3 = { version = "0.19.0" } rayon = "1.6.1" -polars = { version = "0.30.0", features = ["lazy", "rows", "ndarray"] } -pyo3-polars = "0.4.0" +polars = { version = "0.32.0", features = ["lazy", "rows", "ndarray"] } +pyo3-polars = "0.6.0" pywr-schema = { git = "https://github.com/pywr/pywr-schema/", tag="v0.6.0" } rhai = { version="1.12.0", features=["sync"] } From 044f969852ca0c803306ad02c5fd36fae176b6e0 Mon Sep 17 00:00:00 2001 From: Stefano Simonelli <16114781+s-simoncelli@users.noreply.github.com> Date: Sun, 20 Aug 2023 13:31:01 +0100 Subject: [PATCH 2/2] Pass default IndexOrder in to_ndarray --- src/schema/parameters/data_frame.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/schema/parameters/data_frame.rs b/src/schema/parameters/data_frame.rs index e722f398..387998de 100644 --- a/src/schema/parameters/data_frame.rs +++ b/src/schema/parameters/data_frame.rs @@ -4,7 +4,7 @@ use crate::schema::parameters::{DynamicFloatValueType, ParameterMeta}; use crate::{ParameterIndex, PywrError}; use ndarray::Array2; use polars::prelude::DataType::Float64; -use polars::prelude::{DataFrame, Float64Type}; +use polars::prelude::{DataFrame, Float64Type, IndexOrder}; use pyo3::prelude::PyModule; use pyo3::types::{PyDict, PyTuple}; use pyo3::{IntoPy, PyErr, PyObject, Python, ToPyObject}; @@ -124,7 +124,7 @@ impl DataFrameParameter { match &self.columns { DataFrameColumns::Scenario(scenario) => { let scenario_group = model.get_scenario_group_index_by_name(scenario)?; - let array: Array2 = df.to_ndarray::().unwrap(); + let array: Array2 = df.to_ndarray::(IndexOrder::default()).unwrap(); let p = Array2Parameter::new(&self.meta.name, array, scenario_group); model.add_parameter(Box::new(p)) }