Merge pull request #1672 from quantopian/narrow-labelarray

narrow labelarray
This commit is contained in:
Joe Jevnik
2017-03-02 19:32:56 -05:00
committed by GitHub
4 changed files with 308 additions and 88 deletions
+16
View File
@@ -87,6 +87,13 @@ INT_DTYPES_BY_SIZE_BYTES = OrderedDict([
(8, dtype('int64')),
])
UNSIGNED_INT_DTYPES_BY_SIZE_BYTES = OrderedDict([
(1, dtype('uint8')),
(2, dtype('uint16')),
(4, dtype('uint32')),
(8, dtype('uint64')),
])
def int_dtype_with_size_in_bytes(size):
try:
@@ -95,6 +102,15 @@ def int_dtype_with_size_in_bytes(size):
raise ValueError("No integral dtype whose size is %d bytes." % size)
def unsigned_int_dtype_with_size_in_bytes(size):
try:
return UNSIGNED_INT_DTYPES_BY_SIZE_BYTES[size]
except KeyError:
raise ValueError(
"No unsigned integral dtype whose size is %d bytes." % size
)
class NoDefaultMissingValue(Exception):
pass