@@ -109,6 +109,13 @@ def __post_init__(
109109 self ._new_file (initial_metadata )
110110 self .open (to_write )
111111
112+ def __str__ (self ):
113+ if self ._file :
114+ status = f'opened for { "writing" if self .to_write else "reading" } '
115+ else :
116+ status = "currently closed but last seen"
117+ return f'"{ self ._file_name } " { status } with { self ._record_count :,} records'
118+
112119 def open (self , to_write : bool = False ):
113120 """Opens this CaptureFile instance for reading or writing, depending on
114121 the value of `to_write`.
@@ -655,10 +662,11 @@ def record_at(self, record_number: int, /) -> Record:
655662 )
656663
657664 # skip nodes as long as path follows rightmost nodes.
658- while ( child_index := next ( root_to_leaf_path )) == len (
659- ( current_rightmost_node := next ( root_to_leaf_rightmost_nodes )). children
665+ for child_index , current_rightmost_node in zip (
666+ root_to_leaf_path , root_to_leaf_rightmost_nodes
660667 ):
661- pass
668+ if child_index != len (current_rightmost_node .children ):
669+ break
662670
663671 # get first persistent child's data cooridnates. This child will refer
664672 # to either the record or the root of a perfect sub-tree of which no
@@ -1393,9 +1401,7 @@ def leaf_to_root_path(position: int, height: int, fan_out: int, /) -> List[int]:
13931401 root."""
13941402
13951403 path = [0 ] * height
1396-
13971404 for i in range (height ):
1398- position , child_index = divmod (position , fan_out )
1399- path [i ] = child_index
1405+ position , path [i ] = divmod (position , fan_out )
14001406
14011407 return path
0 commit comments