-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
PyArray1::<bool>::as_slice
returns a &[bool]
, but the underlying data may not at all be valid for Rust's bool
, creating instant undefined behavior. For example
>>> a = np.uint8([24, 15, 32, 1, 0]).view(bool)
>>> a
array([ True, True, True, True, False])
Calling as_slice
on this from Rust reveals the invalid representation:
dbg!(arr.as_slice().unwrap());
dbg!(unsafe { core::mem::transmute::<&[bool], &[u8]>(arr.as_slice().unwrap()) });
[ false, true, false, true, false, ]
[ 24, 15, 32, 1, 0, ]
Metadata
Metadata
Assignees
Labels
No labels