Skip to content

Commit b30701c

Browse files
committed
Rename PyArrayDescr::get_typenum -> num
1 parent 38c4282 commit b30701c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ impl<T: Element + AsPrimitive<f64>> PyArray<T, Ix1> {
12191219
start.as_(),
12201220
stop.as_(),
12211221
step.as_(),
1222-
T::get_dtype(py).get_typenum(),
1222+
T::get_dtype(py).num(),
12231223
);
12241224
Self::from_owned_ptr(py, ptr)
12251225
}

src/dtype.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ impl PyArrayDescr {
9494
}
9595
}
9696

97-
/// Retrieves the
98-
/// [enumerated type](https://numpy.org/doc/stable/reference/c-api/dtype.html#enumerated-types)
99-
/// for this type descriptor.
100-
pub fn get_typenum(&self) -> c_int {
97+
/// Returns a unique number for each of the 21 different built-in
98+
/// [enumerated types](https://numpy.org/doc/stable/reference/c-api/dtype.html#enumerated-types).
99+
///
100+
/// These are roughly ordered from least-to-most precision.
101+
///
102+
/// Equivalent to [`np.dtype.num`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.num.html).
103+
pub fn num(&self) -> c_int {
101104
unsafe { *self.as_dtype_ptr() }.type_num
102105
}
103106
}

0 commit comments

Comments
 (0)