@@ -148,7 +148,7 @@ class BaseBlockManager(DataManager):
148
148
_known_consolidated : bool
149
149
_is_consolidated : bool
150
150
151
- def __init__ (self , blocks , axes , verify_integrity : bool = True ):
151
+ def __init__ (self , blocks , axes , verify_integrity = True ):
152
152
raise NotImplementedError
153
153
154
154
@classmethod
@@ -889,8 +889,7 @@ def __init__(
889
889
):
890
890
891
891
if verify_integrity :
892
- # Assertion disabled for performance
893
- # assert all(isinstance(x, Index) for x in axes)
892
+ assert all (isinstance (x , Index ) for x in axes )
894
893
895
894
for block in blocks :
896
895
if self .ndim != block .ndim :
@@ -1559,9 +1558,8 @@ def __init__(
1559
1558
verify_integrity : bool = False ,
1560
1559
fastpath = lib .no_default ,
1561
1560
):
1562
- # Assertions disabled for performance
1563
- # assert isinstance(block, Block), type(block)
1564
- # assert isinstance(axis, Index), type(axis)
1561
+ assert isinstance (block , Block ), type (block )
1562
+ assert isinstance (axis , Index ), type (axis )
1565
1563
1566
1564
if fastpath is not lib .no_default :
1567
1565
warnings .warn (
@@ -1662,8 +1660,7 @@ def getitem_mgr(self, indexer) -> SingleBlockManager:
1662
1660
return type (self )(block , new_idx )
1663
1661
1664
1662
def get_slice (self , slobj : slice , axis : int = 0 ) -> SingleBlockManager :
1665
- # Assertion disabled for performance
1666
- # assert isinstance(slobj, slice), type(slobj)
1663
+ assert isinstance (slobj , slice ), type (slobj )
1667
1664
if axis >= self .ndim :
1668
1665
raise IndexError ("Requested axis not found in manager" )
1669
1666
@@ -1781,10 +1778,9 @@ def create_block_manager_from_arrays(
1781
1778
axes : list [Index ],
1782
1779
consolidate : bool = True ,
1783
1780
) -> BlockManager :
1784
- # Assertions disabled for performance
1785
- # assert isinstance(names, Index)
1786
- # assert isinstance(axes, list)
1787
- # assert all(isinstance(x, Index) for x in axes)
1781
+ assert isinstance (names , Index )
1782
+ assert isinstance (axes , list )
1783
+ assert all (isinstance (x , Index ) for x in axes )
1788
1784
1789
1785
arrays = [_extract_array (x ) for x in arrays ]
1790
1786
@@ -1839,8 +1835,7 @@ def _form_blocks(
1839
1835
if names_idx .equals (axes [0 ]):
1840
1836
names_indexer = np .arange (len (names_idx ))
1841
1837
else :
1842
- # Assertion disabled for performance
1843
- # assert names_idx.intersection(axes[0]).is_unique
1838
+ assert names_idx .intersection (axes [0 ]).is_unique
1844
1839
names_indexer = names_idx .get_indexer_for (axes [0 ])
1845
1840
1846
1841
for i , name_idx in enumerate (names_indexer ):
@@ -1868,9 +1863,10 @@ def _form_blocks(
1868
1863
1869
1864
if len (items_dict ["DatetimeTZBlock" ]):
1870
1865
dttz_blocks = [
1871
- DatetimeTZBlock (
1866
+ new_block (
1872
1867
ensure_block_shape (extract_array (array ), 2 ),
1873
- placement = BlockPlacement (i ),
1868
+ klass = DatetimeTZBlock ,
1869
+ placement = i ,
1874
1870
ndim = 2 ,
1875
1871
)
1876
1872
for i , array in items_dict ["DatetimeTZBlock" ]
@@ -1885,14 +1881,14 @@ def _form_blocks(
1885
1881
1886
1882
if len (items_dict ["CategoricalBlock" ]) > 0 :
1887
1883
cat_blocks = [
1888
- CategoricalBlock (array , placement = BlockPlacement ( i ) , ndim = 2 )
1884
+ new_block (array , klass = CategoricalBlock , placement = i , ndim = 2 )
1889
1885
for i , array in items_dict ["CategoricalBlock" ]
1890
1886
]
1891
1887
blocks .extend (cat_blocks )
1892
1888
1893
1889
if len (items_dict ["ExtensionBlock" ]):
1894
1890
external_blocks = [
1895
- ExtensionBlock (array , placement = BlockPlacement ( i ) , ndim = 2 )
1891
+ new_block (array , klass = ExtensionBlock , placement = i , ndim = 2 )
1896
1892
for i , array in items_dict ["ExtensionBlock" ]
1897
1893
]
1898
1894
@@ -1925,7 +1921,7 @@ def _simple_blockify(tuples, dtype, consolidate: bool) -> list[Block]:
1925
1921
if dtype is not None and values .dtype != dtype : # pragma: no cover
1926
1922
values = values .astype (dtype )
1927
1923
1928
- block = new_block (values , placement = BlockPlacement ( placement ) , ndim = 2 )
1924
+ block = new_block (values , placement = placement , ndim = 2 )
1929
1925
return [block ]
1930
1926
1931
1927
@@ -1948,14 +1944,14 @@ def _multi_blockify(tuples, dtype: DtypeObj | None = None, consolidate: bool = T
1948
1944
list (tup_block ), dtype # type: ignore[arg-type]
1949
1945
)
1950
1946
1951
- block = new_block (values , placement = BlockPlacement ( placement ) , ndim = 2 )
1947
+ block = new_block (values , placement = placement , ndim = 2 )
1952
1948
new_blocks .append (block )
1953
1949
1954
1950
return new_blocks
1955
1951
1956
1952
1957
1953
def _tuples_to_blocks_no_consolidate (tuples , dtype : DtypeObj | None ) -> list [Block ]:
1958
- # tuples produced within _form_blocks are of the form (placement, array)
1954
+ # tuples produced within _form_blocks are of the form (placement, whatever, array)
1959
1955
if dtype is not None :
1960
1956
return [
1961
1957
new_block (
0 commit comments