@@ -10,7 +10,7 @@ use pyo3::sync::GILOnceCell;
1010use pyo3:: {
1111 exceptions:: { PyIndexError , PyValueError } ,
1212 ffi:: { self , PyTuple_Size } ,
13- pyobject_native_type_extract , pyobject_native_type_named,
13+ pyobject_native_type_named,
1414 types:: { PyAnyMethods , PyDict , PyDictMethods , PyTuple , PyType } ,
1515 Borrowed , Bound , Py , PyAny , PyObject , PyResult , PyTypeInfo , Python , ToPyObject ,
1616} ;
@@ -60,8 +60,6 @@ unsafe impl PyTypeInfo for PyArrayDescr {
6060 }
6161}
6262
63- pyobject_native_type_extract ! ( PyArrayDescr ) ;
64-
6563/// Returns the type descriptor ("dtype") for a registered type.
6664pub fn dtype_bound < ' py , T : Element > ( py : Python < ' py > ) -> Bound < ' py , PyArrayDescr > {
6765 T :: get_dtype_bound ( py)
@@ -148,7 +146,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
148146 /// [enumerated-types]: https://numpy.org/doc/stable/reference/c-api/dtype.html#enumerated-types
149147 /// [dtype-num]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.num.html
150148 fn num ( & self ) -> c_int {
151- unsafe { * self . as_dtype_ptr ( ) } . type_num
149+ unsafe { & * self . as_dtype_ptr ( ) } . type_num
152150 }
153151
154152 /// Returns the element size of this type descriptor.
@@ -173,7 +171,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
173171 ///
174172 /// [dtype-byteorder]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.byteorder.html
175173 fn byteorder ( & self ) -> u8 {
176- unsafe { * self . as_dtype_ptr ( ) } . byteorder . max ( 0 ) as _
174+ unsafe { & * self . as_dtype_ptr ( ) } . byteorder . max ( 0 ) as _
177175 }
178176
179177 /// Returns a unique ASCII character for each of the 21 different built-in types.
@@ -184,7 +182,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
184182 ///
185183 /// [dtype-char]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.char.html
186184 fn char ( & self ) -> u8 {
187- unsafe { * self . as_dtype_ptr ( ) } . type_ . max ( 0 ) as _
185+ unsafe { & * self . as_dtype_ptr ( ) } . type_ . max ( 0 ) as _
188186 }
189187
190188 /// Returns an ASCII character (one of `biufcmMOSUV`) identifying the general kind of data.
@@ -195,7 +193,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
195193 ///
196194 /// [dtype-kind]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.kind.html
197195 fn kind ( & self ) -> u8 {
198- unsafe { * self . as_dtype_ptr ( ) } . kind . max ( 0 ) as _
196+ unsafe { & * self . as_dtype_ptr ( ) } . kind . max ( 0 ) as _
199197 }
200198
201199 /// Returns bit-flags describing how this type descriptor is to be interpreted.
@@ -319,7 +317,7 @@ impl<'py> PyArrayDescrMethods<'py> for Bound<'py, PyArrayDescr> {
319317 }
320318
321319 fn typeobj ( & self ) -> Bound < ' py , PyType > {
322- let dtype_type_ptr = unsafe { * self . as_dtype_ptr ( ) } . typeobj ;
320+ let dtype_type_ptr = unsafe { & * self . as_dtype_ptr ( ) } . typeobj ;
323321 unsafe { PyType :: from_borrowed_type_ptr ( self . py ( ) , dtype_type_ptr) }
324322 }
325323
@@ -725,7 +723,7 @@ mod tests {
725723 assert ! ( !dt. has_subarray( ) ) ;
726724 assert ! ( dt. base( ) . is_equiv_to( & dt) ) ;
727725 assert_eq ! ( dt. ndim( ) , 0 ) ;
728- assert_eq ! ( dt. shape( ) , vec! [ ] ) ;
726+ assert_eq ! ( dt. shape( ) , Vec :: < usize > :: new ( ) ) ;
729727 } ) ;
730728 }
731729
@@ -801,7 +799,7 @@ mod tests {
801799 assert ! ( dt. is_aligned_struct( ) ) ;
802800 assert ! ( !dt. has_subarray( ) ) ;
803801 assert_eq ! ( dt. ndim( ) , 0 ) ;
804- assert_eq ! ( dt. shape( ) , vec! [ ] ) ;
802+ assert_eq ! ( dt. shape( ) , Vec :: < usize > :: new ( ) ) ;
805803 assert ! ( dt. base( ) . is_equiv_to( & dt) ) ;
806804 let x = dt. get_field ( "x" ) . unwrap ( ) ;
807805 assert ! ( x. 0 . is_equiv_to( & dtype_bound:: <u8 >( py) ) ) ;
0 commit comments