Skip to content

Commit 3fa04a2

Browse files
committed
removed TO_SKIP list
1 parent cd9fd80 commit 3fa04a2

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

examples/csplib/prob001_convert_data.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
See `prob001_car_sequence.py` for the actual model that uses the JSON data file
44
"""
55
import json
6+
import os
7+
68
import numpy as np
79
import re
810
import sys
@@ -139,11 +141,15 @@ def parse_data(fname):
139141
if len(sys.argv) > 2:
140142
out = sys.argv[2]
141143

142-
problems = list(parse_data(fname))
143-
144+
# if fname file does not exist, end with a warning
145+
if not os.path.exists(fname):
146+
print(f"File {fname} does not exist. No data to convert.")
147+
else:
148+
problems = list(parse_data(fname))
149+
# outstring = pprint.pformat(problems, indent=4, sort_dicts=False)
150+
# outstring = outstring.replace("'",'"')
144151

145-
# outstring = pprint.pformat(problems, indent=4, sort_dicts=False)
146-
# outstring = outstring.replace("'",'"')
152+
with open(out, "w") as outfile:
153+
json.dump(problems, outfile, cls=CompactJSONEncoder, indent=4)
147154

148-
with open(out, "w") as outfile:
149-
json.dump(problems, outfile, cls=CompactJSONEncoder, indent=4)
155+
print(f"Converted {len(problems)} problems to {out}")

tests/test_examples.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,8 @@
1919

2020
prefix = '.' if 'y' in getcwd()[-2:] else '..'
2121

22-
TO_SKIP = [
23-
"prob001_convert_data.py"
24-
]
25-
2622
EXAMPLES = glob(join(prefix, "examples", "*.py")) + \
2723
glob(join(prefix, "examples", "csplib", "*.py"))
28-
EXAMPLES = [e for e in EXAMPLES if not any(x in e for x in TO_SKIP)]
2924

3025
ADVANCED_EXAMPLES = glob(join(prefix, "examples", "advanced", "*.py"))
3126

@@ -36,7 +31,9 @@
3631
"minizinc",
3732
]
3833

39-
@pytest.mark.parametrize(("solver", "example"), itertools.product(SOLVERS, EXAMPLES)) # run the test for each combination of solver and example
34+
35+
# run the test for each combination of solver and example
36+
@pytest.mark.parametrize(("solver", "example"), itertools.product(SOLVERS, EXAMPLES))
4037
@pytest.mark.timeout(60) # 60-second timeout for each test
4138
def test_example(solver, example):
4239
"""Loads the example file and executes its __main__ block with the given solver being set as default.
@@ -45,7 +42,10 @@ def test_example(solver, example):
4542
solver ([string]): Loaded with parametrized solver name
4643
example ([string]): Loaded with parametrized example filename
4744
"""
48-
if solver in ('gurobi', 'minizinc') and any(x in example for x in ["npuzzle.py", "tst_likevrp.py", 'sudoku_', 'pareto_optimal.py', 'prob009_perfect_squares.py', 'blocks_world.py', 'flexible_jobshop.py']):
45+
if solver in ('gurobi', 'minizinc') and any(x in example for x in
46+
["npuzzle.py", "tst_likevrp.py", 'sudoku_', 'pareto_optimal.py',
47+
'prob009_perfect_squares.py', 'blocks_world.py',
48+
'flexible_jobshop.py']):
4949
return pytest.skip(reason=f"exclude {example} for {solver}, too slow or solver-specific")
5050

5151
base_solvers = SolverLookup.base_solvers
@@ -87,4 +87,4 @@ def test_advanced_example(example):
8787
if "CPM_exact".lower() in str(e).lower():
8888
pytest.skip(reason=f"Skipped, example uses Exact but is not installed, raised: {e}")
8989
else:
90-
raise e
90+
raise e

0 commit comments

Comments
 (0)