@@ -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 = True ):
151
+ def __init__ (self , blocks , axes , verify_integrity : bool = True ):
152
152
raise NotImplementedError
153
153
154
154
@classmethod
@@ -889,7 +889,8 @@ def __init__(
889
889
):
890
890
891
891
if verify_integrity :
892
- assert all (isinstance (x , Index ) for x in axes )
892
+ # Assertion disabled for performance
893
+ # assert all(isinstance(x, Index) for x in axes)
893
894
894
895
for block in blocks :
895
896
if self .ndim != block .ndim :
@@ -1563,8 +1564,9 @@ def __init__(
1563
1564
verify_integrity : bool = False ,
1564
1565
fastpath = lib .no_default ,
1565
1566
):
1566
- assert isinstance (block , Block ), type (block )
1567
- assert isinstance (axis , Index ), type (axis )
1567
+ # Assertions disabled for performance
1568
+ # assert isinstance(block, Block), type(block)
1569
+ # assert isinstance(axis, Index), type(axis)
1568
1570
1569
1571
if fastpath is not lib .no_default :
1570
1572
warnings .warn (
@@ -1665,7 +1667,8 @@ def getitem_mgr(self, indexer) -> SingleBlockManager:
1665
1667
return type (self )(block , new_idx )
1666
1668
1667
1669
def get_slice (self , slobj : slice , axis : int = 0 ) -> SingleBlockManager :
1668
- assert isinstance (slobj , slice ), type (slobj )
1670
+ # Assertion disabled for performance
1671
+ # assert isinstance(slobj, slice), type(slobj)
1669
1672
if axis >= self .ndim :
1670
1673
raise IndexError ("Requested axis not found in manager" )
1671
1674
@@ -1783,9 +1786,10 @@ def create_block_manager_from_arrays(
1783
1786
axes : list [Index ],
1784
1787
consolidate : bool = True ,
1785
1788
) -> BlockManager :
1786
- assert isinstance (names , Index )
1787
- assert isinstance (axes , list )
1788
- assert all (isinstance (x , Index ) for x in axes )
1789
+ # Assertions disabled for performance
1790
+ # assert isinstance(names, Index)
1791
+ # assert isinstance(axes, list)
1792
+ # assert all(isinstance(x, Index) for x in axes)
1789
1793
1790
1794
arrays = [_extract_array (x ) for x in arrays ]
1791
1795
@@ -1840,7 +1844,8 @@ def _form_blocks(
1840
1844
if names_idx .equals (axes [0 ]):
1841
1845
names_indexer = np .arange (len (names_idx ))
1842
1846
else :
1843
- assert names_idx .intersection (axes [0 ]).is_unique
1847
+ # Assertion disabled for performance
1848
+ # assert names_idx.intersection(axes[0]).is_unique
1844
1849
names_indexer = names_idx .get_indexer_for (axes [0 ])
1845
1850
1846
1851
for i , name_idx in enumerate (names_indexer ):
@@ -1868,10 +1873,9 @@ def _form_blocks(
1868
1873
1869
1874
if len (items_dict ["DatetimeTZBlock" ]):
1870
1875
dttz_blocks = [
1871
- new_block (
1876
+ DatetimeTZBlock (
1872
1877
ensure_block_shape (extract_array (array ), 2 ),
1873
- klass = DatetimeTZBlock ,
1874
- placement = i ,
1878
+ placement = BlockPlacement (i ),
1875
1879
ndim = 2 ,
1876
1880
)
1877
1881
for i , array in items_dict ["DatetimeTZBlock" ]
@@ -1886,14 +1890,14 @@ def _form_blocks(
1886
1890
1887
1891
if len (items_dict ["CategoricalBlock" ]) > 0 :
1888
1892
cat_blocks = [
1889
- new_block (array , klass = CategoricalBlock , placement = i , ndim = 2 )
1893
+ CategoricalBlock (array , placement = BlockPlacement ( i ) , ndim = 2 )
1890
1894
for i , array in items_dict ["CategoricalBlock" ]
1891
1895
]
1892
1896
blocks .extend (cat_blocks )
1893
1897
1894
1898
if len (items_dict ["ExtensionBlock" ]):
1895
1899
external_blocks = [
1896
- new_block (array , klass = ExtensionBlock , placement = i , ndim = 2 )
1900
+ ExtensionBlock (array , placement = BlockPlacement ( i ) , ndim = 2 )
1897
1901
for i , array in items_dict ["ExtensionBlock" ]
1898
1902
]
1899
1903
@@ -1926,7 +1930,7 @@ def _simple_blockify(tuples, dtype, consolidate: bool) -> list[Block]:
1926
1930
if dtype is not None and values .dtype != dtype : # pragma: no cover
1927
1931
values = values .astype (dtype )
1928
1932
1929
- block = new_block (values , placement = placement , ndim = 2 )
1933
+ block = new_block (values , placement = BlockPlacement ( placement ) , ndim = 2 )
1930
1934
return [block ]
1931
1935
1932
1936
@@ -1949,14 +1953,14 @@ def _multi_blockify(tuples, dtype: DtypeObj | None = None, consolidate: bool = T
1949
1953
list (tup_block ), dtype # type: ignore[arg-type]
1950
1954
)
1951
1955
1952
- block = new_block (values , placement = placement , ndim = 2 )
1956
+ block = new_block (values , placement = BlockPlacement ( placement ) , ndim = 2 )
1953
1957
new_blocks .append (block )
1954
1958
1955
1959
return new_blocks
1956
1960
1957
1961
1958
1962
def _tuples_to_blocks_no_consolidate (tuples , dtype : DtypeObj | None ) -> list [Block ]:
1959
- # tuples produced within _form_blocks are of the form (placement, whatever, array)
1963
+ # tuples produced within _form_blocks are of the form (placement, array)
1960
1964
if dtype is not None :
1961
1965
return [
1962
1966
new_block (
0 commit comments