MCPcopy Create free account
hub / github.com/PyO3/rust-numpy / with_base_object

Function with_base_object

src/borrow/shared.rs:508–525  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

506
507 #[test]
508 fn with_base_object() {
509 Python::attach(|py| {
510 let array = Array::<f64, _>::zeros((1, 2, 3)).into_pyarray(py);
511
512 let base = unsafe { (*array.as_array_ptr()).base };
513 assert!(!base.is_null());
514
515 let base_address = base_address(py, array.as_array_ptr());
516 assert_ne!(base_address, array.as_ptr().cast());
517 assert_eq!(base_address, base.cast::<c_void>());
518
519 let data_range = data_range(py, array.as_array_ptr());
520 assert_eq!(data_range.0, array.data().cast::<c_char>());
521 assert_eq!(data_range.1, unsafe {
522 array.data().add(6).cast::<c_char>()
523 });
524 });
525 }
526
527 #[test]
528 fn view_without_base_object() {

Callers

nothing calls this directly

Calls 5

zerosFunction · 0.85
base_addressFunction · 0.85
data_rangeFunction · 0.85
into_pyarrayMethod · 0.80
as_array_ptrMethod · 0.80

Tested by

no test coverage detected