Skip to content

Split fastpath IntegerArray constructor and general purpose constructor #22070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Prev Previous commit
Next Next commit
add dtype tests
  • Loading branch information
jorisvandenbossche committed Jul 29, 2018
commit 90a9c131109b1b9e5eea05ba8bbafdd0ee5190c6
21 changes: 21 additions & 0 deletions pandas/tests/extension/integer/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,27 @@ def test_to_integer_array_error(values):
integer_array(values)


def test_to_integer_array_inferred_dtype():
# if values has dtype -> respect it
result = integer_array(np.array([1, 2], dtype='int8'))
assert result.dtype == Int8Dtype()
result = integer_array(np.array([1, 2], dtype='int32'))
assert result.dtype == Int32Dtype()

# if values have no dtype -> always int64
result = integer_array([1, 2])
assert result.dtype == Int64Dtype()


def test_to_integer_array_dtype_keyword():
result = integer_array([1, 2], dtype='int8')
assert result.dtype == Int8Dtype()

# if values has dtype -> override it
result = integer_array(np.array([1, 2], dtype='int8'), dtype='int32')
assert result.dtype == Int32Dtype()


def test_to_integer_array_float():
result = integer_array([1., 2.])
expected = integer_array(np.array([1, 2], dtype='int64'))
Expand Down