@@ -1553,6 +1553,11 @@ def is_consolidated(self) -> bool:
1553
1553
return self ._is_consolidated
1554
1554
1555
1555
def _consolidate_check (self ) -> None :
1556
+ if len (self .blocks ) == 1 :
1557
+ # fastpath
1558
+ self ._is_consolidated = True
1559
+ self ._known_consolidated = True
1560
+ return
1556
1561
dtypes = [blk .dtype for blk in self .blocks if blk ._can_consolidate ]
1557
1562
self ._is_consolidated = len (dtypes ) == len (set (dtypes ))
1558
1563
self ._known_consolidated = True
@@ -1775,10 +1780,20 @@ def _equal_values(self: T, other: T) -> bool:
1775
1780
1776
1781
1777
1782
def create_block_manager_from_blocks (
1778
- blocks : list [Block ], axes : list [Index ], consolidate : bool = True
1783
+ blocks : list [Block ],
1784
+ axes : list [Index ],
1785
+ consolidate : bool = True ,
1786
+ verify_integrity : bool = True ,
1779
1787
) -> BlockManager :
1788
+ # If verify_integrity=False, then caller is responsible for checking
1789
+ # all(x.shape[-1] == len(axes[1]) for x in blocks)
1790
+ # sum(x.shape[0] for x in blocks) == len(axes[0])
1791
+ # set(x for for blk in blocks for x in blk.mgr_locs) == set(range(len(axes[0])))
1792
+ # all(blk.ndim == 2 for blk in blocks)
1793
+ # This allows us to safely pass verify_integrity=False
1794
+
1780
1795
try :
1781
- mgr = BlockManager (blocks , axes )
1796
+ mgr = BlockManager (blocks , axes , verify_integrity = verify_integrity )
1782
1797
1783
1798
except ValueError as err :
1784
1799
arrays = [blk .values for blk in blocks ]
0 commit comments