MCPcopy Index your code
hub / github.com/PyO3/rust-numpy / PyArrayDescrMethods

Interface PyArrayDescrMethods

src/dtype.rs:132–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130/// Implementation of functionality for [`PyArrayDescr`].
131#[doc(alias = "PyArrayDescr")]
132pub trait PyArrayDescrMethods<'py>: Sealed {
133 /// Returns `self` as `*mut PyArray_Descr`.
134 fn as_dtype_ptr(&self) -> *mut PyArray_Descr;
135
136 /// Returns `self` as `*mut PyArray_Descr` while increasing the reference count.
137 ///
138 /// Useful in cases where the descriptor is stolen by the API.
139 fn into_dtype_ptr(self) -> *mut PyArray_Descr;
140
141 /// Returns true if two type descriptors are equivalent.
142 fn is_equiv_to(&self, other: &Self) -> bool;
143
144 /// Returns the [array scalar][arrays-scalars] corresponding to this type descriptor.
145 ///
146 /// Equivalent to [`numpy.dtype.type`][dtype-type].
147 ///
148 /// [arrays-scalars]: https://numpy.org/doc/stable/reference/arrays.scalars.html
149 /// [dtype-type]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.type.html
150 fn typeobj(&self) -> Bound<'py, PyType>;
151
152 /// Returns a unique number for each of the 21 different built-in
153 /// [enumerated types][enumerated-types].
154 ///
155 /// These are roughly ordered from least-to-most precision.
156 ///
157 /// Equivalent to [`numpy.dtype.num`][dtype-num].
158 ///
159 /// [enumerated-types]: https://numpy.org/doc/stable/reference/c-api/dtype.html#enumerated-types
160 /// [dtype-num]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.num.html
161 fn num(&self) -> c_int {
162 unsafe { &*self.as_dtype_ptr() }.type_num
163 }
164
165 /// Returns the element size of this type descriptor.
166 ///
167 /// Equivalent to [`numpy.dtype.itemsize`][dtype-itemsize].
168 ///
169 /// [dtype-itemsize]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.itemsize.html
170 fn itemsize(&self) -> usize;
171
172 /// Returns the required alignment (bytes) of this type descriptor according to the compiler.
173 ///
174 /// Equivalent to [`numpy.dtype.alignment`][dtype-alignment].
175 ///
176 /// [dtype-alignment]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.alignment.html
177 fn alignment(&self) -> usize;
178
179 /// Returns an ASCII character indicating the byte-order of this type descriptor object.
180 ///
181 /// All built-in data-type objects have byteorder either `=` or `|`.
182 ///
183 /// Equivalent to [`numpy.dtype.byteorder`][dtype-byteorder].
184 ///
185 /// [dtype-byteorder]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.byteorder.html
186 fn byteorder(&self) -> u8 {
187 unsafe { &*self.as_dtype_ptr() }.byteorder.max(0) as _
188 }
189

Callers 2

arangeMethod · 0.80
is_native_byteorderMethod · 0.80

Implementers 1

dtype.rssrc/dtype.rs

Calls

no outgoing calls

Tested by

no test coverage detected