Test 8-bit integers and raise error on 16-bit floats; add comments

This commit is contained in:
Christopher C. Aycock 2016-12-12 17:40:48 -05:00
parent 0ad1687dfd
commit 89256f01a5
3 changed files with 15 additions and 11 deletions

View File

@ -169,6 +169,7 @@ def asof_join_{{on_dtype}}(ndarray[{{on_dtype}}] left_values,
#----------------------------------------------------------------------
def stringify(ndarray[object, ndim=2] xt):
""" Invokes .tostring() on each array entry within a 2D array. """
cdef:
Py_ssize_t n
ndarray[object] result

View File

@ -949,7 +949,7 @@ _cyton_types = {
'int32': 'int32_t',
'int16': 'int16_t',
'int64': 'int64_t',
'float16': 'float',
'float16': 'error',
'float32': 'float',
'float64': 'double',
}
@ -959,6 +959,8 @@ def _get_cython_type(dtype):
""" Given a dtype, return a C name like 'int64_t' or 'double' """
type_name = _get_dtype(dtype).name
ctype = _cyton_types.get(type_name, 'object')
if ctype == 'error':
raise MergeError('unsupported type: ' + type_name)
return ctype
@ -1063,6 +1065,7 @@ class _AsOfMerge(_OrderedMerge):
def flip_stringify(xs):
""" flip an array of arrays and string-ify contents """
xt = np.transpose(xs)
# numpy arrays aren't hashable, so we convert to a string
return _join.stringify(_ensure_object(xt))
# values to compare

View File

@ -565,17 +565,17 @@ class TestAsOfMerge(tm.TestCase):
def test_on_specialized_type(self):
# GH13936
for dtype in [np.uint16, np.uint32, np.uint64,
np.int16, np.int32, np.int64,
for dtype in [np.uint8, np.uint16, np.uint32, np.uint64,
np.int8, np.int16, np.int32, np.int64,
np.float32, np.float64]:
df1 = pd.DataFrame({
'value': [5, 2, 25, 300, 78, 1040, 79],
'value': [5, 2, 25, 100, 78, 120, 79],
'symbol': list("ABCDEFG")},
columns=['symbol', 'value'])
df1.value = dtype(df1.value)
df2 = pd.DataFrame({
'value': [0, 100, 1000, 10000],
'value': [0, 80, 120, 125],
'result': list('xyzw')},
columns=['value', 'result'])
df2.value = dtype(df2.value)
@ -586,7 +586,7 @@ class TestAsOfMerge(tm.TestCase):
expected = pd.DataFrame({
'symbol': list("BACEGDF"),
'value': [2, 5, 25, 78, 79, 300, 1040],
'value': [2, 5, 25, 78, 79, 100, 120],
'result': list('xxxxxyz')},
columns=['symbol', 'value', 'result'])
expected.value = dtype(expected.value)
@ -595,18 +595,18 @@ class TestAsOfMerge(tm.TestCase):
def test_on_specialized_type_by_int(self):
# GH13936
for dtype in [np.uint16, np.uint32, np.uint64,
np.int16, np.int32, np.int64,
for dtype in [np.uint8, np.uint16, np.uint32, np.uint64,
np.int8, np.int16, np.int32, np.int64,
np.float32, np.float64]:
df1 = pd.DataFrame({
'value': [5, 2, 25, 300, 78, 1040, 79],
'value': [5, 2, 25, 100, 78, 120, 79],
'key': [1, 2, 3, 2, 3, 1, 2],
'symbol': list("ABCDEFG")},
columns=['symbol', 'key', 'value'])
df1.value = dtype(df1.value)
df2 = pd.DataFrame({
'value': [0, 100, 1000, 10000],
'value': [0, 80, 120, 125],
'key': [1, 2, 2, 3],
'result': list('xyzw')},
columns=['value', 'key', 'result'])
@ -619,7 +619,7 @@ class TestAsOfMerge(tm.TestCase):
expected = pd.DataFrame({
'symbol': list("BACEGDF"),
'key': [2, 1, 3, 3, 2, 2, 1],
'value': [2, 5, 25, 78, 79, 300, 1040],
'value': [2, 5, 25, 78, 79, 100, 120],
'result': [np.nan, 'x', np.nan, np.nan, np.nan, 'y', 'x']},
columns=['symbol', 'key', 'value', 'result'])
expected.value = dtype(expected.value)