Skip to content

Commit 6752833

Browse files
CI: numpydev ragged array dtype warning (#31203)
1 parent f4c99ff commit 6752833

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

pandas/core/indexes/multi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ def drop(self, codes, level=None, errors="raise"):
20582058

20592059
if not isinstance(codes, (np.ndarray, Index)):
20602060
try:
2061-
codes = com.index_labels_to_array(codes)
2061+
codes = com.index_labels_to_array(codes, dtype=object)
20622062
except ValueError:
20632063
pass
20642064

pandas/core/strings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def cat_core(list_of_columns: List, sep: str):
7979
return np.sum(arr_of_cols, axis=0)
8080
list_with_sep = [sep] * (2 * len(list_of_columns) - 1)
8181
list_with_sep[::2] = list_of_columns
82-
arr_with_sep = np.asarray(list_with_sep)
82+
arr_with_sep = np.asarray(list_with_sep, dtype=object)
8383
return np.sum(arr_with_sep, axis=0)
8484

8585

pandas/tests/arrays/categorical/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,6 @@ def test_constructor_imaginary(self):
605605
@pytest.mark.skipif(_np_version_under1p16, reason="Skipping for NumPy <1.16")
606606
def test_constructor_string_and_tuples(self):
607607
# GH 21416
608-
c = pd.Categorical(["c", ("a", "b"), ("b", "a"), "c"])
608+
c = pd.Categorical(np.array(["c", ("a", "b"), ("b", "a"), "c"], dtype=object))
609609
expected_index = pd.Index([("a", "b"), ("b", "a"), "c"])
610610
assert c.categories.equals(expected_index)

pandas/tests/arrays/categorical/test_missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_fillna_iterable_category(self, named):
7777
Point = collections.namedtuple("Point", "x y")
7878
else:
7979
Point = lambda *args: args # tuple
80-
cat = Categorical([Point(0, 0), Point(0, 1), None])
80+
cat = Categorical(np.array([Point(0, 0), Point(0, 1), None], dtype=object))
8181
result = cat.fillna(Point(0, 0))
8282
expected = Categorical([Point(0, 0), Point(0, 1), Point(0, 0)])
8383

pandas/tests/extension/base/getitem.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ def test_take_non_na_fill_value(self, data_missing):
245245
fill_value = data_missing[1] # valid
246246
na = data_missing[0]
247247

248-
array = data_missing._from_sequence([na, fill_value, na])
248+
array = data_missing._from_sequence(
249+
[na, fill_value, na], dtype=data_missing.dtype
250+
)
249251
result = array.take([-1, 1], fill_value=fill_value, allow_fill=True)
250252
expected = array.take([1, 1])
251253
self.assert_extension_array_equal(result, expected)
@@ -293,10 +295,12 @@ def test_reindex_non_na_fill_value(self, data_missing):
293295
valid = data_missing[1]
294296
na = data_missing[0]
295297

296-
array = data_missing._from_sequence([na, valid])
298+
array = data_missing._from_sequence([na, valid], dtype=data_missing.dtype)
297299
ser = pd.Series(array)
298300
result = ser.reindex([0, 1, 2], fill_value=valid)
299-
expected = pd.Series(data_missing._from_sequence([na, valid, valid]))
301+
expected = pd.Series(
302+
data_missing._from_sequence([na, valid, valid], dtype=data_missing.dtype)
303+
)
300304

301305
self.assert_series_equal(result, expected)
302306

pandas/tests/extension/json/array.py

+5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ def __setitem__(self, key, value):
113113
def __len__(self) -> int:
114114
return len(self.data)
115115

116+
def __array__(self, dtype=None):
117+
if dtype is None:
118+
dtype = object
119+
return np.asarray(self.data, dtype=dtype)
120+
116121
@property
117122
def nbytes(self) -> int:
118123
return sys.getsizeof(self.data)

pandas/tests/extension/json/test_json.py

-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ def test_unstack(self, data, index):
163163
# this matches otherwise
164164
return super().test_unstack(data, index)
165165

166-
@pytest.mark.xfail(reason="Inconsistent sizes.")
167-
def test_transpose(self, data):
168-
super().test_transpose(data)
169-
170166

171167
class TestGetitem(BaseJSON, base.BaseGetitemTests):
172168
pass

0 commit comments

Comments
 (0)