Skip to content

Commit 56470c3

Browse files
committed
Fixups:
* Ensure data generated OK. * Remove erroneous comments about alignment. That was user error.
1 parent c4604df commit 56470c3

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

pandas/core/arrays/interval.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,7 @@ def take(self, indices, allow_fill=False, fill_value=None, axis=None,
779779

780780
def where(self, cond, other):
781781
if is_scalar(other) and isna(other):
782-
lother = other
783-
rother = other
782+
lother = rother = other
784783
else:
785784
self._check_closed_matches(other, name='other')
786785
lother = other.left

pandas/tests/extension/base/methods.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ def test_where_series(self, data, na_value, as_frame):
210210

211211
if as_frame:
212212
ser = ser.to_frame(name='a')
213-
# TODO: alignment is broken for ndarray `cond`
214-
cond = pd.DataFrame({"a": cond})
213+
cond = cond.reshape(-1, 1)
215214

216215
result = ser.where(cond)
217216
expected = pd.Series(cls._from_sequence([a, a, na_value, na_value],
@@ -225,9 +224,7 @@ def test_where_series(self, data, na_value, as_frame):
225224
cond = np.array([True, False, True, True])
226225
other = cls._from_sequence([a, b, a, b], dtype=data.dtype)
227226
if as_frame:
228-
# TODO: alignment is broken for ndarray `cond`
229227
other = pd.DataFrame({"a": other})
230-
# TODO: alignment is broken for array `other`
231228
cond = pd.DataFrame({"a": cond})
232229
result = ser.where(cond, other)
233230
expected = pd.Series(cls._from_sequence([a, b, b, b],

pandas/tests/extension/conftest.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ def dtype():
1111

1212
@pytest.fixture
1313
def data():
14-
"""Length-100 array for this type."""
14+
"""Length-100 array for this type.
15+
16+
* data[0] and data[1] should both be non missing
17+
* data[0] and data[1] should not gbe equal
18+
"""
1519
raise NotImplementedError
1620

1721

pandas/tests/extension/test_categorical.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525

2626

2727
def make_data():
28-
return np.random.choice(list(string.ascii_letters), size=100)
28+
while True:
29+
values = np.random.choice(list(string.ascii_letters), size=100)
30+
# ensure we meet the requirement
31+
if values[0] != values[1]:
32+
break
33+
return values
2934

3035

3136
@pytest.fixture

pandas/tests/extension/test_sparse.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def make_data(fill_value):
1313
data = np.random.uniform(size=100)
1414
else:
1515
data = np.random.randint(1, 100, size=100)
16+
if data[0] == data[1]:
17+
data[0] += 1
1618

1719
data[2::3] = fill_value
1820
return data

0 commit comments

Comments
 (0)