From baa65a12b7f49b69cbf339cea3d77f84d5b9cb1b Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Tue, 26 Mar 2024 12:33:58 +0100 Subject: [PATCH] reformat --- ortools/linear_solver/python/model_builder.py | 12 ++++-------- .../python/model_builder_helper_test.py | 1 + ortools/linear_solver/python/model_builder_test.py | 7 +++++++ ortools/linear_solver/python/pywraplp_test.py | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ortools/linear_solver/python/model_builder.py b/ortools/linear_solver/python/model_builder.py index 24e78f94a4..715506616c 100644 --- a/ortools/linear_solver/python/model_builder.py +++ b/ortools/linear_solver/python/model_builder.py @@ -883,12 +883,10 @@ class Model: return clone @typing.overload - def _get_linear_constraints(self, constraints: Optional[pd.Index]) -> pd.Index: - ... + def _get_linear_constraints(self, constraints: Optional[pd.Index]) -> pd.Index: ... @typing.overload - def _get_linear_constraints(self, constraints: pd.Series) -> pd.Series: - ... + def _get_linear_constraints(self, constraints: pd.Series) -> pd.Series: ... def _get_linear_constraints( self, constraints: Optional[_IndexOrSeries] = None @@ -898,12 +896,10 @@ class Model: return constraints @typing.overload - def _get_variables(self, variables: Optional[pd.Index]) -> pd.Index: - ... + def _get_variables(self, variables: Optional[pd.Index]) -> pd.Index: ... @typing.overload - def _get_variables(self, variables: pd.Series) -> pd.Series: - ... + def _get_variables(self, variables: pd.Series) -> pd.Series: ... def _get_variables( self, variables: Optional[_IndexOrSeries] = None diff --git a/ortools/linear_solver/python/model_builder_helper_test.py b/ortools/linear_solver/python/model_builder_helper_test.py index ab6ff00ea4..a2b143a392 100644 --- a/ortools/linear_solver/python/model_builder_helper_test.py +++ b/ortools/linear_solver/python/model_builder_helper_test.py @@ -27,6 +27,7 @@ from ortools.linear_solver.python import model_builder_helper class PywrapModelBuilderHelperTest(absltest.TestCase): + def test_export_model_proto_to_mps_string(self): model = model_builder_helper.ModelBuilderHelper() model.set_name("testmodel") diff --git a/ortools/linear_solver/python/model_builder_test.py b/ortools/linear_solver/python/model_builder_test.py index 32d1c2d640..fa070b6cbe 100644 --- a/ortools/linear_solver/python/model_builder_test.py +++ b/ortools/linear_solver/python/model_builder_test.py @@ -421,6 +421,7 @@ ENDATA class InternalHelperTest(absltest.TestCase): + def test_anonymous_variables(self): helper = mb.Model().helper index = helper.add_var() @@ -435,6 +436,7 @@ class InternalHelperTest(absltest.TestCase): class LinearBaseTest(parameterized.TestCase): + def setUp(self): super().setUp() simple_model = mb.Model() @@ -615,6 +617,7 @@ class LinearBaseTest(parameterized.TestCase): class LinearBaseErrorsTest(absltest.TestCase): + def test_unknown_linear_type(self): with self.assertRaisesRegex(TypeError, r"Unrecognized linear expression"): @@ -637,6 +640,7 @@ class LinearBaseErrorsTest(absltest.TestCase): class BoundedLinearBaseTest(parameterized.TestCase): + def setUp(self): super().setUp() simple_model = mb.Model() @@ -730,6 +734,7 @@ class BoundedLinearBaseTest(parameterized.TestCase): class BoundedLinearBaseErrorsTest(absltest.TestCase): + def test_bounded_linear_expression_as_bool(self): with self.assertRaisesRegex(NotImplementedError, "Boolean value"): model = mb.Model() @@ -738,6 +743,7 @@ class BoundedLinearBaseErrorsTest(absltest.TestCase): class ModelBuilderErrorsTest(absltest.TestCase): + def test_new_var_series_errors(self): with self.assertRaisesRegex(TypeError, r"Non-index object"): model = mb.Model() @@ -1566,6 +1572,7 @@ class ModelBuilderObjectiveTest(parameterized.TestCase): class ModelBuilderProtoTest(absltest.TestCase): + def test_export_to_proto(self): expected = linear_solver_pb2.MPModelProto() text_format.Parse( diff --git a/ortools/linear_solver/python/pywraplp_test.py b/ortools/linear_solver/python/pywraplp_test.py index a683d4be0c..e0633e390f 100644 --- a/ortools/linear_solver/python/pywraplp_test.py +++ b/ortools/linear_solver/python/pywraplp_test.py @@ -42,6 +42,7 @@ constraint { class PyWrapLp(unittest.TestCase): + def test_proto(self): input_proto = linear_solver_pb2.MPModelProto() text_format.Merge(TEXT_MODEL, input_proto)