pub enum DType {
Plain(TypeStr),
Array(u64, Box<DType>),
Record(Vec<Field>),
}
Expand description
Representation of a Numpy type
Variants§
Plain(TypeStr)
Numpy type string. First character is '>'
for big endian, '<'
for little endian,
or can be '|'
if it doesn’t matter.
Examples: >i4
, <u8
, >f8
, |S7
. The number usually corresponds to the number of
bytes (with the single exception of unicode strings |U3
).
Array(u64, Box<DType>)
Fixed-size inner array type.
This is only possible inside structured arrays, where fields can themselves be arrays.
E.g. in the DType
for dtype=[('abc', 'i4', [2, 3])]
, the DType
for abc
will be Array(2, Array(3, Plain("<i4")))
. In rust, such an array could be read using
the following element type:
#[derive(npyz::Serialize, npyz::Deserialize, npyz::AutoSerialize)]
struct Row {
abc: [[i32; 3]; 2],
}
Record(Vec<Field>)
A structure record array
Implementations§
source§impl DType
impl DType
sourcepub fn descr(&self) -> String
pub fn descr(&self) -> String
Numpy format description of record dtype.
Calling descr
on DType::Array
will not produce a valid python expression
(the string will only be suitable for error messages).
sourcepub fn new_scalar(ty: TypeStr) -> Self
pub fn new_scalar(ty: TypeStr) -> Self
Construct a scalar DType
. (one which is not a nested array or record type)