@@ -406,7 +406,7 @@ def _parse_shift(self, shift, prev, align):
406
406
self ._junction_error (prev , "LONE ATOMS: Previous odd section, which has an open end,"
407
407
" is wider than the incoming one. A wider odd section must always"
408
408
" have a closed end. You can solve this by making the previous section"
409
- " one unit smaller or larger (L = L +- 1)." , "raise"
409
+ " one unit smaller or larger (L = L +- 1)." , self . on_lone_atom
410
410
)
411
411
412
412
# Get the difference in width between the previous and this ribbon section
@@ -415,8 +415,8 @@ def _parse_shift(self, shift, prev, align):
415
415
# on 1, 2, 3 or 4 atoms. After that, the cycle just repeats (e.g. 5 == 1, etc).
416
416
diff_mod = W_diff % 4
417
417
418
- # Now, we need to calculate the offset that we have to apply to the incoming
419
- # section depending on several factors.
418
+ # Calculate the shifts that are valid (don't leave atoms with less than 2 bonds)
419
+ # This depends on several factors.
420
420
if diff_mod % 2 == 0 and W % 2 == 1 :
421
421
# Both sections are odd
422
422
@@ -445,7 +445,7 @@ def _parse_shift(self, shift, prev, align):
445
445
446
446
# Update the valid shift limits if the sections are aligned on any of the edges.
447
447
shift_offset = self ._offset_from_center (align , prev )
448
- valid_shifts + = shift_offset
448
+ valid_shifts - = shift_offset
449
449
elif prev .W == W :
450
450
valid_shifts = np .array ([0 ])
451
451
else :
@@ -469,7 +469,7 @@ def _parse_shift(self, shift, prev, align):
469
469
shift_offset = self ._offset_from_center (align , prev )
470
470
471
471
# Apply the offsets and calculate the maximum and minimum shifts.
472
- min_shift , max_shift = - shift_lim + shift_offset , shift_lim + shift_offset
472
+ min_shift , max_shift = - shift_lim - shift_offset , shift_lim - shift_offset
473
473
474
474
valid_shifts = np .arange (min_shift , max_shift + 1 , 2 )
475
475
else :
0 commit comments