This commit is contained in:
Laurent Perron
2024-03-26 12:33:58 +01:00
parent d9b2908bfb
commit baa65a12b7
4 changed files with 13 additions and 8 deletions

View File

@@ -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

View File

@@ -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")

View File

@@ -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(

View File

@@ -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)