Add test for deserialize backwards compatibility

This commit is contained in:
Ben Letham 2020-08-18 12:34:47 -07:00
parent 40c5b84784
commit 0d0f508cf1
2 changed files with 20 additions and 0 deletions

File diff suppressed because one or more lines are too long

View file

@ -137,3 +137,22 @@ class TestSerialize(TestCase):
fcst2 = m2.predict(test)
self.assertTrue(np.array_equal(fcst['yhat'].values, fcst2['yhat'].values))
def test_backwards_compatibility(self):
old_versions = {
'0.6.1.dev0': 29.3669923968994,
}
for v, pred_val in old_versions.items():
fname = os.path.join(
os.path.dirname(__file__),
'serialized_model_v{}.json'.format(v)
)
with open(fname, 'r') as fin:
model_str = json.load(fin)
# Check that deserializes
m = model_from_json(model_str)
self.assertEqual(json.loads(model_str)['__fbprophet_version'], v)
# Predict
future = m.make_future_dataframe(10)
fcst = m.predict(future)
self.assertAlmostEqual(fcst['yhat'].values[-1], pred_val)