Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded lifetime annotations #389

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/linalg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use numpy::{IntoPyArray, PyArray2, PyReadonlyArray2};
use pyo3::{exceptions::PyRuntimeError, pymodule, types::PyModule, PyResult, Python};

#[pymodule]
fn rust_linalg(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn rust_linalg(_py: Python, m: &PyModule) -> PyResult<()> {
#[pyfn(m)]
fn inv<'py>(py: Python<'py>, x: PyReadonlyArray2<'py, f64>) -> PyResult<&'py PyArray2<f64>> {
fn inv<'py>(py: Python<'py>, x: PyReadonlyArray2<f64>) -> PyResult<&'py PyArray2<f64>> {
let x = x.as_array();
let y = x
.inv()
Expand Down
6 changes: 3 additions & 3 deletions examples/parallel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use numpy::{IntoPyArray, PyArray1, PyReadonlyArray1, PyReadonlyArray2};
use pyo3::{pymodule, types::PyModule, PyResult, Python};

#[pymodule]
fn rust_parallel(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn rust_parallel(_py: Python, m: &PyModule) -> PyResult<()> {
#[pyfn(m)]
fn rows_dot<'py>(
py: Python<'py>,
x: PyReadonlyArray2<'py, f64>,
y: PyReadonlyArray1<'py, f64>,
x: PyReadonlyArray2<f64>,
y: PyReadonlyArray1<f64>,
) -> &'py PyArray1<f64> {
let x = x.as_array();
let y = y.as_array();
Expand Down
18 changes: 9 additions & 9 deletions examples/simple/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ use pyo3::{
};

#[pymodule]
fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn rust_ext(_py: Python, m: &PyModule) -> PyResult<()> {
// example using generic PyObject
fn head(x: ArrayViewD<'_, PyObject>) -> PyResult<PyObject> {
fn head(x: ArrayViewD<PyObject>) -> PyResult<PyObject> {
x.get(0)
.cloned()
.ok_or_else(|| PyIndexError::new_err("array index out of range"))
}

// example using immutable borrows producing a new array
fn axpy(a: f64, x: ArrayViewD<'_, f64>, y: ArrayViewD<'_, f64>) -> ArrayD<f64> {
fn axpy(a: f64, x: ArrayViewD<f64>, y: ArrayViewD<f64>) -> ArrayD<f64> {
a * &x + &y
}

// example using a mutable borrow to modify an array in-place
fn mult(a: f64, mut x: ArrayViewMutD<'_, f64>) {
fn mult(a: f64, mut x: ArrayViewMutD<f64>) {
x *= a;
}

// example using complex numbers
fn conj(x: ArrayViewD<'_, Complex64>) -> ArrayD<Complex64> {
fn conj(x: ArrayViewD<Complex64>) -> ArrayD<Complex64> {
x.map(|c| c.conj())
}

Expand All @@ -45,7 +45,7 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
// wrapper of `head`
#[pyfn(m)]
#[pyo3(name = "head")]
fn head_py(_py: Python<'_>, x: PyReadonlyArrayDyn<'_, PyObject>) -> PyResult<PyObject> {
fn head_py(_py: Python, x: PyReadonlyArrayDyn<PyObject>) -> PyResult<PyObject> {
head(x.as_array())
}

Expand All @@ -55,8 +55,8 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn axpy_py<'py>(
py: Python<'py>,
a: f64,
x: PyReadonlyArrayDyn<'_, f64>,
y: PyReadonlyArrayDyn<'_, f64>,
x: PyReadonlyArrayDyn<f64>,
y: PyReadonlyArrayDyn<f64>,
) -> &'py PyArrayDyn<f64> {
let x = x.as_array();
let y = y.as_array();
Expand All @@ -77,7 +77,7 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
#[pyo3(name = "conj")]
fn conj_py<'py>(
py: Python<'py>,
x: PyReadonlyArrayDyn<'_, Complex64>,
x: PyReadonlyArrayDyn<Complex64>,
) -> &'py PyArrayDyn<Complex64> {
conj(x.as_array()).into_pyarray(py)
}
Expand Down
2 changes: 2 additions & 0 deletions tests/to_py.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::useless_vec)]
adamreichold marked this conversation as resolved.
Show resolved Hide resolved

use std::cmp::Ordering;
use std::mem::size_of;

Expand Down