From f4756e36c57f8c2269730a0158a896e7c90b3e6b Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Sun, 9 Sep 2018 22:11:37 +0200 Subject: [PATCH] fix a few lint warnings --- examples/python/vendor_scheduling_sat.py | 6 +++++- examples/python/wedding_optimal_chart_sat.py | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/python/vendor_scheduling_sat.py b/examples/python/vendor_scheduling_sat.py index 0dafbfe82c..3117b347b1 100644 --- a/examples/python/vendor_scheduling_sat.py +++ b/examples/python/vendor_scheduling_sat.py @@ -10,6 +10,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Solves a simple shift scheduling problem.""" from __future__ import absolute_import from __future__ import division @@ -33,8 +34,9 @@ class SolutionPrinter(cp_model.CpSolverSolutionCallback): self.__min_vendors = min_vendors def OnSolutionCallback(self): + """Called at each new solution.""" self.__solution_count += 1 - print ('Solution %i: ', self.__solution_count) + print('Solution %i: ', self.__solution_count) print(' min vendors:', self.__min_vendors) for i in range(self.__num_vendors): print(' - vendor %i: ' % i, @@ -48,10 +50,12 @@ class SolutionPrinter(cp_model.CpSolverSolutionCallback): print() def SolutionCount(self): + """Returns the number of solution found.""" return self.__solution_count def main(): + """Create the shift scheduling model and solve it.""" # Create the model. model = cp_model.CpModel() diff --git a/examples/python/wedding_optimal_chart_sat.py b/examples/python/wedding_optimal_chart_sat.py index 3eade77651..3362558567 100644 --- a/examples/python/wedding_optimal_chart_sat.py +++ b/examples/python/wedding_optimal_chart_sat.py @@ -12,10 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -from __future__ import print_function -from ortools.sat.python import cp_model -import time """Finding an optimal wedding seating chart. From @@ -40,6 +36,10 @@ Adapted from https://github.com/google/or-tools/blob/master/examples/csharp/wedding_optimal_chart.cs """ +from __future__ import print_function +import time +from ortools.sat.python import cp_model + class WeddingChartPrinter(cp_model.CpSolverSolutionCallback): """Print intermediate solutions.""" @@ -196,7 +196,7 @@ def SolveWithDiscreteModel(): ### Solve model. solver = cp_model.CpSolver() solution_printer = WeddingChartPrinter(seats, names, num_tables, num_guests) - status = solver.SolveWithSolutionCallback(model, solution_printer) + solver.SolveWithSolutionCallback(model, solution_printer) print("Statistics") print(" - conflicts : %i" % solver.NumConflicts())