Skip to content

Commit

Permalink
Resolve warnings on non-local definitions and legacy numerical consta…
Browse files Browse the repository at this point in the history
…nts.
  • Loading branch information
adamreichold committed Apr 16, 2024
1 parent 0832b28 commit ca17e88
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
26 changes: 13 additions & 13 deletions tests/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,23 +399,23 @@ fn dtype_via_python_attribute() {
});
}

#[test]
fn borrow_from_array_works() {
#[pyclass]
struct Owner {
array: Array1<f64>,
}
#[pyclass]
struct Owner {
array: Array1<f64>,
}

#[pymethods]
impl Owner {
#[getter]
fn array(this: Bound<'_, Self>) -> Bound<'_, PyArray1<f64>> {
let array = &this.borrow().array;
#[pymethods]
impl Owner {
#[getter]
fn array(this: Bound<'_, Self>) -> Bound<'_, PyArray1<f64>> {
let array = &this.borrow().array;

unsafe { PyArray1::borrow_from_array_bound(array, this.into_any()) }
}
unsafe { PyArray1::borrow_from_array_bound(array, this.into_any()) }
}
}

#[test]
fn borrow_from_array_works() {
let array = Python::with_gil(|py| {
let owner = Py::new(
py,
Expand Down
20 changes: 10 additions & 10 deletions tests/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ fn exclusive_borrow_requires_writeable() {
});
}

#[test]
#[should_panic(expected = "AlreadyBorrowed")]
fn borrows_span_frames() {
#[pyclass]
struct Borrower;
#[pyclass]
struct Borrower;

#[pymethods]
impl Borrower {
fn shared(&self, _array: PyReadonlyArray3<'_, f64>) {}
#[pymethods]
impl Borrower {
fn shared(&self, _array: PyReadonlyArray3<'_, f64>) {}

fn exclusive(&self, _array: PyReadwriteArray3<'_, f64>) {}
}
fn exclusive(&self, _array: PyReadwriteArray3<'_, f64>) {}
}

#[test]
#[should_panic(expected = "AlreadyBorrowed")]
fn borrows_span_frames() {
Python::with_gil(|py| {
let borrower = Py::new(py, Borrower).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions tests/to_py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ fn from_small_array() {
($($t:ty)+) => {
$({
Python::with_gil(|py| {
let array: [$t; 2] = [<$t>::min_value(), <$t>::max_value()];
let array: [$t; 2] = [<$t>::MIN, <$t>::MAX];
let pyarray = array.to_pyarray_bound(py);

assert_eq!(
pyarray.readonly().as_slice().unwrap(),
&[<$t>::min_value(), <$t>::max_value()]
&[<$t>::MIN, <$t>::MAX]
);
});
})+
Expand Down

0 comments on commit ca17e88

Please sign in to comment.