@@ -406,7 +406,7 @@ def _parse_shift(self, shift, prev, align):
406406 self ._junction_error (prev , "LONE ATOMS: Previous odd section, which has an open end,"
407407 " is wider than the incoming one. A wider odd section must always"
408408 " 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
410410 )
411411
412412 # Get the difference in width between the previous and this ribbon section
@@ -415,8 +415,8 @@ def _parse_shift(self, shift, prev, align):
415415 # on 1, 2, 3 or 4 atoms. After that, the cycle just repeats (e.g. 5 == 1, etc).
416416 diff_mod = W_diff % 4
417417
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.
420420 if diff_mod % 2 == 0 and W % 2 == 1 :
421421 # Both sections are odd
422422
@@ -445,7 +445,7 @@ def _parse_shift(self, shift, prev, align):
445445
446446 # Update the valid shift limits if the sections are aligned on any of the edges.
447447 shift_offset = self ._offset_from_center (align , prev )
448- valid_shifts + = shift_offset
448+ valid_shifts - = shift_offset
449449 elif prev .W == W :
450450 valid_shifts = np .array ([0 ])
451451 else :
@@ -469,7 +469,7 @@ def _parse_shift(self, shift, prev, align):
469469 shift_offset = self ._offset_from_center (align , prev )
470470
471471 # 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
473473
474474 valid_shifts = np .arange (min_shift , max_shift + 1 , 2 )
475475 else :
0 commit comments