Skip to content

Commit 076e2d8

Browse files
committed
Add is_instance test
1 parent 4b05393 commit 076e2d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/array.rs

+10
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,13 @@ fn iter_to_pyarray() {
104104
println!("arr = {:?}", arr.as_slice::<i32>().unwrap());
105105
assert_eq!(arr.shape(), [10]);
106106
}
107+
108+
#[test]
109+
fn is_instance() {
110+
let gil = pyo3::Python::acquire_gil();
111+
let py = gil.python();
112+
let np = PyArrayModule::import(py).unwrap();
113+
let arr = PyArray::new::<f64>(gil.python(), &np, &[3, 5]);
114+
assert!(py.is_instance::<PyArray, _>(&arr).unwrap());
115+
assert!(!py.is_instance::<pyo3::PyList, _>(&arr).unwrap());
116+
}

0 commit comments

Comments
 (0)