File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -472,7 +472,7 @@ cdef class BitmaskArray:
472
472
cdef Py_ssize_t start, stop, step
473
473
cdef BitmaskArray bma
474
474
cdef ArrowBitmap bitmap
475
- cdef int64_t nbytes
475
+ cdef int64_t nbytes, nbits
476
476
cdef BitmaskArray self_ = self
477
477
# to_numpy can be expensive, so try to avoid for simple cases
478
478
if isinstance (key, int ) and self .ndim == 1 :
@@ -488,21 +488,23 @@ cdef class BitmaskArray:
488
488
PySlice_Unpack(key, & start, & stop, & step)
489
489
if start == 0 and stop > 0 and step == 1 :
490
490
if stop > self_.bitmap.size_bits:
491
- stop = self_.bitmap.size_bits
491
+ nbits = self_.bitmap.size_bits
492
+ else :
493
+ nbits = stop
492
494
493
495
nbytes = (stop + 7 ) // 8
494
496
495
497
bma = BitmaskArray.__new__ (BitmaskArray)
496
498
ArrowBitmapInit(& bitmap)
497
- ArrowBitmapReserve(& bitmap, nbytes )
499
+ ArrowBitmapReserve(& bitmap, nbits )
498
500
memcpy(bitmap.buffer.data, self_.bitmap.buffer.data, nbytes)
499
501
bitmap.buffer.size_bytes = nbytes
500
502
bitmap.size_bits = stop
501
503
502
504
bma.bitmap = bitmap
503
505
bma.buffer_owner = True
504
506
bma.ndim = self_.ndim
505
- bma.shape[0 ] = stop
507
+ bma.shape[0 ] = nbits
506
508
bma.strides = self_.strides
507
509
bma.parent = False
508
510
Original file line number Diff line number Diff line change @@ -463,7 +463,7 @@ def test_memoryview(array, expected):
463
463
464
464
465
465
def test_bitmask_array_shape_from_sliced_bitmask ():
466
- orig_bma = BitmaskArray ([True ] * 100 )
466
+ orig_bma = BitmaskArray (np . array ( [True ] * 100 ) )
467
467
bma = BitmaskArray (orig_bma [:10 ])
468
468
469
469
assert bma .shape == (10 ,)
You can’t perform that action at this time.
0 commit comments