Skip to content

Commit

Permalink
Minor bug fixed for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lecoutre committed Oct 8, 2020
1 parent 5dcad7b commit d2d7f19
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
11 changes: 5 additions & 6 deletions compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

from pycsp3.dashboard import options
from pycsp3.problems.data import parsing
from pycsp3.solvers.solver import process_options
from pycsp3.tools.aggregator import build_similar_constraints
from pycsp3.tools.compactor import build_compact_forms
from pycsp3.tools.curser import OpOverrider, convert_to_namedtuples, is_namedtuple
from pycsp3.tools.slider import handle_slides
from pycsp3.tools.utilities import Stopwatch
from pycsp3.tools.utilities import Stopwatch, GREEN, WHITE
from pycsp3.tools.xcsp import build_document
from pycsp3.solvers.solver import process_options

None_Values = ['None', '', 'null'] # adding 'none'?

Expand Down Expand Up @@ -47,8 +47,7 @@ def compile():
def _load_options():
options.set_values("data", "dataparser", "dataexport", "dataformat", "variant", "checker", "solver")
options.set_flags("dataexport", "compress", "ev", "display", "time", "noComments", "recognizeSlides", "keepSmartConditions", "restrictTablesWrtDomains",
"solve"
)
"solve")
if options.checker is None:
options.checker = "fast"
assert options.checker in {"complete", "fast", "none"}
Expand Down Expand Up @@ -204,7 +203,7 @@ def prepare_for_json(obj):
else:
with open(filename, "w") as f:
f.write(pretty_text)
print(" Generation of the file " + filename + " completed.\n")
print(" * Generating the file " + filename + " completed in " + GREEN + Compilation.stopwatch.elapsed_time() + WHITE + " seconds.\n")
if options.compress:
with lzma.open(filename + ".lzma", "w") as f:
f.write(bytes(pretty_text, 'utf-8'))
Expand All @@ -221,7 +220,7 @@ def prepare_for_json(obj):
json.dump(prepare_for_json(Compilation.data), f)
print(" Generation for data saving of the file " + json_prefix + '.json' + " completed.")

print(" Total wall clock time:", Compilation.stopwatch.elapsed_time(), "seconds")
# print(" Total wall clock time:", Compilation.stopwatch.elapsed_time(), "seconds")

Compilation.done = True

Expand Down
2 changes: 2 additions & 0 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def VarArray(*, size, dom, comment=None):
name = extract_declaration_for("VarArray")
if comment is None and not isinstance(name, list):
comment, tags = comment_and_tags_of(function_name="VarArray")
else:
tags = []

assert isinstance(comment, (str, type(None))), "A comment must be a string (or None). Usually, they are given on plain lines preceding the declaration"
assert not isinstance(dom, type(lambda: 0)) or len(size) == len(inspect.signature(dom).parameters), \
Expand Down
4 changes: 2 additions & 2 deletions solvers/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pycsp3.classes.entities import VarEntities, EVar
from pycsp3.classes.main.variables import Variable
from pycsp3.dashboard import options
from pycsp3.tools.utilities import Stopwatch, flatten
from pycsp3.tools.utilities import Stopwatch, flatten, GREEN, WHITE

UNKNOWN, SAT, UNSAT, OPTIMUM = "UNKNOWN", "SAT", "UNSAT", "OPTIMUM"

Expand Down Expand Up @@ -203,7 +203,7 @@ def execute(command, verbose):
if not verbose:
self.last_command_wck = stopwatch.elapsed_time()
if out_err and not missing:
print(" * Solved by " + self.name + " in " + self.last_command_wck + " seconds")
print(" * Solved by " + self.name + " in " + GREEN + self.last_command_wck + WHITE + " seconds")
else:
print(" * Solving process stopped by " + self.name + " after " + self.last_command_wck + " seconds")
if missing:
Expand Down
2 changes: 1 addition & 1 deletion tools/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def elapsed_time(self, *, reset=False):
elapsed_time = time() - self.initial_time
if reset:
self.initial_time = time()
return "{:10.2f}".format(elapsed_time)
return "{:8.2f}".format(elapsed_time)


class _Star(float):
Expand Down

0 comments on commit d2d7f19

Please sign in to comment.