File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -479,8 +479,8 @@ def _editable(self) -> bool:
479479 @staticmethod
480480 def from_history (
481481 other : HistoryBase ,
482- file : Union [ str , Path ] ,
483- id_ : str ,
482+ file : str | Path ,
483+ id_ : str | int ,
484484 overwrite : bool = False ,
485485 ) -> "Hdf5History" :
486486 """Write some History to HDF5.
@@ -491,7 +491,7 @@ def from_history(
491491 History to be copied to HDF5.
492492 file:
493493 HDF5 file to write to (append or create).
494- id_:
494+ `` id_`` :
495495 ID of the history.
496496 overwrite:
497497 Whether to overwrite an existing history with the same id.
@@ -501,6 +501,12 @@ def from_history(
501501 -------
502502 The newly created :class:`Hdf5History`.
503503 """
504+ if isinstance (id_ , int ):
505+ id_ = str (id_ )
506+ if not isinstance (id_ , str ):
507+ raise ValueError (
508+ f"ID must be a string or integer, not { type (id_ )} "
509+ )
504510 history = Hdf5History (file = file , id = id_ )
505511 history ._f = h5py .File (history .file , mode = "a" )
506512
You can’t perform that action at this time.
0 commit comments