Skip to content

Commit

Permalink
prints during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maffoo committed Sep 30, 2024
1 parent dfb6be9 commit 2392b5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
runs-on: ${{ matrix.platform.os }}
#needs: [lint, check-msrv, examples]
strategy:
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
#fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
fail-fast: false
matrix:
#python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11"]
Expand Down Expand Up @@ -73,7 +74,8 @@ jobs:
- name: Test
run: |
pip install "numpy" ml_dtypes
cargo test --all-features
$Env:RUST_BACKTRACE = 1
cargo test --all-features --verbose -- --nocapture
# Not on PyPy, because no embedding API
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
- name: Test example
Expand Down
9 changes: 9 additions & 0 deletions src/borrow/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ fn data_range<'py>(py: Python<'py>, array: *mut PyArrayObject) -> (*mut c_char,
let strides = unsafe { from_raw_parts((*array).strides, nd) };

let itemsize = unsafe { PyDataType_ELSIZE(py, (*array).descr) } as isize;
println!("itemsize = {itemsize}");

let mut start = 0;
let mut end = 0;
Expand Down Expand Up @@ -609,8 +610,10 @@ mod tests {
#[test]
fn view_of_view_with_base_object() {
Python::with_gil(|py| {
println!("A");
let array = Array::<f64, _>::zeros((1, 2, 3)).into_pyarray_bound(py);

println!("B");
let locals = [("array", &array)].into_py_dict_bound(py);
let view1 = py
.eval_bound("array[:,:,0]", None, Some(&locals))
Expand All @@ -622,6 +625,7 @@ mod tests {
array.as_ptr().cast::<c_void>(),
);

println!("C");
let locals = [("view1", &view1)].into_py_dict_bound(py);
let view2 = py
.eval_bound("view1[:,0]", None, Some(&locals))
Expand All @@ -637,21 +641,26 @@ mod tests {
view1.as_ptr().cast::<c_void>(),
);

println!("D");
let base = unsafe { (*view2.as_array_ptr()).base };
assert_eq!(base.cast::<c_void>(), array.as_ptr().cast::<c_void>());

println!("E");
let base = unsafe { (*view1.as_array_ptr()).base };
assert_eq!(base.cast::<c_void>(), array.as_ptr().cast::<c_void>());

println!("F");
let base = unsafe { (*array.as_array_ptr()).base };
assert!(!base.is_null());

println!("G");
let base_address = base_address(py, view2.as_array_ptr());
assert_ne!(base_address, view2.as_ptr().cast::<c_void>());
assert_ne!(base_address, view1.as_ptr().cast::<c_void>());
assert_ne!(base_address, array.as_ptr().cast::<c_void>());
assert_eq!(base_address, base.cast::<c_void>());

println!("H");
let data_range = data_range(py, view2.as_array_ptr());
assert_eq!(data_range.0, array.data().cast::<c_char>());
assert_eq!(data_range.1, unsafe {
Expand Down

0 comments on commit 2392b5f

Please sign in to comment.