Skip to content

Commit 3b8dd50

Browse files
committed
Use match/case instead of nested elif in lp_diag
1 parent 0ab1b8f commit 3b8dd50

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

message_ix/tools/lp_diag/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -647,19 +647,18 @@ def row_att(
647647
print(f"{sec_name} value {val} ignored for neutral row {row_name}.")
648648
return
649649
attr = self.seq_row.get(row_seq) # [row_name, lo_bnd, up_bnd, row_type]
650-
if sec_name == "rhs": # process the RHS value
651-
if row_type == "G": # update lo_bnd
650+
match sec_name, row_type:
651+
case "rhs", "G": # update lo_bnd
652652
attr[1] = val
653-
elif row_type == "L": # update up_bnd
653+
case "rhs", "L": # update up_bnd
654654
attr[2] = val
655-
elif row_type == "E": # update both bounds
655+
case "rhs", "E": # update both bounds
656656
attr[1] = attr[2] = val
657-
else: # process the ranges value
658-
if row_type == "G": # update up_bnd
657+
case "ranges", "G": # update up_bnd
659658
attr[2] = attr[1] + abs(val)
660-
elif row_type == "L": # update lo_bnd
659+
case "ranges", "L": # update lo_bnd
661660
attr[1] = attr[2] - abs(val)
662-
elif row_type == "E": # update both bounds
661+
case "ranges", "E": # update both bounds
663662
if val > 0:
664663
attr[2] = attr[1] + val
665664
else:

0 commit comments

Comments
 (0)