@@ -696,22 +696,77 @@ def integer_arithmetic_method(self, other):
696696"""
697697
698698# create the Dtype
699- _dtypes = {}
700- for dtype in ['int8' , 'int16' , 'int32' , 'int64' ,
701- 'uint8' , 'uint16' , 'uint32' , 'uint64' ]:
702-
703- if dtype .startswith ('u' ):
704- name = "U{}" .format (dtype [1 :].capitalize ())
705- else :
706- name = dtype .capitalize ()
707- classname = "{}Dtype" .format (name )
708- numpy_dtype = getattr (np , dtype )
709- attributes_dict = {'type' : numpy_dtype ,
710- 'name' : name ,
711- '__doc__' : _dtype_docstring .format (dtype = dtype )}
712- dtype_type = register_extension_dtype (
713- type (classname , (_IntegerDtype , ), attributes_dict )
714- )
715- setattr (module , classname , dtype_type )
716-
717- _dtypes [dtype ] = dtype_type ()
699+ Int8Dtype = register_extension_dtype (
700+ type ('Int8Dtype' , (_IntegerDtype , ), {
701+ 'type' : np .int8 ,
702+ 'name' : 'Int8' ,
703+ '__doc__' : _dtype_docstring .format (dtype = 'int8' )
704+ })
705+ )
706+
707+ Int16Dtype = register_extension_dtype (
708+ type ('Int16Dtype' , (_IntegerDtype , ), {
709+ 'type' : np .int16 ,
710+ 'name' : 'Int16' ,
711+ '__doc__' : _dtype_docstring .format (dtype = 'int16' )
712+ })
713+ )
714+
715+ Int32Dtype = register_extension_dtype (
716+ type ('Int32Dtype' , (_IntegerDtype , ), {
717+ 'type' : np .int32 ,
718+ 'name' : 'Int32' ,
719+ '__doc__' : _dtype_docstring .format (dtype = 'int32' )
720+ })
721+ )
722+
723+ Int64Dtype = register_extension_dtype (
724+ type ('Int64Dtype' , (_IntegerDtype , ), {
725+ 'type' : np .int64 ,
726+ 'name' : 'Int64' ,
727+ '__doc__' : _dtype_docstring .format (dtype = 'int64' )
728+ })
729+ )
730+
731+ UInt8Dtype = register_extension_dtype (
732+ type ('UInt8Dtype' , (_IntegerDtype , ), {
733+ 'type' : np .uint8 ,
734+ 'name' : 'UInt8' ,
735+ '__doc__' : _dtype_docstring .format (dtype = 'uint8' )
736+ })
737+ )
738+
739+ UInt16Dtype = register_extension_dtype (
740+ type ('UInt16Dtype' , (_IntegerDtype , ), {
741+ 'type' : np .uint16 ,
742+ 'name' : 'UInt16' ,
743+ '__doc__' : _dtype_docstring .format (dtype = 'uint16' )
744+ })
745+ )
746+
747+ UInt32Dtype = register_extension_dtype (
748+ type ('UInt32Dtype' , (_IntegerDtype , ), {
749+ 'type' : np .uint32 ,
750+ 'name' : 'UInt32' ,
751+ '__doc__' : _dtype_docstring .format (dtype = 'uint32' )
752+ })
753+ )
754+
755+ UInt64Dtype = register_extension_dtype (
756+ type ('UInt64Dtype' , (_IntegerDtype , ), {
757+ 'type' : np .uint64 ,
758+ 'name' : 'UInt64' ,
759+ '__doc__' : _dtype_docstring .format (dtype = 'uint64' )
760+ })
761+ )
762+
763+ _dtypes = {
764+ 'int8' : Int8Dtype (),
765+ 'int16' : Int16Dtype (),
766+ 'int32' : Int32Dtype (),
767+ 'int64' : Int64Dtype (),
768+ 'uint8' : UInt8Dtype (),
769+ 'uint16' : UInt16Dtype (),
770+ 'uint32' : UInt32Dtype (),
771+ 'uint64' : UInt64Dtype (),
772+ }
0 commit comments