def test05b(self):
     """Try just saving values with fixed filter"""
     model = self.setup_model02()
     model.x[1].fix(1)
     wts = StoreSpec.value(only_not_fixed=True)
     to_json(model, fname=self.fname, human_read=True, wts=wts)
     model.g.deactivate()
     model.x[1].setlb(-4)
     model.x[1].value = 3
     model.x[2].value = 6
     from_json(model, fname=self.fname, wts=wts)
     assert value(model.x[1]) == 3  # should not load since is fixed
     assert model.x[1].lb == -4
     assert value(model.x[2]) == pytest.approx(2.5)
     assert not model.g.active
Exemple #2
0
 def test05(self):
     """Try just saving values"""
     model = self.setup_model02()
     model.x[1].value = 1
     wts = StoreSpec.value()
     to_json(model, fname=self.fname, human_read=True, wts=wts)
     model.g.deactivate()
     model.x[1].setlb(-4)
     model.x[1].value = 3
     model.x[2].value = 6
     from_json(model, fname=self.fname, wts=wts)
     assert (abs(value(model.x[1]) - 1) < 1e-5)
     assert (abs(model.x[1].lb + 4) < 1e-5)
     assert (abs(value(model.x[2]) - 2.5) < 1e-5)
     assert (not model.g.active)
 def test05(self):
     """Try just saving values"""
     model = self.setup_model02()
     model.x[1].value = 1
     wts = StoreSpec.value()
     to_json(model, fname=self.fname, human_read=True, wts=wts)
     model.g.deactivate()
     model.x[1].setlb(-4)
     model.x[1].value = 3
     model.x[2].value = 6
     from_json(model, fname=self.fname, wts=wts)
     assert value(model.x[1]) == 1
     assert model.x[1].lb == -4
     assert value(model.x[2]) == pytest.approx(2.5)
     assert not model.g.active