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

Silence non_local_definition warnings until they fixed upstream in PyO3's macros #427

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install Rust
Expand Down Expand Up @@ -203,7 +203,8 @@ jobs:
- name: Generate code coverage
run: cargo llvm-cov --all-features --codecov --output-path coverage.json
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: coverage.json
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
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
Loading