From 220fe2a15463b37f56e84f954511426e5edaa97b Mon Sep 17 00:00:00 2001 From: Malte Londschien <61679398+mlondschien@users.noreply.github.com> Date: Tue, 3 Oct 2023 09:09:35 +0200 Subject: [PATCH] Empty (#156) * Empty * clippy. * Bump maturin. * Upgrade some more versions. * add target also for macos-latest arm64 (is this correct?). * Update pyo3. * Back to a path dependency. * Prepare for release. --- .github/workflows/build.yml | 2 +- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- changeforest-py/Cargo.toml | 8 ++++---- changeforest-py/pyproject.toml | 6 +++--- changeforest-py/src/lib.rs | 2 +- changeforest-py/src/result.rs | 17 +---------------- changeforest-r/DESCRIPTION | 2 +- changeforest-r/src/rust/Cargo.toml | 2 +- src/fmt.rs | 2 +- 10 files changed, 20 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4c8fc9..2cccb5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,7 @@ jobs: platforms: arm64 - name: Install darwin target for apple silicon - if: matrix.vers == 'universal2' + if: matrix.vers == 'universal2' || (matrix.vers == 'arm64' && matrix.os == 'macos-latest') run: rustup target add aarch64-apple-darwin - name: Setup env when not using docker diff --git a/CHANGELOG.md b/CHANGELOG.md index 4243522..8cf3f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog +## 1.1.1 - (2023-10-03) + +**Other changes:** + +- Upgraded `pyo3` dependency in Python package. + ## 1.1.0 - (2023-08-01) **New features**: diff --git a/Cargo.toml b/Cargo.toml index 5fb94f8..da3eb0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "changeforest" description = "Random Forests for Change Point Detection" authors = ["Malte Londschien "] repository = "https://github.com/mlondschien/changeforest/" -version = "1.1.0" +version = "1.1.1" edition = "2021" readme = "README.md" license = "BSD-3-Clause" diff --git a/changeforest-py/Cargo.toml b/changeforest-py/Cargo.toml index 1d51fcb..55f8507 100644 --- a/changeforest-py/Cargo.toml +++ b/changeforest-py/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "changeforest_py" -version = "1.1.0" +version = "1.1.1" edition = "2021" [lib] @@ -11,8 +11,8 @@ crate-type = ["cdylib"] name = "changeforest" [dependencies] -numpy = "0.15" +numpy = "0.19" changeforest = { path = "../" } -ndarray = "0.15.3" -pyo3 = {version = "0.15", features = ["extension-module"]} +ndarray = "0.15" +pyo3 = {version = "0.19", features = ["extension-module"]} biosphere = "0.3.0" \ No newline at end of file diff --git a/changeforest-py/pyproject.toml b/changeforest-py/pyproject.toml index d2a5941..5e2b6b1 100644 --- a/changeforest-py/pyproject.toml +++ b/changeforest-py/pyproject.toml @@ -2,8 +2,8 @@ name = "changeforest" description = "Random Forests for Change Point Detection" readme = "README.md" -version = "1.1.0" -requires-python = ">=3.7" +version = "1.1.1" +requires-python = ">=3.8" author = "Malte Londschien " urls = {homepage = "https://github.com/mlondschien/changeforest/"} classifiers = [ @@ -12,7 +12,7 @@ classifiers = [ ] [build-system] -requires = ["maturin>=0.11,<0.12"] +requires = ["maturin>=1.0,<2.0"] build-backend = "maturin" [tool.isort] diff --git a/changeforest-py/src/lib.rs b/changeforest-py/src/lib.rs index 9676f8d..fda9794 100644 --- a/changeforest-py/src/lib.rs +++ b/changeforest-py/src/lib.rs @@ -3,7 +3,7 @@ mod result; use crate::control::control_from_pyobj; use crate::result::{MyBinarySegmentationResult, MyOptimizerResult}; -use changeforest::wrapper; +use ::changeforest::wrapper; use numpy::PyReadonlyArray2; use pyo3::prelude::{pymodule, PyModule, PyResult, Python}; use pyo3::PyObject; diff --git a/changeforest-py/src/result.rs b/changeforest-py/src/result.rs index ab956c1..35453ba 100644 --- a/changeforest-py/src/result.rs +++ b/changeforest-py/src/result.rs @@ -1,9 +1,9 @@ // Wrap GainResult, OptimizerResult and BinarySegmentationResult. // See https://github.com/PyO3/pyo3/issues/287. +use ::changeforest::{BinarySegmentationResult, ModelSelectionResult}; use changeforest::gain::GainResult; use changeforest::optimizer::OptimizerResult; -use changeforest::{BinarySegmentationResult, ModelSelectionResult}; use numpy::{PyArray1, PyArray2, ToPyArray}; use pyo3::prelude::*; @@ -24,10 +24,7 @@ impl MyModelSelectionResult { pub fn p_value(&self) -> Option { self.result.p_value } -} -#[pyproto] -impl pyo3::class::basic::PyObjectProtocol for MyModelSelectionResult { fn __repr__(&self) -> PyResult { Ok(format!("{}", self.result)) } @@ -70,10 +67,7 @@ impl MyGainResult { pub fn predictions<'py>(&self, py: Python<'py>) -> Option<&'py PyArray1> { self.result.predictions().map(|arr| arr.to_pyarray(py)) } -} -#[pyproto] -impl pyo3::class::basic::PyObjectProtocol for MyGainResult { fn __repr__(&self) -> PyResult { Ok(format!("{}", self.result)) } @@ -117,13 +111,7 @@ impl MyOptimizerResult { }) .collect() } -} -#[pyproto] -// https://stackoverflow.com/questions/62666926/str-function-of-class-ported-from-\ -// rust-to-python-using-pyo3-doesnt-get-used -// https://pyo3.rs/v0.9.2/python_from_rust.html -impl pyo3::class::basic::PyObjectProtocol for MyOptimizerResult { fn __repr__(&self) -> PyResult { Ok(format!("{}", self.result)) } @@ -228,10 +216,7 @@ impl MyBinarySegmentationResult { fn split_points(&self) -> Vec { self.result.split_points() } -} -#[pyproto] -impl pyo3::class::basic::PyObjectProtocol for MyBinarySegmentationResult { fn __repr__(&self) -> PyResult { Ok(format!("{}", self.result)) } diff --git a/changeforest-r/DESCRIPTION b/changeforest-r/DESCRIPTION index f02c536..3ea99c9 100644 --- a/changeforest-r/DESCRIPTION +++ b/changeforest-r/DESCRIPTION @@ -1,7 +1,7 @@ Package: changeforest Type: Package Title: Random Forests for Change Point Detection -Version: 1.1.0 +Version: 1.1.1 Author: Malte Londschien Maintainer: Malte Londschien Description: diff --git a/changeforest-r/src/rust/Cargo.toml b/changeforest-r/src/rust/Cargo.toml index dbf2382..6c01ab6 100644 --- a/changeforest-r/src/rust/Cargo.toml +++ b/changeforest-r/src/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'changeforestr' -version = '1.1.0' +version = '1.1.1' edition = '2021' [lib] diff --git a/src/fmt.rs b/src/fmt.rs index c097503..2b659c6 100644 --- a/src/fmt.rs +++ b/src/fmt.rs @@ -3,7 +3,7 @@ use std::fmt::Display; impl Display for BinarySegmentationResult { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let mut max_lengths = vec![0; 4]; + let mut max_lengths = [0; 4]; let mut rows = _format_tree(self); rows.insert( 0,