File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -319,10 +319,19 @@ def _save_batch_index(self):
319319 batch_index = np .zeros (len (self .all_ids ), batch_index_dtype )
320320 batch_index ["id" ] = np .array (self .all_ids )
321321 batch_index ["batch_num" ] = np .array (self .all_batch_nums )
322- batch_index .sort (order = "id" )
323322
323+ # Save the batch index in insertion order
324+ filename = "batch_index_insertion_order.npy"
325+ self ._save_file (filename , batch_index )
326+
327+ # Sort the batch index by id, and save it again
328+ batch_index .sort (order = "id" )
324329 filename = "batch_index.npy"
330+ self ._save_file (filename , batch_index )
331+
332+ def _save_file (self , filename : str , data : np .ndarray ):
333+ """Save a numpy array to a file in the result directory provided"""
325334 savepath = self .result_dir / filename
326335 if savepath .exists ():
327- RuntimeError ("The path to save batch index already exists." )
328- np .save (savepath , batch_index , allow_pickle = False )
336+ raise RuntimeError (f "The path to save { filename } already exists." )
337+ np .save (savepath , data , allow_pickle = False )
You can’t perform that action at this time.
0 commit comments