File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -481,15 +481,16 @@ cdef class BitmaskArray:
481
481
return bool (ArrowBitGet(self .bitmap.buffer.data, ckey))
482
482
elif is_null_slice(key):
483
483
return self .copy()
484
- elif isinstance (key, slice ):
484
+ elif isinstance (key, slice ) and self .ndim == 1 :
485
485
# fastpath for slices that start at 0 and step 1 at a time
486
486
# towards a positive number.
487
487
# TODO: upstream generic ArrowBitsGet function in nanoarrow
488
488
PySlice_Unpack(key, & start, & stop, & step)
489
489
if start == 0 and stop > 0 and step == 1 :
490
+ if stop > self_.bitmap.size_bits:
491
+ stop = self_.bitmap.size_bits
492
+
490
493
nbytes = (stop + 7 ) // 8
491
- if nbytes > self_.bitmap.size_bits:
492
- nbytes = self_.bitmap.size_bits
493
494
494
495
bma = BitmaskArray.__new__ (BitmaskArray)
495
496
ArrowBitmapInit(& bitmap)
@@ -501,7 +502,7 @@ cdef class BitmaskArray:
501
502
bma.bitmap = bitmap
502
503
bma.buffer_owner = True
503
504
bma.ndim = self_.ndim
504
- bma.shape = self_.shape
505
+ bma.shape[ 0 ] = stop
505
506
bma.strides = self_.strides
506
507
bma.parent = False
507
508
Original file line number Diff line number Diff line change @@ -460,3 +460,10 @@ def test_memoryview(array, expected):
460
460
bma = BitmaskArray (array )
461
461
vw = memoryview (bma )
462
462
assert vw .tolist () == expected
463
+
464
+
465
+ def test_bitmask_array_shape_from_sliced_bitmask ():
466
+ orig_bma = BitmaskArray ([True ] * 100 )
467
+ bma = BitmaskArray (orig_bma [:10 ])
468
+
469
+ assert bma .shape == (10 ,)
You can’t perform that action at this time.
0 commit comments