@@ -2033,11 +2033,11 @@ def get_ftype_counts(self):
2033
2033
2034
2034
def get_dtypes (self ):
2035
2035
dtypes = np .array ([blk .dtype for blk in self .blocks ])
2036
- return dtypes . take ( self ._blknos )
2036
+ return com . take_1d ( dtypes , self ._blknos , allow_fill = False )
2037
2037
2038
2038
def get_ftypes (self ):
2039
2039
ftypes = np .array ([blk .ftype for blk in self .blocks ])
2040
- return ftypes . take ( self ._blknos )
2040
+ return com . take_1d ( ftypes , self ._blknos , allow_fill = False )
2041
2041
2042
2042
def __getstate__ (self ):
2043
2043
block_values = [b .values for b in self .blocks ]
@@ -2322,7 +2322,8 @@ def combine(self, blocks, copy=True):
2322
2322
new_blocks = []
2323
2323
for b in blocks :
2324
2324
b = b .copy (deep = copy )
2325
- b .mgr_locs = inv_indexer .take (b .mgr_locs .as_array )
2325
+ b .mgr_locs = com .take_1d (inv_indexer , b .mgr_locs .as_array , axis = 0 ,
2326
+ allow_fill = False )
2326
2327
new_blocks .append (b )
2327
2328
2328
2329
new_axes = list (self .axes )
@@ -2666,11 +2667,12 @@ def value_getitem(placement):
2666
2667
is_deleted = np .zeros (self .nblocks , dtype = np .bool_ )
2667
2668
is_deleted [removed_blknos ] = True
2668
2669
2669
- new_blknos = np .empty (self .nblocks , dtype = np .int_ )
2670
+ new_blknos = np .empty (self .nblocks , dtype = np .int64 )
2670
2671
new_blknos .fill (- 1 )
2671
2672
new_blknos [~ is_deleted ] = np .arange (self .nblocks -
2672
2673
len (removed_blknos ))
2673
- self ._blknos = new_blknos .take (self ._blknos , axis = 0 )
2674
+ self ._blknos = com .take_1d (new_blknos , self ._blknos , axis = 0 ,
2675
+ allow_fill = False )
2674
2676
self .blocks = tuple (blk for i , blk in enumerate (self .blocks )
2675
2677
if i not in set (removed_blknos ))
2676
2678
@@ -3546,19 +3548,19 @@ def _invert_reordering(reordering, minlength=None):
3546
3548
array([-1, 0, -1, 1, -1, 2])
3547
3549
3548
3550
"""
3549
- reordering = np .asanyarray (reordering )
3551
+ reordering = np .asanyarray (reordering , dtype = np . int64 )
3550
3552
if not com .is_integer_dtype (reordering ):
3551
3553
raise ValueError ("Only integer indexers are supported" )
3552
3554
3553
- nonneg_indices = reordering [reordering >= 0 ]
3555
+ nonneg_indices = reordering [reordering >= 0 ]. astype ( np . int_ )
3554
3556
counts = np .bincount (nonneg_indices , minlength = minlength )
3555
3557
has_non_unique = (counts > 1 ).any ()
3556
3558
3557
- dtype = np .dtype (np .object_ ) if has_non_unique else np .dtype (np .int_ )
3559
+ dtype = np .dtype (np .object_ ) if has_non_unique else np .dtype (np .int64 )
3558
3560
inverted = np .empty_like (counts , dtype = dtype )
3559
3561
inverted .fill (- 1 )
3560
3562
3561
- nonneg_positions = np .arange (len (reordering ), dtype = np .int_ )[reordering >= 0 ]
3563
+ nonneg_positions = np .arange (len (reordering ), dtype = np .int64 )[reordering >= 0 ]
3562
3564
np .put (inverted , nonneg_indices , nonneg_positions )
3563
3565
3564
3566
if has_non_unique :
@@ -3585,6 +3587,8 @@ def _get_blkno_placements(blknos, blk_count, group=True):
3585
3587
3586
3588
"""
3587
3589
3590
+ blknos = com ._ensure_int64 (blknos )
3591
+
3588
3592
# FIXME: blk_count is unused, but it may avoid the use of dicts in cython
3589
3593
for blkno , indexer in lib .get_blkno_indexers (blknos , group ):
3590
3594
yield blkno , BlockPlacement (indexer )
@@ -4076,7 +4080,7 @@ def _fast_count_smallints(arr):
4076
4080
# Handle empty arr case separately: numpy 1.6 chokes on that.
4077
4081
return np .empty ((0 , 2 ), dtype = arr .dtype )
4078
4082
else :
4079
- counts = np .bincount (arr )
4083
+ counts = np .bincount (arr . astype ( np . int_ ) )
4080
4084
nz = counts .nonzero ()[0 ]
4081
4085
return np .c_ [nz , counts [nz ]]
4082
4086
@@ -4089,7 +4093,7 @@ def _preprocess_slice_or_indexer(slice_or_indexer, length, allow_fill):
4089
4093
slice_or_indexer .dtype == np .bool_ ):
4090
4094
return 'mask' , slice_or_indexer , slice_or_indexer .sum ()
4091
4095
else :
4092
- indexer = np .asanyarray (slice_or_indexer , dtype = np .int_ )
4096
+ indexer = np .asanyarray (slice_or_indexer , dtype = np .int64 )
4093
4097
if not allow_fill :
4094
4098
indexer = _maybe_convert_indices (indexer , length )
4095
4099
return 'fancy' , indexer , len (indexer )
0 commit comments