Skip to content

Commit

Permalink
BUG: in maybe_convert_numeric, if you've seen an 'inf', you've seen a…
Browse files Browse the repository at this point in the history
… float
  • Loading branch information
aflaxman committed Oct 7, 2012
1 parent 6f31f8c commit d11eea2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pandas/src/inference.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ def maybe_convert_numeric(ndarray[object] values, set na_values,
if not seen_float:
if '.' in val:
seen_float = 1
elif 'inf' in val: # special case to handle +/-inf
seen_float = 1
else:
ints[i] = <int64_t> fval

Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/test_tseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ def test_convert_objects():
result = lib.maybe_convert_objects(arr)
assert(result.dtype == np.object_)

def test_convert_infs():
arr = np.array(['inf', 'inf', 'inf'], dtype='O')
result = lib.maybe_convert_numeric(arr, set(), False)
assert(result.dtype == np.float64)

def test_convert_objects_ints():
# test that we can detect many kinds of integers
dtypes = ['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8']
Expand Down

0 comments on commit d11eea2

Please sign in to comment.