From c8c459eb3588613d4f8314564c766bcc9b792ca0 Mon Sep 17 00:00:00 2001 From: Taku Fukada Date: Tue, 22 Oct 2024 13:14:47 +0900 Subject: [PATCH] bump pyo3 to 0.22 (#6) --- japan-geoid-py/Cargo.toml | 6 +++--- japan-geoid-py/src/lib.rs | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/japan-geoid-py/Cargo.toml b/japan-geoid-py/Cargo.toml index 439e635..4971c2f 100644 --- a/japan-geoid-py/Cargo.toml +++ b/japan-geoid-py/Cargo.toml @@ -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 @@ -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 = "../" } diff --git a/japan-geoid-py/src/lib.rs b/japan-geoid-py/src/lib.rs index 94fc712..a077662 100644 --- a/japan-geoid-py/src/lib.rs +++ b/japan-geoid-py/src/lib.rs @@ -24,7 +24,7 @@ pub fn load_embedded_gsigeo2011() -> PyResult { impl GsiGeoid { /// Load the geoid model from the original ascii format. #[classmethod] - fn from_ascii(_cls: &PyType, content: &str) -> PyResult { + fn from_ascii(_cls: &Bound<'_, PyType>, content: &str) -> PyResult { let mut reader = std::io::Cursor::new(content); let geoid = MemoryGrid::from_ascii_reader(&mut reader)?; Ok(GsiGeoid { geoid }) @@ -32,7 +32,7 @@ impl GsiGeoid { /// Load the geoid model from the efficient binary format. #[classmethod] - fn from_binary(_cls: &PyType, content: &[u8]) -> PyResult { + fn from_binary(_cls: &Bound<'_, PyType>, content: &[u8]) -> PyResult { let mut reader = std::io::Cursor::new(content); let geoid = MemoryGrid::from_binary_reader(&mut reader)?; Ok(GsiGeoid { geoid }) @@ -56,7 +56,7 @@ impl GsiGeoid { py: Python<'py>, lng: PyReadonlyArrayDyn<'py, f64>, lat: PyReadonlyArrayDyn<'py, f64>, - ) -> PyResult<&'py PyArrayDyn> { + ) -> PyResult>> { if lng.shape() != lat.shape() { return Err(PyErr::new::( "lng and lat must have the same shape", @@ -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::()?; m.add_function(wrap_pyfunction!(load_embedded_gsigeo2011, m)?)?; Ok(())