-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtests.rs
More file actions
33 lines (29 loc) · 793 Bytes
/
tests.rs
File metadata and controls
33 lines (29 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use pyo3::ffi::c_str;
use numpy::PyUntypedArray;
use pyo3::{
Bound, PyResult, Python,
types::{PyAnyMethods, PyModule},
};
use crate::CodecPipelineImpl;
#[test]
fn test_nparray_to_unsafe_cell_slice_empty() -> PyResult<()> {
Python::initialize();
Python::attach(|py| {
let arr: Bound<'_, PyUntypedArray> = PyModule::from_code(
py,
c_str!(
"def empty_array():
import numpy as np
return np.empty(0, dtype=np.uint8)"
),
c_str!(""),
c_str!(""),
)?
.getattr("empty_array")?
.call0()?
.extract()?;
let slice = CodecPipelineImpl::nparray_to_unsafe_cell_slice(&arr)?;
assert!(slice.is_empty());
Ok(())
})
}