Skip to content

Commit 3e5ec56

Browse files
committed
Fix CI
1 parent 5b53438 commit 3e5ec56

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

pandas/core/arrays/integer.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ def coerce_to_array(values, dtype, mask=None, copy=False):
152152
dtype = dtype.lower()
153153
if not issubclass(type(dtype), _IntegerDtype):
154154
try:
155-
dtype = _dtypes[str(np.dtype(dtype.name.lower()))]
155+
try:
156+
dtype = _dtypes[str(np.dtype(dtype.name.lower()))]
157+
except AttributeError:
158+
dtype = _dtypes[str(np.dtype(dtype.lower()))]
156159
except KeyError:
157160
raise ValueError("invalid dtype specified {}".format(dtype))
158161

pandas/core/dtypes/cast.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import numpy as np
66

7+
from pandas.errors import AbstractMethodError
78
from pandas._libs import lib, tslib, tslibs
89
from pandas._libs.tslibs import OutOfBoundsDatetime, Period, iNaT
910
from pandas.compat import PY3, string_types, text_type, to_str
@@ -617,12 +618,17 @@ def astype_nansafe(arr, dtype, copy=True, skipna=False):
617618
if is_extension_array_dtype(dtype):
618619
if is_object_dtype(arr):
619620
try:
620-
return dtype.construct_array_type()._from_sequence_of_strings(
621-
arr, dtype=dtype, copy=copy)
621+
array_type = dtype.construct_array_type()
622622
except AttributeError:
623623
dtype = pandas_dtype(dtype)
624-
return dtype.construct_array_type()._from_sequence_of_strings(
625-
arr, dtype=dtype, copy=copy)
624+
array_type = dtype.construct_array_type()
625+
try:
626+
# use _from_sequence_of_strings if the class defines it
627+
return array_type._from_sequence_of_strings(arr,
628+
dtype=dtype,
629+
copy=copy)
630+
except AbstractMethodError:
631+
return array_type._from_sequence(arr, dtype=dtype, copy=copy)
626632
else:
627633
try:
628634
return dtype.construct_array_type()._from_sequence(

pandas/core/indexes/numeric.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
from pandas.core.dtypes.common import (
1010
is_bool, is_bool_dtype, is_dtype_equal, is_float, is_integer_dtype,
11-
is_scalar, needs_i8_conversion, pandas_dtype)
11+
is_scalar, needs_i8_conversion, pandas_dtype, is_extension_array_dtype,
12+
)
1213
import pandas.core.dtypes.concat as _concat
1314
from pandas.core.dtypes.missing import isna
1415

@@ -328,7 +329,8 @@ def astype(self, dtype, copy=True):
328329
msg = ('Cannot convert Float64Index to dtype {dtype}; integer '
329330
'values are required for conversion').format(dtype=dtype)
330331
raise TypeError(msg)
331-
elif is_integer_dtype(dtype) and self.hasnans:
332+
elif is_integer_dtype(dtype) and self.hasnans and \
333+
not is_extension_array_dtype(dtype):
332334
# GH 13149
333335
raise ValueError('Cannot convert NA to integer')
334336
return super(Float64Index, self).astype(dtype, copy=copy)

pandas/tests/extension/base/io.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
import pandas as pd
22
from pandas.compat import StringIO
3-
from pandas.core.arrays.integer import Int64Dtype
3+
from pandas.core.arrays.integer import (
4+
Int8Dtype, Int16Dtype, Int32Dtype, Int64Dtype, UInt8Dtype, UInt16Dtype,
5+
UInt32Dtype, UInt64Dtype)
46
from .base import BaseExtensionTests
57

8+
def make_data():
9+
return (list(range(1, 9)) + [np.nan] + list(range(10, 98))
10+
+ [np.nan] + [99, 100])
11+
12+
13+
@pytest.fixture(params=[Int8Dtype, Int16Dtype, Int32Dtype, Int64Dtype,
14+
UInt8Dtype, UInt16Dtype, UInt32Dtype, UInt64Dtype])
15+
def dtype(request):
16+
return request.param()
17+
18+
19+
@pytest.fixture
20+
def data(dtype):
21+
return integer_array(make_data(), dtype=dtype)
622

723
class ExtensionParsingTests(BaseExtensionTests):
824
def test_EA_types(self):

0 commit comments

Comments
 (0)