From 06fd8d36c8be71030aa29235b47fab707333b6ee Mon Sep 17 00:00:00 2001 From: Konstantin Malanchev Date: Tue, 2 Dec 2025 10:34:59 -0500 Subject: [PATCH 1/4] Rust edition 2021->2024 --- rust/Cargo.toml | 2 +- rust/src/selector.rs | 2 +- rust/src/tree_traversal.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index eee2e75..8b75391 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "coniferest" version = "0.1.2" -edition = "2021" +edition = "2024" [lib] name = "calc_trees" diff --git a/rust/src/selector.rs b/rust/src/selector.rs index 498f12d..2b2df20 100644 --- a/rust/src/selector.rs +++ b/rust/src/selector.rs @@ -2,7 +2,7 @@ use numpy::{Element, PyArrayDescr}; use pyo3::prelude::{PyAnyMethods, PyDictMethods}; use pyo3::sync::GILOnceCell; use pyo3::types::PyDict; -use pyo3::{py_run, Bound, Py, PyResult, Python}; +use pyo3::{Bound, Py, PyResult, Python, py_run}; static SELECTOR_DTYPE_CELL: GILOnceCell> = GILOnceCell::new(); diff --git a/rust/src/tree_traversal.rs b/rust/src/tree_traversal.rs index f11b788..573e959 100644 --- a/rust/src/tree_traversal.rs +++ b/rust/src/tree_traversal.rs @@ -7,7 +7,7 @@ use num_traits::AsPrimitive; use numpy::{Element, PyArray1, PyArray2, PyArrayMethods}; use pyo3::exceptions::PyValueError; use pyo3::prelude::PyAnyMethods; -use pyo3::{pyfunction, Bound, FromPyObject, PyResult, Python}; +use pyo3::{Bound, FromPyObject, PyResult, Python, pyfunction}; type DeltaSumHitCount<'py> = (Bound<'py, PyArray2>, Bound<'py, PyArray2>); From 9a6e07240ba7e6c76cc016ba74bee8348d3b7c73 Mon Sep 17 00:00:00 2001 From: Konstantin Malanchev Date: Tue, 2 Dec 2025 10:38:32 -0500 Subject: [PATCH 2/4] Bump PyO3 and numpy to 0.27 --- rust/Cargo.lock | 25 ++++++++++++------------- rust/Cargo.toml | 4 ++-- rust/src/selector.rs | 8 ++++---- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index f46bb0e..bec1891 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "numpy" -version = "0.25.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f1dee9aa8d3f6f8e8b9af3803006101bb3653866ef056d530d53ae68587191" +checksum = "0fa24ffc88cf9d43f7269d6b6a0d0a00010924a8cc90604a21ef9c433b66998d" dependencies = [ "libc", "ndarray", @@ -204,9 +204,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.25.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a" +checksum = "ab53c047fcd1a1d2a8820fe84f05d6be69e9526be40cb03b73f86b6b03e6d87d" dependencies = [ "indoc", "libc", @@ -221,19 +221,18 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.25.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598" +checksum = "b455933107de8642b4487ed26d912c2d899dec6114884214a0b3bb3be9261ea6" dependencies = [ - "once_cell", "target-lexicon", ] [[package]] name = "pyo3-ffi" -version = "0.25.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c" +checksum = "1c85c9cbfaddf651b1221594209aed57e9e5cff63c4d11d1feead529b872a089" dependencies = [ "libc", "pyo3-build-config", @@ -241,9 +240,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.25.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50" +checksum = "0a5b10c9bf9888125d917fb4d2ca2d25c8df94c7ab5a52e13313a07e050a3b02" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -253,9 +252,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.25.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc" +checksum = "03b51720d314836e53327f5871d4c0cfb4fb37cc2c4a11cc71907a86342c40f9" dependencies = [ "heck", "proc-macro2", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 8b75391..0d23307 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -22,10 +22,10 @@ default = ["pyo3/abi3-py310"] [dependencies] enum_dispatch = "0.3" itertools = "0.14" -pyo3 = { version = "0.25", features = ["extension-module"] } +pyo3 = { version = "0.27", features = ["extension-module"] } # Needs to be consistent with ndarray dependency in numpy ndarray = { version = "0.16", features = ["rayon"] } num-traits = "0.2" -numpy = "0.25" +numpy = "0.27" # Needs to be consistent with rayon dependency in ndarray rayon = "1.11" diff --git a/rust/src/selector.rs b/rust/src/selector.rs index 2b2df20..5bc6757 100644 --- a/rust/src/selector.rs +++ b/rust/src/selector.rs @@ -1,10 +1,10 @@ use numpy::{Element, PyArrayDescr}; -use pyo3::prelude::{PyAnyMethods, PyDictMethods}; -use pyo3::sync::GILOnceCell; +use pyo3::prelude::PyDictMethods; +use pyo3::sync::PyOnceLock; use pyo3::types::PyDict; use pyo3::{Bound, Py, PyResult, Python, py_run}; -static SELECTOR_DTYPE_CELL: GILOnceCell> = GILOnceCell::new(); +static SELECTOR_DTYPE_CELL: PyOnceLock> = PyOnceLock::new(); /// Selector is the representation of decision tree nodes: either branches or leafs. /// @@ -50,7 +50,7 @@ impl Selector { .get_item("dtype") .expect("Error in built-in Python code for dtype initialization") .expect("Error in built-in Python code for dtype initialization: dtype cannot be None") - .downcast::()?.clone() + .cast::()?.clone() .unbind()) })?; Ok(unbind_dtype.bind(py).clone()) From e9b5489fa1bdbfcdd5266d0bd0217a8892749819 Mon Sep 17 00:00:00 2001 From: Konstantin Malanchev Date: Tue, 2 Dec 2025 10:40:58 -0500 Subject: [PATCH 3/4] Bump ndarray to 0.17 --- rust/Cargo.lock | 19 +++++++++++++++++-- rust/Cargo.toml | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index bec1891..b5c9e68 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -14,7 +14,7 @@ version = "0.1.2" dependencies = [ "enum_dispatch", "itertools", - "ndarray", + "ndarray 0.17.1", "num-traits", "numpy", "pyo3", @@ -118,6 +118,21 @@ name = "ndarray" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "portable-atomic", + "portable-atomic-util", + "rawpointer", +] + +[[package]] +name = "ndarray" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7c9125e8f6f10c9da3aad044cc918cf8784fa34de857b1aa68038eb05a50a9" dependencies = [ "matrixmultiply", "num-complex", @@ -163,7 +178,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa24ffc88cf9d43f7269d6b6a0d0a00010924a8cc90604a21ef9c433b66998d" dependencies = [ "libc", - "ndarray", + "ndarray 0.16.1", "num-complex", "num-integer", "num-traits", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 0d23307..2927468 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -24,7 +24,7 @@ enum_dispatch = "0.3" itertools = "0.14" pyo3 = { version = "0.27", features = ["extension-module"] } # Needs to be consistent with ndarray dependency in numpy -ndarray = { version = "0.16", features = ["rayon"] } +ndarray = { version = "0.17", features = ["rayon"] } num-traits = "0.2" numpy = "0.27" # Needs to be consistent with rayon dependency in ndarray From 1427a7e1569629db1fa6947f698e7cfc2834fba0 Mon Sep 17 00:00:00 2001 From: Konstantin Malanchev Date: Tue, 2 Dec 2025 13:59:09 -0500 Subject: [PATCH 4/4] numpy 0.27.1, because it supports ndarray 0.17 --- rust/Cargo.lock | 23 ++++------------------- rust/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index b5c9e68..0db26df 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -14,7 +14,7 @@ version = "0.1.2" dependencies = [ "enum_dispatch", "itertools", - "ndarray 0.17.1", + "ndarray", "num-traits", "numpy", "pyo3", @@ -113,21 +113,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "ndarray" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" -dependencies = [ - "matrixmultiply", - "num-complex", - "num-integer", - "num-traits", - "portable-atomic", - "portable-atomic-util", - "rawpointer", -] - [[package]] name = "ndarray" version = "0.17.1" @@ -173,12 +158,12 @@ dependencies = [ [[package]] name = "numpy" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa24ffc88cf9d43f7269d6b6a0d0a00010924a8cc90604a21ef9c433b66998d" +checksum = "7aac2e6a6e4468ffa092ad43c39b81c79196c2bb773b8db4085f695efe3bba17" dependencies = [ "libc", - "ndarray 0.16.1", + "ndarray", "num-complex", "num-integer", "num-traits", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 2927468..9e114e8 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -26,6 +26,6 @@ pyo3 = { version = "0.27", features = ["extension-module"] } # Needs to be consistent with ndarray dependency in numpy ndarray = { version = "0.17", features = ["rayon"] } num-traits = "0.2" -numpy = "0.27" +numpy = "0.27.1" # Needs to be consistent with rayon dependency in ndarray rayon = "1.11"