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

Function extract

examples/simple/src/lib.rs:85–94  ·  view source on GitHub ↗
(d: &Bound<'_, PyDict>)

Source from the content-addressed store, hash-verified

83 // example of how to extract an array from a dictionary
84 #[pyfunction]
85 fn extract(d: &Bound<'_, PyDict>) -> f64 {
86 let x = d
87 .get_item("x")
88 .unwrap()
89 .unwrap()
90 .cast_into::<PyArray1<f64>>()
91 .unwrap();
92
93 x.readonly().as_array().sum()
94 }
95
96 // example using timedelta64 array
97 #[pyfunction]

Callers 1

test_extractFunction · 0.85

Calls 2

readonlyMethod · 0.80
as_arrayMethod · 0.45

Tested by 1

test_extractFunction · 0.68