Newer
Older
Alex Rubinsteyn
committed
import numpy as np
from mhcflurry.class1_affinity_prediction import Class1NeuralNetwork
Alex Rubinsteyn
committed
def test_predict_after_saving_model_to_disk():
# don't even bother fitting the model, just save its random weights
Alex Rubinsteyn
committed
# and check we get the same predictions back afterward
Alex Rubinsteyn
committed
peptides = ["A" * 9, "C" * 9]
original_predictions = model.predict(peptides)
Alex Rubinsteyn
committed
depickled_model = pickle.loads(pickle.dumps(model))
assert depickled_model.model is not None
Alex Rubinsteyn
committed
depickled_predictions = depickled_model.predict(peptides)
Alex Rubinsteyn
committed
assert np.allclose(original_predictions, depickled_predictions), (
peptides, original_predictions, depickled_predictions)