Skip to content

Commit 183b1af

Browse files
committed
Improve type handling in readStatistics parsing
Refactored the value assignment in readStatistics to use a try-except block for float conversion, ensuring non-numeric values are handled gracefully. This simplifies the logic and improves robustness when parsing statistics.
1 parent cad83ff commit 183b1af

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/pyscipopt/scip.pxi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12688,14 +12688,14 @@ def readStatistics(filename):
1268812688
if stat_name == "Gap":
1268912689
relevant_value = relevant_value[:-1] # removing %
1269012690

12691-
if isinstance(relevant_value, NUMBER_TYPES):
12691+
try:
1269212692
result[stat_name] = float(relevant_value)
12693+
except:
12694+
result[stat_name] = relevant_value
12695+
else:
1269312696
if stat_name == "Solutions found" and result[stat_name] == 0:
1269412697
break
1269512698

12696-
else: # it's a string
12697-
result[stat_name] = relevant_value
12698-
1269912699
# changing keys to pythonic variable names
1270012700
treated_keys = {"status": "status", "Total Time": "total_time", "solving":"solving_time", "presolving":"presolving_time", "reading":"reading_time",
1270112701
"copying":"copying_time", "Problem name": "problem_name", "Presolved Problem name": "presolved_problem_name", "Variables":"_variables",

0 commit comments

Comments
 (0)