@@ -110,8 +110,6 @@ class BlockManager(PandasObject):
110110 __slots__ = [
111111 "axes" ,
112112 "blocks" ,
113- "_ndim" ,
114- "_shape" ,
115113 "_known_consolidated" ,
116114 "_is_consolidated" ,
117115 "_blknos" ,
@@ -759,9 +757,7 @@ def get_slice(self, slobj: slice, axis: int = 0) -> "BlockManager":
759757 if axis == 0 :
760758 new_blocks = self ._slice_take_blocks_ax0 (slobj )
761759 elif axis == 1 :
762- _slicer = [slice (None )] * (axis + 1 )
763- _slicer [axis ] = slobj
764- slicer = tuple (_slicer )
760+ slicer = (slice (None ), slobj )
765761 new_blocks = [blk .getitem_block (slicer ) for blk in self .blocks ]
766762 else :
767763 raise IndexError ("Requested axis not found in manager" )
@@ -1103,7 +1099,6 @@ def value_getitem(placement):
11031099 if len (val_locs ) == len (blk .mgr_locs ):
11041100 removed_blknos .append (blkno )
11051101 else :
1106- self ._blklocs [blk .mgr_locs .indexer ] = - 1
11071102 blk .delete (blk_locs )
11081103 self ._blklocs [blk .mgr_locs .indexer ] = np .arange (len (blk ))
11091104
@@ -1115,9 +1110,7 @@ def value_getitem(placement):
11151110 new_blknos = np .empty (self .nblocks , dtype = np .int64 )
11161111 new_blknos .fill (- 1 )
11171112 new_blknos [~ is_deleted ] = np .arange (self .nblocks - len (removed_blknos ))
1118- self ._blknos = algos .take_1d (
1119- new_blknos , self ._blknos , axis = 0 , allow_fill = False
1120- )
1113+ self ._blknos = new_blknos [self ._blknos ]
11211114 self .blocks = tuple (
11221115 blk for i , blk in enumerate (self .blocks ) if i not in set (removed_blknos )
11231116 )
@@ -1128,8 +1121,9 @@ def value_getitem(placement):
11281121
11291122 new_blocks : List [Block ] = []
11301123 if value_is_extension_type :
1131- # This code (ab-)uses the fact that sparse blocks contain only
1124+ # This code (ab-)uses the fact that EA blocks contain only
11321125 # one item.
1126+ # TODO(EA2D): special casing unnecessary with 2D EAs
11331127 new_blocks .extend (
11341128 make_block (
11351129 values = value ,
@@ -1162,7 +1156,7 @@ def value_getitem(placement):
11621156 # Newly created block's dtype may already be present.
11631157 self ._known_consolidated = False
11641158
1165- def insert (self , loc : int , item , value , allow_duplicates : bool = False ):
1159+ def insert (self , loc : int , item : Label , value , allow_duplicates : bool = False ):
11661160 """
11671161 Insert item at selected position.
11681162
@@ -1185,7 +1179,7 @@ def insert(self, loc: int, item, value, allow_duplicates: bool = False):
11851179 # insert to the axis; this could possibly raise a TypeError
11861180 new_axis = self .items .insert (loc , item )
11871181
1188- if value .ndim == self .ndim - 1 and not is_extension_array_dtype (value ):
1182+ if value .ndim == self .ndim - 1 and not is_extension_array_dtype (value . dtype ):
11891183 value = _safe_reshape (value , (1 ,) + value .shape )
11901184
11911185 block = make_block (values = value , ndim = self .ndim , placement = slice (loc , loc + 1 ))
@@ -1959,14 +1953,14 @@ def _compare_or_regex_search(a, b, regex=False):
19591953 return result
19601954
19611955
1962- def _fast_count_smallints (arr ) :
1956+ def _fast_count_smallints (arr : np . ndarray ) -> np . ndarray :
19631957 """Faster version of set(arr) for sequences of small numbers."""
19641958 counts = np .bincount (arr .astype (np .int_ ))
19651959 nz = counts .nonzero ()[0 ]
19661960 return np .c_ [nz , counts [nz ]]
19671961
19681962
1969- def _preprocess_slice_or_indexer (slice_or_indexer , length , allow_fill ):
1963+ def _preprocess_slice_or_indexer (slice_or_indexer , length : int , allow_fill : bool ):
19701964 if isinstance (slice_or_indexer , slice ):
19711965 return (
19721966 "slice" ,
0 commit comments