Skip to content

Commit ccb60aa

Browse files
committed
Version updates
1 parent 67e48ac commit ccb60aa

6 files changed

Lines changed: 37 additions & 32 deletions

File tree

.github/workflows/wheels.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ jobs:
1212
strategy:
1313
matrix:
1414
container:
15+
- "quay.io/pypa/musllinux_1_2_x86_64"
1516
- "quay.io/pypa/manylinux2014_x86_64"
1617
- "quay.io/pypa/manylinux_2_28_x86_64"
1718
container: ${{ matrix.container }}
1819
steps:
19-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2021
- name: Build wheels
2122
run: |
2223
bash .github/workflows/build-wheels.sh
23-
- uses: actions/upload-artifact@v3
24+
- uses: actions/upload-artifact@v4
2425
with:
2526
name: wheels
2627
path: wheelhouse
@@ -31,17 +32,18 @@ jobs:
3132
strategy:
3233
matrix:
3334
container:
35+
- "quay.io/pypa/musllinux_1_2_aarch64"
3436
- "quay.io/pypa/manylinux2014_aarch64"
3537
- "quay.io/pypa/manylinux_2_28_aarch64"
3638
steps:
37-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4
3840
- name: Install QEMU
3941
run: |
4042
docker run --privileged --rm tonistiigi/binfmt --install arm64
4143
- name: Build wheels
4244
run: |
4345
docker run --platform linux/arm64 --workdir /src -v ${PWD}:/src ${{ matrix.container }} /bin/bash .github/workflows/build-wheels.sh
44-
- uses: actions/upload-artifact@v3
46+
- uses: actions/upload-artifact@v4
4547
with:
4648
name: wheels
4749
path: wheelhouse
@@ -51,9 +53,9 @@ jobs:
5153
runs-on: macos-latest
5254
strategy:
5355
matrix:
54-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
56+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
5557
steps:
56-
- uses: actions/checkout@v3
58+
- uses: actions/checkout@v4
5759
- uses: actions-rs/toolchain@v1
5860
with:
5961
toolchain: stable
@@ -68,7 +70,7 @@ jobs:
6870
maturin build --release --strip --target universal2-apple-darwin
6971
python3 -m pip install kmedoids --no-index --find-links target/wheels
7072
cd tests && python3 -m unittest discover && cd ..
71-
- uses: actions/upload-artifact@v3
73+
- uses: actions/upload-artifact@v4
7274
with:
7375
name: wheels
7476
path: target/wheels
@@ -78,9 +80,9 @@ jobs:
7880
runs-on: windows-latest
7981
strategy:
8082
matrix:
81-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
83+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
8284
steps:
83-
- uses: actions/checkout@v3
85+
- uses: actions/checkout@v4
8486
- uses: actions-rs/toolchain@v1
8587
with:
8688
toolchain: stable
@@ -94,7 +96,7 @@ jobs:
9496
maturin build --release --strip
9597
python -m pip install kmedoids --no-index --find-links target/wheels
9698
cd tests && python -m unittest discover && cd ..
97-
- uses: actions/upload-artifact@v3
99+
- uses: actions/upload-artifact@v4
98100
with:
99101
name: wheels
100102
path: target/wheels
@@ -106,7 +108,7 @@ jobs:
106108
runs-on: ubuntu-latest
107109
steps:
108110
- name: Collect artifacts
109-
uses: actions/download-artifact@v3
111+
uses: actions/download-artifact@v4
110112
with:
111113
name: wheels
112114
path: wheels/

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
For changes to the main Rust package, please see <https://github.com/kno10/rust-kmedoids/blob/main/CHANGELOG.md>
44

5+
## kmedoids 0.5.2 (2024-09-10)
6+
7+
- fix clippy warnings
8+
- update to pyo3 0.21, numpy 0.21
9+
- update github action for python 3.13 and musllinux
10+
511
## kmedoids 0.5.1 (2024-03-14)
612

713
- DynMSC: best loss reported incorrectly if best k=2

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ authors:
1010
title: "Fast k-medoids Clustering in Rust and Python"
1111
journal: "J. Open Source Softw."
1212
doi: 10.21105/joss.04183
13-
version: 0.5.1
14-
date-released: 2024-03-14
13+
version: 0.5.2
14+
date-released: 2024-09-10
1515
license: GPL-3.0
1616
preferred-citation:
1717
title: "Fast k-medoids Clustering in Rust and Python"

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
edition = "2021"
33
name = "kmedoids"
4-
version = "0.5.1"
4+
version = "0.5.2"
55
authors = ["Erich Schubert <erich.schubert@tu-dortmund.de>", "Lars Lenssen <lars.lenssen@tu-dortmund.de>"]
66
description = "k-Medoids clustering with the FasterPAM algorithm"
77
homepage = "https://github.com/kno10/python-kmedoids"
@@ -14,13 +14,13 @@ name = "kmedoids"
1414
crate-type = ["cdylib"]
1515

1616
[dependencies]
17-
rustkmedoids = { version = "0.5.1", package = "kmedoids", git = "https://github.com/kno10/rust-kmedoids" }
18-
numpy = "0.20"
17+
rustkmedoids = { version = "0.5.2", package = "kmedoids", git = "https://github.com/kno10/rust-kmedoids" }
18+
numpy = "0.21"
1919
ndarray = "0.15"
2020
rand = "0.8"
21-
rayon = "1.9"
21+
rayon = "1.10"
2222

2323
[dependencies.pyo3]
24-
version = "0.20"
24+
version = "^0.21"
2525
features = ["extension-module"]
2626

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "kmedoids"
7-
version = "0.5.1"
7+
version = "0.5.2"
88
description = "k-Medoids Clustering in Python with FasterPAM"
99
requires-dist = ["numpy"]
1010
classifier = [

src/lib.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use pyo3::prelude::*;
22
use pyo3::wrap_pyfunction;
3-
use numpy::{PyArray1, PyReadonlyArray1, PyReadonlyArray2};
3+
use numpy::{PyArray1, PyReadonlyArray1, PyReadonlyArray2, PyArrayMethods, PyUntypedArrayMethods};
44
use rand::{rngs::StdRng, SeedableRng};
5-
use rayon;
6-
use rustkmedoids;
75

86
macro_rules! variant_call {
97
($name:ident, $variant:ident, $type: ty, $ltype: ty) => {
@@ -24,7 +22,7 @@ fn $name(dist: PyReadonlyArray2<'_, $type>, meds: PyReadonlyArray1<'_, usize>, m
2422
let mut meds = meds.to_vec()?;
2523
let (loss, assi, n_iter, n_swap): ($ltype, _, _, _) = rustkmedoids::$variant(&dist.as_array(), &mut meds, max_iter);
2624
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
27-
Ok((loss, PyArray1::from_vec(py, assi), PyArray1::from_vec(py, meds), n_iter, n_swap).to_object(py))
25+
Ok((loss, PyArray1::from_vec_bound(py, assi), PyArray1::from_vec_bound(py, meds), n_iter, n_swap).to_object(py))
2826
})
2927
}
3028
}}
@@ -71,7 +69,7 @@ fn $name(dist: PyReadonlyArray2<'_, $type>, meds: PyReadonlyArray1<'_, usize>, m
7169
let mut rnd = StdRng::seed_from_u64(seed);
7270
let (loss, assi, n_iter, n_swap): ($ltype, _, _, _) = rustkmedoids::$variant(&dist.as_array(), &mut meds, max_iter, &mut rnd);
7371
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
74-
Ok((loss, PyArray1::from_vec(py, assi), PyArray1::from_vec(py, meds), n_iter, n_swap).to_object(py))
72+
Ok((loss, PyArray1::from_vec_bound(py, assi), PyArray1::from_vec_bound(py, meds), n_iter, n_swap).to_object(py))
7573
})
7674
}
7775
}}
@@ -108,7 +106,7 @@ fn $name(dist: PyReadonlyArray2<'_, $type>, meds: PyReadonlyArray1<'_, usize>, m
108106
rustkmedoids::$variant(&dist, &mut meds, max_iter, &mut rnd)
109107
});
110108
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
111-
Ok((loss, PyArray1::from_vec(py, assi), PyArray1::from_vec(py, meds), n_iter, n_swap).to_object(py))
109+
Ok((loss, PyArray1::from_vec_bound(py, assi), PyArray1::from_vec_bound(py, meds), n_iter, n_swap).to_object(py))
112110
})
113111
}
114112
}}
@@ -133,7 +131,7 @@ fn $name(dist: PyReadonlyArray2<'_, $type>, k: usize) -> PyResult<Py<PyAny>> {
133131
assert_eq!(dist.shape()[0], dist.shape()[1]);
134132
let (loss, assi, meds): ($ltype, _, _) = rustkmedoids::pam_build(&dist.as_array(), k);
135133
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
136-
Ok((loss, PyArray1::from_vec(py, assi), PyArray1::from_vec(py, meds), 1).to_object(py))
134+
Ok((loss, PyArray1::from_vec_bound(py, assi), PyArray1::from_vec_bound(py, meds), 1).to_object(py))
137135
})
138136
}
139137
}}
@@ -161,7 +159,7 @@ fn $name(dist: PyReadonlyArray2<'_, $type>, meds: PyReadonlyArray1<'_, usize>, m
161159
let mut meds = meds.to_vec()?;
162160
let (loss, assi, n_iter): ($ltype, _, _) = rustkmedoids::alternating(&dist.as_array(), &mut meds, max_iter);
163161
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
164-
Ok((loss, PyArray1::from_vec(py, assi), PyArray1::from_vec(py, meds), n_iter).to_object(py))
162+
Ok((loss, PyArray1::from_vec_bound(py, assi), PyArray1::from_vec_bound(py, meds), n_iter).to_object(py))
165163
})
166164
}
167165
}}
@@ -191,7 +189,7 @@ fn $name(dist: PyReadonlyArray2<'_, $type>, meds: PyReadonlyArray1<'_, usize>, m
191189
let (loss, assi, n_iter, n_swap, best_meds, losses): ($ltype, _, _, _, _, _) = rustkmedoids::dynmsc(&dist.as_array(), &mut meds, minimum_k, max_iter);
192190
let bestk = best_meds.len();
193191
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
194-
Ok((loss, PyArray1::from_vec(py, assi), PyArray1::from_vec(py, best_meds), bestk, PyArray1::from_vec(py, losses), (minimum_k..maxk).collect::<Vec<usize>>(), n_iter, n_swap).to_object(py))
192+
Ok((loss, PyArray1::from_vec_bound(py, assi), PyArray1::from_vec_bound(py, best_meds), bestk, PyArray1::from_vec_bound(py, losses), (minimum_k..maxk).collect::<Vec<usize>>(), n_iter, n_swap).to_object(py))
195193
})
196194
}
197195
}}
@@ -216,7 +214,7 @@ fn $name(dist: PyReadonlyArray2<'_, $type>, assi: PyReadonlyArray1<'_, usize>, s
216214
assert_eq!(dist.shape()[0], dist.shape()[1]);
217215
let (sil, sils): (f64, _) = rustkmedoids::silhouette(&dist.as_array(), &assi.to_vec()?, samples);
218216
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
219-
Ok((sil, PyArray1::from_vec(py, sils)).to_object(py))
217+
Ok((sil, PyArray1::from_vec_bound(py, sils)).to_object(py))
220218
})
221219
}
222220
}}
@@ -271,7 +269,7 @@ fn $name(dist: PyReadonlyArray2<'_, $type>, meds: PyReadonlyArray1<'_, usize>, s
271269
assert_eq!(dist.shape()[0], dist.shape()[1]);
272270
let (sil, sils): (f64, _) = rustkmedoids::medoid_silhouette(&dist.as_array(), &meds.to_vec()?, samples);
273271
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
274-
Ok((sil, PyArray1::from_vec(py, sils)).to_object(py))
272+
Ok((sil, PyArray1::from_vec_bound(py, sils)).to_object(py))
275273
})
276274
}
277275
}}
@@ -282,7 +280,7 @@ medoid_silhouette_call!(medoid_silhouette_i32, i32);
282280

283281
#[pymodule]
284282
#[allow(unused_variables)]
285-
fn kmedoids(py: Python, m: &PyModule) -> PyResult<()> {
283+
fn kmedoids(m: &Bound<'_, PyModule>) -> PyResult<()> {
286284
m.add("_fasterpam_f32", wrap_pyfunction!(fasterpam_f32, m)?)?;
287285
m.add("_fasterpam_f64", wrap_pyfunction!(fasterpam_f64, m)?)?;
288286
m.add("_fasterpam_i32", wrap_pyfunction!(fasterpam_i32, m)?)?;
@@ -335,4 +333,3 @@ fn kmedoids(py: Python, m: &PyModule) -> PyResult<()> {
335333
// not supported: m.add("_medoid_silhouette_i64", wrap_pyfunction!(medoid_silhouette_i64, m)?)?;
336334
Ok(())
337335
}
338-

0 commit comments

Comments
 (0)