pub struct Ndarray {
pub source: Source,
pub shape: Vec<Option<u64>>,
pub datatype: Datatype,
pub byteorder: ByteOrder,
pub offset: u64,
pub strides: Option<Vec<i64>>,
pub mask: Option<Mask>,
}Expand description
A parsed core/ndarray.
Fields§
§source: SourceWhere the data lives.
shape: Vec<Option<u64>>The array’s shape. A leading None means the dimension is determined
from the block’s size, which the schema allows for streamed arrays.
datatype: DatatypeThe element type.
byteorder: ByteOrderByte order of the elements.
offset: u64Offset in bytes into the block where the data starts.
strides: Option<Vec<i64>>Bytes to step per dimension. Absent means C-contiguous.
mask: Option<Mask>How missing values are marked, if at all.
Implementations§
Source§impl Ndarray
impl Ndarray
Sourcepub fn resolved_shape(&self, block_bytes: Option<u64>) -> Result<Vec<u64>>
pub fn resolved_shape(&self, block_bytes: Option<u64>) -> Result<Vec<u64>>
The shape with every dimension known, given the block’s byte length.
A streamed array’s first dimension is * in the file and is derived
from how many whole rows the block holds.
Sourcepub fn len(&self, block_bytes: Option<u64>) -> Result<u64>
pub fn len(&self, block_bytes: Option<u64>) -> Result<u64>
The number of elements, for a fully-known shape.
The shape comes from the tree, so the product is checked: a crafted shape can otherwise wrap to a small number and make a later read address the wrong bytes, or wrap past a size check into an allocation nothing justifies.
Sourcepub fn is_empty(&self, block_bytes: Option<u64>) -> Result<bool>
pub fn is_empty(&self, block_bytes: Option<u64>) -> Result<bool>
Whether the array has no elements.
Sourcepub fn nbytes(&self, block_bytes: Option<u64>) -> Result<u64>
pub fn nbytes(&self, block_bytes: Option<u64>) -> Result<u64>
The number of bytes the elements occupy.
Sourcepub fn c_strides(shape: &[u64], item_size: u64) -> Option<Vec<i64>>
pub fn c_strides(shape: &[u64], item_size: u64) -> Option<Vec<i64>>
C-contiguous strides for a shape, in bytes.
None when the shape is too large to stride, rather than a wrapped
value: a wrapped stride silently addresses the wrong element, which
for a data format is worse than refusing to read.