Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jschendel committed Nov 21, 2017
1 parent 1bffe76 commit ea978b0
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime, timedelta

import pandas.util.testing as tm
from pandas.core.dtypes.common import is_unsigned_integer_dtype
from pandas.core.indexes.api import Index, MultiIndex
from pandas.tests.indexes.common import Base

Expand Down Expand Up @@ -201,25 +202,20 @@ def __array__(self, dtype=None):
result = pd.Index(ArrayLike(array))
tm.assert_index_equal(result, expected)

def test_constructor_int_dtype_float(self):
@pytest.mark.parametrize('dtype', [
int, 'int64', 'int32', 'int16', 'int8', 'uint64', 'uint32',
'uint16', 'uint8'])
def test_constructor_int_dtype_float(self, dtype):
# GH 18400
data = [0., 1., 2., 3.]

expected = Int64Index([0, 1, 2, 3])
result = Index(data, dtype='int64')
tm.assert_index_equal(result, expected)
if is_unsigned_integer_dtype(dtype):
index_type = UInt64Index
else:
index_type = Int64Index

expected = UInt64Index([0, 1, 2, 3])
result = Index(data, dtype='uint64')
expected = index_type([0, 1, 2, 3])
result = Index([0., 1., 2., 3.], dtype=dtype)
tm.assert_index_equal(result, expected)

# fall back to Float64Index
data = [0.0, 1.1, 2.2, 3.3]
expected = Float64Index(data)
for dtype in ('int64', 'uint64'):
result = Index(data, dtype=dtype)
tm.assert_index_equal(result, expected)

def test_constructor_int_dtype_nan(self):
# see gh-15187
data = [np.nan]
Expand Down

0 comments on commit ea978b0

Please sign in to comment.