@@ -1151,8 +1151,8 @@ def __mul__(self, scaling_matrix):
1151
1151
# this could probably be a lot smaller
1152
1152
tol = 0.05
1153
1153
1154
- for u , v , k , d in new_g .edges (keys = True , data = True ):
1155
- to_jimage = d ["to_jimage" ] # for node v
1154
+ for u , v , k , dct in new_g .edges (keys = True , data = True ):
1155
+ to_jimage = dct ["to_jimage" ] # for node v
1156
1156
1157
1157
# reduce unnecessary checking
1158
1158
if to_jimage != (0 , 0 , 0 ):
@@ -1191,7 +1191,7 @@ def __mul__(self, scaling_matrix):
1191
1191
if v_present is not None :
1192
1192
new_u = u
1193
1193
new_v = v_present
1194
- new_d = d .copy ()
1194
+ new_d = dct .copy ()
1195
1195
1196
1196
# node now inside supercell
1197
1197
new_d ["to_jimage" ] = (0 , 0 , 0 )
@@ -1229,13 +1229,13 @@ def __mul__(self, scaling_matrix):
1229
1229
if v_present is not None :
1230
1230
new_u = u
1231
1231
new_v = v_present
1232
- new_d = d .copy ()
1232
+ new_d = dct .copy ()
1233
1233
new_to_jimage = tuple (map (int , v_expec_image ))
1234
1234
1235
1235
# normalize direction
1236
1236
if new_v < new_u :
1237
1237
new_u , new_v = new_v , new_u
1238
- new_to_jimage = tuple (np .multiply (- 1 , d ["to_jimage" ]).astype (int ))
1238
+ new_to_jimage = tuple (np .multiply (- 1 , dct ["to_jimage" ]).astype (int ))
1239
1239
1240
1240
new_d ["to_jimage" ] = new_to_jimage
1241
1241
@@ -1250,18 +1250,18 @@ def __mul__(self, scaling_matrix):
1250
1250
# add/delete marked edges
1251
1251
for edge in edges_to_remove :
1252
1252
new_g .remove_edge (* edge )
1253
- for u , v , d in edges_to_add :
1254
- new_g .add_edge (u , v , ** d )
1253
+ for u , v , dct in edges_to_add :
1254
+ new_g .add_edge (u , v , ** dct )
1255
1255
1256
1256
# return new instance of StructureGraph with supercell
1257
- d = {
1257
+ dct = {
1258
1258
"@module" : type (self ).__module__ ,
1259
1259
"@class" : type (self ).__name__ ,
1260
1260
"structure" : new_structure .as_dict (),
1261
1261
"graphs" : json_graph .adjacency_data (new_g ),
1262
1262
}
1263
1263
1264
- return StructureGraph .from_dict (d )
1264
+ return StructureGraph .from_dict (dct )
1265
1265
1266
1266
def __rmul__ (self , other ):
1267
1267
return self .__mul__ (other )
@@ -1307,7 +1307,7 @@ def __str__(self):
1307
1307
1308
1308
def __repr__ (self ):
1309
1309
s = "Structure Graph"
1310
- s += f"\n Structure: \n { self .structure . __repr__ () } "
1310
+ s += f"\n Structure: \n { self .structure !r } "
1311
1311
s += f"\n Graph: { self .name } \n "
1312
1312
s += self ._edges_to_string (self .graph )
1313
1313
return s
@@ -1363,8 +1363,7 @@ def __eq__(self, other: object) -> bool:
1363
1363
if not isinstance (other , StructureGraph ):
1364
1364
return NotImplemented
1365
1365
# sort for consistent node indices
1366
- # PeriodicSite should have a proper __hash__() value,
1367
- # using its frac_coords as a convenient key
1366
+ # PeriodicSite should have a proper __hash__() value, using its frac_coords as a convenient key
1368
1367
mapping = {tuple (site .frac_coords ): self .structure .index (site ) for site in other .structure }
1369
1368
other_sorted = other .__copy__ ()
1370
1369
other_sorted .sort (key = lambda site : mapping [tuple (site .frac_coords )])
@@ -1406,8 +1405,7 @@ def diff(self, other, strict=True):
1406
1405
1407
1406
if strict :
1408
1407
# sort for consistent node indices
1409
- # PeriodicSite should have a proper __hash__() value,
1410
- # using its frac_coords as a convenient key
1408
+ # PeriodicSite should have a proper __hash__() value, using its frac_coords as a convenient key
1411
1409
mapping = {tuple (site .frac_coords ): self .structure .index (site ) for site in other .structure }
1412
1410
other_sorted = copy .copy (other )
1413
1411
other_sorted .sort (key = lambda site : mapping [tuple (site .frac_coords )])
@@ -2668,7 +2666,7 @@ def __str__(self) -> str:
2668
2666
2669
2667
def __repr__ (self ) -> str :
2670
2668
out = "Molecule Graph"
2671
- out += f"\n Molecule: \n { self .molecule . __repr__ () } "
2669
+ out += f"\n Molecule: \n { self .molecule !r } "
2672
2670
out += f"\n Graph: { self .name } \n "
2673
2671
out += self ._edges_to_string (self .graph )
2674
2672
return out
@@ -2725,8 +2723,7 @@ def __eq__(self, other: object) -> bool:
2725
2723
return NotImplemented
2726
2724
2727
2725
# sort for consistent node indices
2728
- # PeriodicSite should have a proper __hash__() value,
2729
- # using its frac_coords as a convenient key
2726
+ # PeriodicSite should have a proper __hash__() value, using its frac_coords as a convenient key
2730
2727
try :
2731
2728
mapping = {tuple (site .coords ): self .molecule .index (site ) for site in other .molecule }
2732
2729
except ValueError :
@@ -2789,8 +2786,7 @@ def diff(self, other, strict=True):
2789
2786
2790
2787
if strict :
2791
2788
# sort for consistent node indices
2792
- # PeriodicSite should have a proper __hash__() value,
2793
- # using its frac_coords as a convenient key
2789
+ # PeriodicSite should have a proper __hash__() value, using its frac_coords as a convenient key
2794
2790
mapping = {tuple (site .frac_coords ): self .molecule .index (site ) for site in other .molecule }
2795
2791
other_sorted = copy .copy (other )
2796
2792
other_sorted .sort (key = lambda site : mapping [tuple (site .frac_coords )])
0 commit comments