INNER CODE UNIT · Rust
type_name
RyanCodrai/turbovec · turbovec-python/src/lib.rs:21
fn type_name(obj: &Bound<'_, PyAny>) -> String {
obj.get_type()
.name()
.map(|n| n.to_string())
.unwrap_or_else(|_| "<unknown>".to_string())
}
/// Describe an argument for an array-mismatch error: "2-D float64" for
/// anything ndarray-like, otherwise the plain type name (e.g. "list").
fn array_desc(obj: &Bound<'_, PyAny>) -> String {
let ndim = obj
.getattr("ndim")
.ok()
.and_then(|n| n.extract::<usize>().ok());
let dtype = obj
.getattr("dtype")
.ok()
.and_then(|d| d.str().ok())