Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ follow_imports=silent
[mypy-pandas.conftest,pandas.tests.*]
ignore_errors=True

[mypy-pandas.core.api]
ignore_errors=True

[mypy-pandas.core.indexes.base]
ignore_errors=True

Expand Down
93 changes: 74 additions & 19 deletions pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,22 +696,77 @@ def integer_arithmetic_method(self, other):
"""

# create the Dtype
_dtypes = {}
for dtype in ['int8', 'int16', 'int32', 'int64',
'uint8', 'uint16', 'uint32', 'uint64']:

if dtype.startswith('u'):
name = "U{}".format(dtype[1:].capitalize())
else:
name = dtype.capitalize()
classname = "{}Dtype".format(name)
numpy_dtype = getattr(np, dtype)
attributes_dict = {'type': numpy_dtype,
'name': name,
'__doc__': _dtype_docstring.format(dtype=dtype)}
dtype_type = register_extension_dtype(
type(classname, (_IntegerDtype, ), attributes_dict)
)
setattr(module, classname, dtype_type)

_dtypes[dtype] = dtype_type()
Int8Dtype = register_extension_dtype(
type('Int8Dtype', (_IntegerDtype, ), {
'type': getattr(np, 'int8'),
'name': 'Int8',
'__doc__': _dtype_docstring.format(dtype='int8')
})
)

Int16Dtype = register_extension_dtype(
type('Int16Dtype', (_IntegerDtype, ), {
'type': getattr(np, 'int16'),
'name': 'Int16',
'__doc__': _dtype_docstring.format(dtype='int16')
})
)

Int32Dtype = register_extension_dtype(
type('Int32Dtype', (_IntegerDtype, ), {
'type': getattr(np, 'int32'),
'name': 'Int32',
'__doc__': _dtype_docstring.format(dtype='int32')
})
)

Int64Dtype = register_extension_dtype(
type('Int64Dtype', (_IntegerDtype, ), {
'type': getattr(np, 'int64'),
'name': 'Int64',
'__doc__': _dtype_docstring.format(dtype='int64')
})
)

UInt8Dtype = register_extension_dtype(
type('UInt8Dtype', (_IntegerDtype, ), {
'type': getattr(np, 'uint8'),
'name': 'UInt8',
'__doc__': _dtype_docstring.format(dtype='uint8')
})
)

UInt16Dtype = register_extension_dtype(
type('UInt16Dtype', (_IntegerDtype, ), {
'type': getattr(np, 'uint16'),
'name': 'UInt16',
'__doc__': _dtype_docstring.format(dtype='uint16')
})
)

UInt32Dtype = register_extension_dtype(
type('UInt32Dtype', (_IntegerDtype, ), {
'type': getattr(np, 'uint8'),
'name': 'UInt32',
'__doc__': _dtype_docstring.format(dtype='uint32')
})
)

UInt64Dtype = register_extension_dtype(
type('UInt64Dtype', (_IntegerDtype, ), {
'type': getattr(np, 'uint64'),
'name': 'UInt64',
'__doc__': _dtype_docstring.format(dtype='uint64')
})
)

_dtypes = {
'int8': Int8Dtype(),
'int16': Int16Dtype(),
'int32': Int32Dtype(),
'int64': Int64Dtype(),
'uint8': UInt8Dtype(),
'uint16': UInt16Dtype(),
'uint32': UInt32Dtype(),
'uint64': UInt64Dtype(),
}