Skip to content

Commit 414246b

Browse files
committed
BUG: cast mask back to bool (hack)
1 parent b504129 commit 414246b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pandas/src/tseries.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def maybe_indices_to_slice(ndarray[int64_t] indices):
442442
return slice(indices[0], indices[n - 1] + 1)
443443

444444

445-
def maybe_booleans_to_slice(ndarray[uint8_t, cast=True] mask):
445+
def maybe_booleans_to_slice(ndarray[uint8_t] mask):
446446
cdef:
447447
Py_ssize_t i, n = len(mask)
448448
Py_ssize_t start, end
@@ -451,7 +451,7 @@ def maybe_booleans_to_slice(ndarray[uint8_t, cast=True] mask):
451451
for i in range(n):
452452
if mask[i]:
453453
if finished:
454-
return mask
454+
return mask.view(np.bool_)
455455
if not started:
456456
started = 1
457457
start = i

pandas/tests/test_tseries.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ def test_duplicated_with_nas():
186186
expected = trues + falses
187187
assert(np.array_equal(result, expected))
188188

189+
def test_maybe_booleans_to_slice():
190+
arr = np.array([0, 0, 1, 1, 1, 0, 1], dtype=np.uint8)
191+
result = lib.maybe_booleans_to_slice(arr)
192+
assert(result.dtype == np.bool_)
193+
194+
189195
def test_convert_objects():
190196
arr = np.array(['a', 'b', nan, nan, 'd', 'e', 'f'], dtype='O')
191197
result = lib.maybe_convert_objects(arr)

0 commit comments

Comments
 (0)