@@ -320,8 +320,8 @@ def __init__(self, name, voxel=None, vertex=None, affine=None,
320
320
for check_name in ('name' , 'voxel' , 'vertex' ):
321
321
shape = (self .size , 3 ) if check_name == 'voxel' else (self .size , )
322
322
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" )
325
325
326
326
@classmethod
327
327
def from_mask (cls , mask , name = 'other' , affine = None ):
@@ -537,8 +537,8 @@ def to_cifti_brain_structure_name(name):
537
537
else :
538
538
proposed_name = f'CIFTI_STRUCTURE_{ structure .upper ()} _{ orientation .upper ()} '
539
539
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' )
542
542
return proposed_name
543
543
544
544
@property
@@ -650,8 +650,8 @@ def __add__(self, other):
650
650
nvertices = dict (self .nvertices )
651
651
for name , value in other .nvertices .items ():
652
652
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 } " )
655
655
nvertices [name ] = value
656
656
return self .__class__ (
657
657
np .append (self .name , other .name ),
@@ -763,8 +763,8 @@ def __init__(self, name, voxels, vertices, affine=None, volume_shape=None, nvert
763
763
764
764
for check_name in ('name' , 'voxels' , 'vertices' ):
765
765
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" )
768
768
769
769
@classmethod
770
770
def from_brain_models (cls , named_brain_models ):
@@ -804,8 +804,8 @@ def from_brain_models(cls, named_brain_models):
804
804
for name , _ , bm_part in bm .iter_structures ():
805
805
if name in bm .nvertices .keys ():
806
806
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 } " )
809
809
nvertices [name ] = bm .nvertices [name ]
810
810
vertices [name ] = bm_part .vertex
811
811
all_vertices [idx_parcel ] = vertices
@@ -846,8 +846,7 @@ def from_index_mapping(cls, mim):
846
846
name = vertex .brain_structure
847
847
vertices [vertex .brain_structure ] = np .array (vertex )
848
848
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" )
851
850
all_voxels [idx_parcel ] = voxels
852
851
all_vertices [idx_parcel ] = vertices
853
852
all_names .append (parcel .name )
@@ -968,9 +967,8 @@ def __add__(self, other):
968
967
nvertices = dict (self .nvertices )
969
968
for name , value in other .nvertices .items ():
970
969
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 } " )
974
972
nvertices [name ] = value
975
973
return self .__class__ (
976
974
np .append (self .name , other .name ),
@@ -1042,8 +1040,8 @@ def __init__(self, name, meta=None):
1042
1040
1043
1041
for check_name in ('name' , 'meta' ):
1044
1042
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" )
1047
1045
1048
1046
@classmethod
1049
1047
def from_index_mapping (cls , mim ):
@@ -1176,8 +1174,8 @@ def __init__(self, name, label, meta=None):
1176
1174
1177
1175
for check_name in ('name' , 'meta' , 'label' ):
1178
1176
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" )
1181
1179
1182
1180
@classmethod
1183
1181
def from_index_mapping (cls , mim ):
0 commit comments