@@ -427,7 +427,7 @@ def _read_annot_ctab_old_format(fobj, n_entries):
427427 for i in range (n_entries ):
428428 # structure name length + string
429429 name_length = np .fromfile (fobj , dt , 1 )[0 ]
430- name = np .fromfile (fobj , '|S%d' % name_length , 1 )[0 ]
430+ name = np .fromfile (fobj , f '|S{ name_length } ' , 1 )[0 ]
431431 names .append (name )
432432 # read RGBT for this entry
433433 ctab [i , :4 ] = np .fromfile (fobj , dt , 4 )
@@ -465,13 +465,13 @@ def _read_annot_ctab_new_format(fobj, ctab_version):
465465 dt = _ANNOT_DT
466466 # This code works with a file version == 2, nothing else
467467 if ctab_version != 2 :
468- raise Exception ('Unrecognised .annot file version (%i)' , ctab_version )
468+ raise Exception (f 'Unrecognised .annot file version ({ ctab_version } )' )
469469 # maximum LUT index present in the file
470470 max_index = np .fromfile (fobj , dt , 1 )[0 ]
471471 ctab = np .zeros ((max_index , 5 ), dt )
472472 # orig_tab string length + string
473473 length = np .fromfile (fobj , dt , 1 )[0 ]
474- np .fromfile (fobj , '|S%d' % length , 1 )[0 ] # Orig table path
474+ np .fromfile (fobj , f '|S{ length } ' , 1 )[0 ] # Orig table path
475475 # number of LUT entries present in the file
476476 entries_to_read = np .fromfile (fobj , dt , 1 )[0 ]
477477 names = list ()
@@ -480,7 +480,7 @@ def _read_annot_ctab_new_format(fobj, ctab_version):
480480 idx = np .fromfile (fobj , dt , 1 )[0 ]
481481 # structure name length + string
482482 name_length = np .fromfile (fobj , dt , 1 )[0 ]
483- name = np .fromfile (fobj , '|S%d' % name_length , 1 )[0 ]
483+ name = np .fromfile (fobj , f '|S{ name_length } ' , 1 )[0 ]
484484 names .append (name )
485485 # RGBT
486486 ctab [idx , :4 ] = np .fromfile (fobj , dt , 4 )
@@ -525,7 +525,7 @@ def write(num, dtype=dt):
525525 def write_string (s ):
526526 s = (s if isinstance (s , bytes ) else s .encode ()) + b'\x00 '
527527 write (len (s ))
528- write (s , dtype = '|S%d' % len (s ))
528+ write (s , dtype = f '|S{ len (s )} ' )
529529
530530 # Generate annotation values for each ctab entry
531531 if fill_ctab :
0 commit comments