Skip to content

Commit

Permalink
Avoid deprecation warnings in example projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreichold committed Jul 4, 2021
1 parent 775d6d0 commit cdb1ed9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/linalg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use pyo3::prelude::{pymodule, PyErr, PyModule, PyResult, Python};

#[pymodule]
fn rust_linalg(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
#[pyfn(m, "inv")]
#[pyfn(m)]
fn inv<'py>(py: Python<'py>, x: PyReadonlyArray2<'py, f64>) -> PyResult<&'py PyArray2<f64>> {
let x = x
.as_array()
Expand Down
9 changes: 6 additions & 3 deletions examples/simple-extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
}

// wrapper of `axpy`
#[pyfn(m, "axpy")]
#[pyfn(m)]
#[pyo3(name = "axpy")]
fn axpy_py<'py>(
py: Python<'py>,
a: f64,
Expand All @@ -33,14 +34,16 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
}

// wrapper of `mult`
#[pyfn(m, "mult")]
#[pyfn(m)]
#[pyo3(name = "mult")]
fn mult_py(a: f64, x: &PyArrayDyn<f64>) {
let x = unsafe { x.as_array_mut() };
mult(a, x);
}

// wrapper of `conj`
#[pyfn(m, "conj")]
#[pyfn(m)]
#[pyo3(name = "conj")]
fn conj_py<'py>(py: Python<'py>, x: PyReadonlyArrayDyn<'_, c64>) -> &'py PyArrayDyn<c64> {
conj(x.as_array()).into_pyarray(py)
}
Expand Down

0 comments on commit cdb1ed9

Please sign in to comment.