Skip to content

Commit 6c94a17

Browse files
committed
Fix ambiguous code that fails under Python 3.12
1 parent b4da987 commit 6c94a17

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pyscf/soscf/m3soscf.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,26 +561,27 @@ def dump_info(self, log, cycles):
561561
log.info("Index: Energy [ha]: Occupation: Symmetry:")
562562
if self.method in ['uhf', 'uks']:
563563
for index, mo_e in enumerate(self.mf.mo_energy[0]):
564-
label = "A " * (self.mf.mo_occ[0,index] > 0)
565564
s = f"{index} (A){(9 - len(str(index))) * ' '}{mo_e}{' ' * (36 - len(str(mo_e)))}"
566-
s += f"{label}"
565+
if self.mf.mo_occ[0,index] > 0:
566+
s += "A "
567567
s += f"{' ' * (65 - len(s))}{irreps[0][index]}"
568568
s +=f"{(f' (FORCED, Overlap: {round(symm_overlap[0][index], 5)})') * forced_irreps}"
569569
log.info(s)
570570

571571
mo_e = self.mf.mo_energy[1, index]
572-
label = " B" * (self.mf.mo_occ[1,index] > 0)
573572
s = f"{index} (B){(9 - len(str(index))) * ' '}{mo_e}{' ' * (36 - len(str(mo_e)))}"
574-
s += f"{label}"
573+
if self.mf.mo_occ[1,index] > 0:
574+
s += " B"
575575
s += f"{' ' * (65 - len(s))}{irreps[1][index]}"
576576
s +=f"{(f' (FORCED, Overlap: {round(symm_overlap[1][index], 5)})') * forced_irreps}"
577577
log.info(s)
578578
else:
579579
for index, mo_e in enumerate(self.mf.mo_energy):
580-
label = "A B" if self.mf.mo_occ[index] > 1 else "A" if self.mf.mo_occ[index] > 0 \
581-
else ""
582580
s = f"{index}{(13 - len(str(index))) * ' '}{mo_e}{' ' * (36 - len(str(mo_e)))}"
583-
s += f"{label}"
581+
if self.mf.mo_occ[index] > 1:
582+
s += "A B"
583+
elif self.mf.mo_occ[index] > 0:
584+
s += "A"
584585
s += f"{' ' * (65 - len(s))}{irreps[index]}"
585586
s += f"{(f' (FORCED, Overlap: {round(symm_overlap[index], 5)})') * forced_irreps}"
586587
log.info(s)

0 commit comments

Comments
 (0)