Skip to content

Commit

Permalink
downgrade rust dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjinliu committed Jan 7, 2025
1 parent dc4c551 commit 39e85d7
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
platform: [ubuntu-latest, macos-latest, windows-latest]

steps:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ name = "_cylindra_ext"
crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.23.3"
numpy = "0.23.0"
pyo3 = "0.22.6"
numpy = "0.22.1" # NOTE: numpy=0.23.0 fails to compile in some OS
rand = "0.8.5"
mt19937 = "2.0.1"
num = { version = "0.4.0", features = ["std"] }
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ dependencies = [
"pyqtgraph>=0.12.4",
"pyarrow>=11.0.0",
"numpy>=1.23.0",
"scipy>=1.11.3",
"scipy>=1.11.3,!=1.15.0", # See https://github.com/scipy/scipy/issues/22271#issuecomment-2574884519
"pandas>=1.5.0",
"polars>=1.1.0",
"polars>=1.19.0",
"scikit-image>=0.21.0",
"napari>=0.5.1",
"qtpy>=2.3.1",
Expand Down
4 changes: 2 additions & 2 deletions src/alleviate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn alleviate<'py>(
let mut arr = arr.to_owned();
if indices.len() == 0 {
// nothing to do.
return Ok(arr.into_pyarray(py).unbind());
return Ok(arr.into_pyarray_bound(py).unbind());
}
let geometry = CylinderGeometry::new(ny, na, nrise);
let mut processed = HashSet::new();
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn alleviate<'py>(
return value_error!("Infinite recursion occurred.");
}
}
Ok(arr.into_pyarray(py).unbind())
Ok(arr.into_pyarray_bound(py).unbind())
}

fn local_average(neighbor: &Index, arr: &Array3<f32>, geometry: &CylinderGeometry) -> PyResult<(f32, f32, f32)> {
Expand Down
14 changes: 7 additions & 7 deletions src/annealing/models/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,25 @@ impl CylindricAnnealingModel {

/// Get all the existing distances of longitudinal connections as a numpy array.
pub fn longitudinal_distances<'py>(&self, py: Python<'py>) -> Py<PyArray1<f32>> {
self.graph.get_longitudinal_distances().into_pyarray(py).into()
self.graph.get_longitudinal_distances().into_pyarray_bound(py).into()
}

/// Get all the existing distances of lateral connections as a numpy array.
pub fn lateral_distances<'py>(&self, py: Python<'py>) -> Py<PyArray1<f32>> {
self.graph.get_lateral_distances().into_pyarray(py).into()
self.graph.get_lateral_distances().into_pyarray_bound(py).into()
}

pub fn longitudinal_angles<'py>(&self, py: Python<'py>) -> Py<PyArray1<f32>> {
self.graph.get_longitudinal_angles().into_pyarray(py).into()
self.graph.get_longitudinal_angles().into_pyarray_bound(py).into()
}

pub fn lateral_angles<'py>(&self, py: Python<'py>) -> Py<PyArray1<f32>> {
self.graph.get_lateral_angles().into_pyarray(py).into()
self.graph.get_lateral_angles().into_pyarray_bound(py).into()
}

pub fn get_edge_info<'py>(&self, py: Python<'py>) -> (Py<PyArray2<f32>>, Py<PyArray2<f32>>, Py<PyArray1<i32>>) {
let (out0, out1, out2) = self.graph.get_edge_states();
(out0.into_pyarray(py).into(), out1.into_pyarray(py).into(), out2.into_pyarray(py).into())
(out0.into_pyarray_bound(py).into(), out1.into_pyarray_bound(py).into(), out2.into_pyarray_bound(py).into())
}

#[pyo3(signature = (indices, npf, nrise))]
Expand Down Expand Up @@ -199,7 +199,7 @@ impl CylindricAnnealingModel {

/// Get integer shift in each local coordinates as a numpy array.
pub fn shifts<'py>(&self, py: Python<'py>) -> Py<PyArray2<isize>> {
self.graph.get_shifts().into_pyarray(py).into()
self.graph.get_shifts().into_pyarray_bound(py).into()
}

pub fn set_shifts<'py>(
Expand All @@ -223,7 +223,7 @@ impl CylindricAnnealingModel {

pub fn binding_energies<'py>(&self, py: Python<'py>) -> (Py<PyArray1<f32>>, Py<PyArray1<f32>>) {
let (lon, lat) = self.graph.binding_energies();
(lon.into_pyarray(py).into(), lat.into_pyarray(py).into())
(lon.into_pyarray_bound(py).into(), lat.into_pyarray_bound(py).into())
}

/// Get current optimization state as a string.
Expand Down
14 changes: 7 additions & 7 deletions src/annealing/models/defective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,25 @@ impl DefectiveCylindricAnnealingModel {

/// Get all the existing distances of longitudinal connections as a numpy array.
pub fn longitudinal_distances<'py>(&self, py: Python<'py>) -> Py<PyArray1<f32>> {
self.graph.get_longitudinal_distances().into_pyarray(py).into()
self.graph.get_longitudinal_distances().into_pyarray_bound(py).into()
}

/// Get all the existing distances of lateral connections as a numpy array.
pub fn lateral_distances<'py>(&self, py: Python<'py>) -> Py<PyArray1<f32>> {
self.graph.get_lateral_distances().into_pyarray(py).into()
self.graph.get_lateral_distances().into_pyarray_bound(py).into()
}

pub fn longitudinal_angles<'py>(&self, py: Python<'py>) -> Py<PyArray1<f32>> {
self.graph.get_longitudinal_angles().into_pyarray(py).into()
self.graph.get_longitudinal_angles().into_pyarray_bound(py).into()
}

pub fn lateral_angles<'py>(&self, py: Python<'py>) -> Py<PyArray1<f32>> {
self.graph.get_lateral_angles().into_pyarray(py).into()
self.graph.get_lateral_angles().into_pyarray_bound(py).into()
}

pub fn get_edge_info<'py>(&self, py: Python<'py>) -> (Py<PyArray2<f32>>, Py<PyArray2<f32>>, Py<PyArray1<i32>>) {
let (out0, out1, out2) = self.graph.get_edge_states();
(out0.into_pyarray(py).into(), out1.into_pyarray(py).into(), out2.into_pyarray(py).into())
(out0.into_pyarray_bound(py).into(), out1.into_pyarray_bound(py).into(), out2.into_pyarray_bound(py).into())
}

#[pyo3(signature = (indices, npf, nrise))]
Expand Down Expand Up @@ -219,7 +219,7 @@ impl DefectiveCylindricAnnealingModel {

/// Get integer shift in each local coordinates as a numpy array.
pub fn shifts<'py>(&self, py: Python<'py>) -> Py<PyArray2<isize>> {
self.graph.get_shifts().into_pyarray(py).into()
self.graph.get_shifts().into_pyarray_bound(py).into()
}

pub fn set_shifts<'py>(
Expand All @@ -243,7 +243,7 @@ impl DefectiveCylindricAnnealingModel {

pub fn binding_energies<'py>(&self, py: Python<'py>) -> (Py<PyArray1<f32>>, Py<PyArray1<f32>>) {
let (lon, lat) = self.graph.binding_energies();
(lon.into_pyarray(py).into(), lat.into_pyarray(py).into())
(lon.into_pyarray_bound(py).into(), lat.into_pyarray_bound(py).into())
}

/// Get current optimization state as a string.
Expand Down
4 changes: 2 additions & 2 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn oblique_coordinates<'py>(
out[[i, 0]] = (nth + npf * tan1) * d0 + c0;
out[[i, 1]] = (nth * tan0 + npf) * d1 + c1;
}
Ok(out.into_pyarray(py).unbind())
Ok(out.into_pyarray_bound(py).unbind())

}

Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn cylinder_faces<'py>(
out_vert[[i, 2]] = v.2;
}

Ok(out_vert.into_pyarray(py).unbind())
Ok(out_vert.into_pyarray_bound(py).unbind())
}

#[pyfunction]
Expand Down
4 changes: 2 additions & 2 deletions src/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ impl CylindricArray {

/// Convert the CylindricArray to a 2D numpy array.
pub fn asarray(&self, py: Python) -> Py<PyArray2<f32>> {
self.array.clone().into_pyarray(py).unbind()
self.array.clone().into_pyarray_bound(py).unbind()
}

pub fn as1d(&self, py: Python) -> Py<PyArray1<f32>> {
let mut out = Array1::<f32>::zeros(self.ycoords.shape()[0]);
for i in 0..self.ycoords.len() {
out[[i]] = self.array[[self.ycoords[[i]], self.acoords[[i]]]];
}
out.into_pyarray(py).unbind()
out.into_pyarray_bound(py).unbind()
}

/// Convolution on the cylinder surface.
Expand Down
2 changes: 1 addition & 1 deletion src/regionprops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl RegionProfiler {
"std" => self.intensity_std(),
_ => return value_error!(format!("Unknown property: {}", prop)),
};
out.insert(prop, Array1::from(vec).into_pyarray(py).unbind());
out.insert(prop, Array1::from(vec).into_pyarray_bound(py).unbind());
}
Ok(out)
}
Expand Down
6 changes: 3 additions & 3 deletions src/viterbi/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ViterbiGrid {
out[0] = pos.z;
out[1] = pos.y;
out[2] = pos.x;
Ok(out.into_pyarray(py).into())
Ok(out.into_pyarray_bound(py).into())
}

#[pyo3(signature = (dist_min, dist_max, angle_max = None))]
Expand All @@ -131,7 +131,7 @@ impl ViterbiGrid {
}
}
)?;
Ok((states.into_pyarray(py).into(), score))
Ok((states.into_pyarray_bound(py).into(), score))
}

#[pyo3(signature = (dist_min, dist_max, coords, origin, angle_max = None))]
Expand Down Expand Up @@ -160,7 +160,7 @@ impl ViterbiGrid {
}
}
)?;
Ok((states.into_pyarray(py).into(), score))
Ok((states.into_pyarray_bound(py).into(), score))
}
}

Expand Down

0 comments on commit 39e85d7

Please sign in to comment.