@@ -7,8 +7,7 @@ use pyo3::{ffi, prelude::*, pyobject_native_type_core, types::PyType, AsPyPointe
7
7
8
8
use crate :: npyffi:: { NpyTypes , PyArray_Descr , NPY_TYPES , PY_ARRAY_API } ;
9
9
10
- pub use num_complex:: Complex32 as c32;
11
- pub use num_complex:: Complex64 as c64;
10
+ pub use num_complex:: { Complex32 , Complex64 } ;
12
11
13
12
/// Binding of [`numpy.dtype`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html).
14
13
///
@@ -287,7 +286,8 @@ pub unsafe trait Element: Clone + Send {
287
286
}
288
287
289
288
macro_rules! impl_num_element {
290
- ( $ty: ty, $data_type: expr) => {
289
+ ( $ty: ty, $data_type: expr $( , #[ $meta: meta] ) * ) => {
290
+ $( #[ $meta] ) *
291
291
unsafe impl Element for $ty {
292
292
const IS_COPY : bool = true ;
293
293
@@ -309,8 +309,10 @@ impl_num_element!(u32, DataType::Uint32);
309
309
impl_num_element ! ( u64 , DataType :: Uint64 ) ;
310
310
impl_num_element ! ( f32 , DataType :: Float32 ) ;
311
311
impl_num_element ! ( f64 , DataType :: Float64 ) ;
312
- impl_num_element ! ( c32, DataType :: Complex32 ) ;
313
- impl_num_element ! ( c64, DataType :: Complex64 ) ;
312
+ impl_num_element ! ( Complex32 , DataType :: Complex32 ,
313
+ #[ doc = "Complex type with `f32` components which maps to `np.csingle` (`np.complex64`)." ] ) ;
314
+ impl_num_element ! ( Complex64 , DataType :: Complex64 ,
315
+ #[ doc = "Complex type with `f64` components which maps to `np.cdouble` (`np.complex128`)." ] ) ;
314
316
315
317
cfg_if ! {
316
318
if #[ cfg( any( target_pointer_width = "32" , target_pointer_width = "64" ) ) ] {
@@ -331,7 +333,7 @@ unsafe impl Element for PyObject {
331
333
mod tests {
332
334
use std:: mem:: size_of;
333
335
334
- use super :: { c32 , c64 , Element , PyArrayDescr } ;
336
+ use super :: { Complex32 , Complex64 , Element , PyArrayDescr } ;
335
337
336
338
#[ test]
337
339
fn test_dtype_names ( ) {
@@ -350,8 +352,8 @@ mod tests {
350
352
assert_eq ! ( type_name:: <u64 >( py) , "uint64" ) ;
351
353
assert_eq ! ( type_name:: <f32 >( py) , "float32" ) ;
352
354
assert_eq ! ( type_name:: <f64 >( py) , "float64" ) ;
353
- assert_eq ! ( type_name:: <c32 >( py) , "complex64" ) ;
354
- assert_eq ! ( type_name:: <c64 >( py) , "complex128" ) ;
355
+ assert_eq ! ( type_name:: <Complex32 >( py) , "complex64" ) ;
356
+ assert_eq ! ( type_name:: <Complex64 >( py) , "complex128" ) ;
355
357
match size_of :: < usize > ( ) {
356
358
32 => {
357
359
assert_eq ! ( type_name:: <usize >( py) , "uint32" ) ;
0 commit comments