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

Function convert

src/datetime.rs:324–330  ·  view source on GitHub ↗
(py: Python<'py>, expected_value: i64)

Source from the content-addressed store, hash-verified

322 fn unit_conversion() {
323 #[track_caller]
324 fn convert<'py, S: Unit, D: Unit>(py: Python<'py>, expected_value: i64) {
325 let array = PyArray1::<Timedelta<S>>::from_slice(py, &[Timedelta::<S>::from(1)]);
326 let array = array.cast_array::<Timedelta<D>>(false).unwrap();
327
328 let value: i64 = array.get_owned(0).unwrap().into();
329 assert_eq!(value, expected_value);
330 }
331
332 Python::attach(|py| {
333 convert::<units::Years, units::Days>(py, (97 + 400 * 365) / 400);

Callers

nothing calls this directly

Calls 2

from_sliceFunction · 0.85
get_ownedMethod · 0.80

Tested by

no test coverage detected