Skip to content

Commit

Permalink
Empty (#156)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mlondschien authored Oct 3, 2023
1 parent a53e571 commit 220fe2a
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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**:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "changeforest"
description = "Random Forests for Change Point Detection"
authors = ["Malte Londschien <[email protected]>"]
repository = "https://github.com/mlondschien/changeforest/"
version = "1.1.0"
version = "1.1.1"
edition = "2021"
readme = "README.md"
license = "BSD-3-Clause"
Expand Down
8 changes: 4 additions & 4 deletions changeforest-py/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "changeforest_py"
version = "1.1.0"
version = "1.1.1"
edition = "2021"

[lib]
Expand All @@ -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"
6 changes: 3 additions & 3 deletions changeforest-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"
urls = {homepage = "https://github.com/mlondschien/changeforest/"}
classifiers = [
Expand All @@ -12,7 +12,7 @@ classifiers = [
]

[build-system]
requires = ["maturin>=0.11,<0.12"]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[tool.isort]
Expand Down
2 changes: 1 addition & 1 deletion changeforest-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 1 addition & 16 deletions changeforest-py/src/result.rs
Original file line number Diff line number Diff line change
@@ -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::*;

Expand All @@ -24,10 +24,7 @@ impl MyModelSelectionResult {
pub fn p_value(&self) -> Option<f64> {
self.result.p_value
}
}

#[pyproto]
impl pyo3::class::basic::PyObjectProtocol for MyModelSelectionResult {
fn __repr__(&self) -> PyResult<String> {
Ok(format!("{}", self.result))
}
Expand Down Expand Up @@ -70,10 +67,7 @@ impl MyGainResult {
pub fn predictions<'py>(&self, py: Python<'py>) -> Option<&'py PyArray1<f64>> {
self.result.predictions().map(|arr| arr.to_pyarray(py))
}
}

#[pyproto]
impl pyo3::class::basic::PyObjectProtocol for MyGainResult {
fn __repr__(&self) -> PyResult<String> {
Ok(format!("{}", self.result))
}
Expand Down Expand Up @@ -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<String> {
Ok(format!("{}", self.result))
}
Expand Down Expand Up @@ -228,10 +216,7 @@ impl MyBinarySegmentationResult {
fn split_points(&self) -> Vec<usize> {
self.result.split_points()
}
}

#[pyproto]
impl pyo3::class::basic::PyObjectProtocol for MyBinarySegmentationResult {
fn __repr__(&self) -> PyResult<String> {
Ok(format!("{}", self.result))
}
Expand Down
2 changes: 1 addition & 1 deletion changeforest-r/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
Description:
Expand Down
2 changes: 1 addition & 1 deletion changeforest-r/src/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'changeforestr'
version = '1.1.0'
version = '1.1.1'
edition = '2021'

[lib]
Expand Down
2 changes: 1 addition & 1 deletion src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 220fe2a

Please sign in to comment.