Beispiel #1
0
 def test_save_junk_model(self):
     a = 'g'
     with pytest.raises(TypeError) as record:
         save_model(a, 'bad.p', constraints={'bounds': ()})
     assert 'The model has to be an Astropy model or a callable' \
            in str(record.value)
     assert not os.path.exists('bad.p')
Beispiel #2
0
 def test_save_and_load_Astropy_model(self):
     save_model(self.model, 'bubu_model.p')
     b, kind, _ = load_model('bubu_model.p')
     assert kind == 'Astropy'
     assert isinstance(b, Model)
     assert np.all(self.model.parameters == b.parameters)
     assert np.all(self.model.bounds == b.bounds)
     assert np.all(self.model.fixed == b.fixed)
Beispiel #3
0
 def test_save_and_load_callable_model(self):
     constraints0 = {'bounds': ()}
     save_model(_dummy, 'bubu_callable.p', constraints=constraints0)
     b, kind, constraints = load_model('bubu_callable.p')
     assert kind == 'callable'
     assert callable(b)
     assert np.all(_dummy.__code__.co_argcount == b.__code__.co_argcount)
     assert np.all(_dummy.__defaults__ == b.__defaults__)
     assert np.all(constraints == constraints0)
Beispiel #4
0
 def test_save_callable_model_wrong(self):
     with pytest.raises(TypeError) as record:
         save_model(_dummy_bad, 'callable_bad.p')
     assert 'Accepted callable models have only' in str(record.value)
     assert not os.path.exists('callable_bad.p')