Skip to content

Commit

Permalink
LPdiag: minor modifications.
Browse files Browse the repository at this point in the history
Just to please the new version (thus more picky) version of flake8; no changes in the functionality.
  • Loading branch information
marek-iiasa committed Aug 9, 2023
1 parent 408521c commit 07fae19
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions message_ix/tools/lp_diag/lp_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def add_coeff(self, words, n_line):
assert row_seq is not None, f"unknown row name {row_name} (line {n_line})."
val = float(words[2])
assert (

Check warning on line 324 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L319-L324

Added lines #L319 - L324 were not covered by tests
type(val) == float
type(val) is float
), f"string {words[2]} (line {n_line}) is not a number."
# add the matrix element to the lists of: seq_row, seq_col, val
# the lists will be converted to self.mat df after all elements
Expand Down Expand Up @@ -354,7 +354,7 @@ def add_coeff(self, words, n_line):
assert row_seq is not None, f"unknown row name {row_name} (line {n_line})."
val = float(words[4])
assert (

Check warning on line 356 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L352-L356

Added lines #L352 - L356 were not covered by tests
type(val) == float
type(val) is float
), f"string {words[4]} (line {n_line}) is not a number."
self.mat_row.append(row_seq)
self.mat_col.append(col_seq)
Expand Down Expand Up @@ -407,7 +407,7 @@ def add_rhs(self, words, n_line):
row_seq = self.row_name.get(row_name)
assert row_seq is not None, f"unknown RHS row-name {row_name} (line {n_line})."
val = float(words[pos_name + 1])
assert type(val) == float, (
assert type(val) is float, (

Check warning on line 410 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L406-L410

Added lines #L406 - L410 were not covered by tests
f"RHS value {words[pos_name + 1]} (line {n_line}) is not a" " number."
)
attr = self.seq_row.get(row_seq) # [row_name, lo_bnd, up_bnd, row_type]
Expand All @@ -421,7 +421,7 @@ def add_rhs(self, words, n_line):
row_seq is not None
), f"unknown RHS row-name {row_name} (line {n_line})."
val = float(words[pos_name + 3])
assert type(val) == float, (
assert type(val) is float, (

Check warning on line 424 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L423-L424

Added lines #L423 - L424 were not covered by tests
f"RHS value {words[pos_name + 1]} (line {n_line}) is" " not a number."
)
attr = self.seq_row.get(row_seq) # [row_name, lo_bnd, up_bnd, row_type]
Expand Down Expand Up @@ -478,7 +478,7 @@ def add_range(self, words, n_line):
), f"unknown range row-name {row_name} (line {n_line})."
val = float(words[pos_name + 1])
assert (

Check warning on line 480 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L479-L480

Added lines #L479 - L480 were not covered by tests
type(val) == float
type(val) is float
), f"Range value {words[pos_name + 1]} (line {n_line}) is not a number."
attr = self.seq_row.get(row_seq) # [row_name, lo_bnd, up_bnd, row_type]
row_type = attr[3]
Expand All @@ -491,7 +491,7 @@ def add_range(self, words, n_line):
row_seq is not None
), f"unknown ranges row-name {row_name} (line {n_line})."
val = float(words[pos_name + 3])
assert type(val) == float, (
assert type(val) is float, (

Check warning on line 494 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L493-L494

Added lines #L493 - L494 were not covered by tests
f"Ranges value {words[pos_name + 1]} (line {n_line}) is"
" not a number."
)
Expand Down Expand Up @@ -566,7 +566,7 @@ def add_bnd(self, words, n_line):
if typ in bnd_type1: # bound-types that require a value
val = float(words[pos_name + 1])
assert (

Check warning on line 568 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L565-L568

Added lines #L565 - L568 were not covered by tests
type(val) == float
type(val) is float
), f"BOUND value {words[pos_name + 1]} (line {n_line}) is not a number."
at_pos = bnd_type1.get(typ)
if at_pos == 3: # set both bounds
Expand Down Expand Up @@ -895,7 +895,7 @@ def ent_range(self, seq_id, by_row=True) -> str:
if val == self.infty: # used for both infinites (positive and negative)
s.append(self.infty)

Check warning on line 896 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L890-L896

Added lines #L890 - L896 were not covered by tests
else:
if type(val) == int:
if type(val) is int:
val = float(val)
if abs(val) < 1e-10:
s.append("0") # same string for int and float zeros

Check warning on line 901 in message_ix/tools/lp_diag/lp_diag.py

View check run for this annotation

Codecov / codecov/patch

message_ix/tools/lp_diag/lp_diag.py#L898-L901

Added lines #L898 - L901 were not covered by tests
Expand Down

0 comments on commit 07fae19

Please sign in to comment.