@@ -320,8 +320,8 @@ def __init__(self, name, voxel=None, vertex=None, affine=None,
320320 for check_name in ('name' , 'voxel' , 'vertex' ):
321321 shape = (self .size , 3 ) if check_name == 'voxel' else (self .size , )
322322 if getattr (self , check_name ).shape != shape :
323- raise ValueError ("Input {} has incorrect shape ({}) for BrainModelAxis axis" . format (
324- check_name , getattr (self , check_name ).shape ) )
323+ raise ValueError (f "Input { check_name } has incorrect shape "
324+ f"( { getattr (self , check_name ).shape } ) for BrainModelAxis axis" )
325325
326326 @classmethod
327327 def from_mask (cls , mask , name = 'other' , affine = None ):
@@ -537,8 +537,8 @@ def to_cifti_brain_structure_name(name):
537537 else :
538538 proposed_name = f'CIFTI_STRUCTURE_{ structure .upper ()} _{ orientation .upper ()} '
539539 if proposed_name not in cifti2 .CIFTI_BRAIN_STRUCTURES :
540- raise ValueError ('%s was interpreted as %s , which is not a valid CIFTI brain structure '
541- % ( name , proposed_name ) )
540+ raise ValueError (f' { name } was interpreted as { proposed_name } , which is not '
541+ f'a valid CIFTI brain structure' )
542542 return proposed_name
543543
544544 @property
@@ -650,8 +650,8 @@ def __add__(self, other):
650650 nvertices = dict (self .nvertices )
651651 for name , value in other .nvertices .items ():
652652 if name in nvertices .keys () and nvertices [name ] != value :
653- raise ValueError ("Trying to concatenate two BrainModels with inconsistent "
654- " number of vertices for %s" % name )
653+ raise ValueError (f "Trying to concatenate two BrainModels with "
654+ f"inconsistent number of vertices for { name } " )
655655 nvertices [name ] = value
656656 return self .__class__ (
657657 np .append (self .name , other .name ),
@@ -763,8 +763,8 @@ def __init__(self, name, voxels, vertices, affine=None, volume_shape=None, nvert
763763
764764 for check_name in ('name' , 'voxels' , 'vertices' ):
765765 if getattr (self , check_name ).shape != (self .size , ):
766- raise ValueError ("Input {} has incorrect shape ({}) for Parcel axis" . format (
767- check_name , getattr (self , check_name ).shape ) )
766+ raise ValueError (f "Input { check_name } has incorrect shape "
767+ f"( { getattr (self , check_name ).shape } ) for Parcel axis" )
768768
769769 @classmethod
770770 def from_brain_models (cls , named_brain_models ):
@@ -804,8 +804,8 @@ def from_brain_models(cls, named_brain_models):
804804 for name , _ , bm_part in bm .iter_structures ():
805805 if name in bm .nvertices .keys ():
806806 if name in nvertices .keys () and nvertices [name ] != bm .nvertices [name ]:
807- raise ValueError ("Got multiple conflicting number of "
808- "vertices for surface structure %s" % name )
807+ raise ValueError (f "Got multiple conflicting number of "
808+ f "vertices for surface structure { name } " )
809809 nvertices [name ] = bm .nvertices [name ]
810810 vertices [name ] = bm_part .vertex
811811 all_vertices [idx_parcel ] = vertices
@@ -846,8 +846,7 @@ def from_index_mapping(cls, mim):
846846 name = vertex .brain_structure
847847 vertices [vertex .brain_structure ] = np .array (vertex )
848848 if name not in nvertices .keys ():
849- raise ValueError ("Number of vertices for surface structure %s not defined" %
850- name )
849+ raise ValueError (f"Number of vertices for surface structure { name } not defined" )
851850 all_voxels [idx_parcel ] = voxels
852851 all_vertices [idx_parcel ] = vertices
853852 all_names .append (parcel .name )
@@ -968,9 +967,8 @@ def __add__(self, other):
968967 nvertices = dict (self .nvertices )
969968 for name , value in other .nvertices .items ():
970969 if name in nvertices .keys () and nvertices [name ] != value :
971- raise ValueError ("Trying to concatenate two ParcelsAxis with inconsistent "
972- "number of vertices for %s"
973- % name )
970+ raise ValueError (f"Trying to concatenate two ParcelsAxis with "
971+ f"inconsistent number of vertices for { name } " )
974972 nvertices [name ] = value
975973 return self .__class__ (
976974 np .append (self .name , other .name ),
@@ -1042,8 +1040,8 @@ def __init__(self, name, meta=None):
10421040
10431041 for check_name in ('name' , 'meta' ):
10441042 if getattr (self , check_name ).shape != (self .size , ):
1045- raise ValueError ("Input {} has incorrect shape ({}) for ScalarAxis axis" . format (
1046- check_name , getattr (self , check_name ).shape ) )
1043+ raise ValueError (f "Input { check_name } has incorrect shape "
1044+ f"( { getattr (self , check_name ).shape } ) for ScalarAxis axis" )
10471045
10481046 @classmethod
10491047 def from_index_mapping (cls , mim ):
@@ -1176,8 +1174,8 @@ def __init__(self, name, label, meta=None):
11761174
11771175 for check_name in ('name' , 'meta' , 'label' ):
11781176 if getattr (self , check_name ).shape != (self .size , ):
1179- raise ValueError ("Input {} has incorrect shape ({}) for LabelAxis axis" . format (
1180- check_name , getattr (self , check_name ).shape ) )
1177+ raise ValueError (f "Input { check_name } has incorrect shape "
1178+ f"( { getattr (self , check_name ).shape } ) for LabelAxis axis" )
11811179
11821180 @classmethod
11831181 def from_index_mapping (cls , mim ):
0 commit comments