Skip to content

Commit

Permalink
bump pyo3 to 0.22 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn authored Oct 22, 2024
1 parent 5062915 commit c8c459e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions japan-geoid-py/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "japan-geoid-py"
version = "0.4.2"
version = "0.4.3"
edition.workspace = true
categories.workspace = true
description.workspace = true
Expand All @@ -11,6 +11,6 @@ name = "japan_geoid"
crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.21.2"
numpy = "0.21.0"
pyo3 = "0.22.5"
numpy = "0.22.0"
japan-geoid = { path = "../" }
10 changes: 5 additions & 5 deletions japan-geoid-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ pub fn load_embedded_gsigeo2011() -> PyResult<GsiGeoid> {
impl GsiGeoid {
/// Load the geoid model from the original ascii format.
#[classmethod]
fn from_ascii(_cls: &PyType, content: &str) -> PyResult<Self> {
fn from_ascii(_cls: &Bound<'_, PyType>, content: &str) -> PyResult<Self> {
let mut reader = std::io::Cursor::new(content);
let geoid = MemoryGrid::from_ascii_reader(&mut reader)?;
Ok(GsiGeoid { geoid })
}

/// Load the geoid model from the efficient binary format.
#[classmethod]
fn from_binary(_cls: &PyType, content: &[u8]) -> PyResult<Self> {
fn from_binary(_cls: &Bound<'_, PyType>, content: &[u8]) -> PyResult<Self> {
let mut reader = std::io::Cursor::new(content);
let geoid = MemoryGrid::from_binary_reader(&mut reader)?;
Ok(GsiGeoid { geoid })
Expand All @@ -56,7 +56,7 @@ impl GsiGeoid {
py: Python<'py>,
lng: PyReadonlyArrayDyn<'py, f64>,
lat: PyReadonlyArrayDyn<'py, f64>,
) -> PyResult<&'py PyArrayDyn<f64>> {
) -> PyResult<Bound<'py, PyArrayDyn<f64>>> {
if lng.shape() != lat.shape() {
return Err(PyErr::new::<pyo3::exceptions::PyValueError, _>(
"lng and lat must have the same shape",
Expand All @@ -67,13 +67,13 @@ impl GsiGeoid {
.and(lng.as_array())
.and(lat.as_array())
.for_each(|c, &a, &b| *c = self.geoid.get_height(a, b));
Ok(c.into_pyarray(py))
Ok(c.into_pyarray_bound(py))
}
}

/// A Python module implemented in Rust.
#[pymodule]
fn japan_geoid(_py: Python, m: &PyModule) -> PyResult<()> {
fn japan_geoid(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<GsiGeoid>()?;
m.add_function(wrap_pyfunction!(load_embedded_gsigeo2011, m)?)?;
Ok(())
Expand Down

0 comments on commit c8c459e

Please sign in to comment.