def test_dumps_and_loads_before_fitting(): model1 = pf.LinearRegression(7) model2 = pf.loads(model1.dumps()) assert isinstance(model2, pf.LinearRegression) assert model1 is not model2 post1 = model1.posterior_mean() post2 = model2.posterior_mean() for k in post1: assert isclose(post1[k], post2[k])
def test_dumps_and_loads_after_fitting(): model1 = pf.LinearRegression(7) x, y = get_test_data(1024, 7) model1.fit(x, y, epochs=2) model2 = pf.loads(model1.dumps()) assert isinstance(model2, pf.LinearRegression) assert model1 is not model2 post1 = model1.posterior_mean() post2 = model2.posterior_mean() for k in post1: assert isclose(post1[k], post2[k])