def test_export_model_to_hdf5(file_stimuli, tmpdir): model = pysaliency.UniformModel() filename = str(tmpdir.join('model.hdf5')) export_model_to_hdf5(model, file_stimuli, filename) model2 = pysaliency.HDF5Model(file_stimuli, filename) for s in file_stimuli: np.testing.assert_allclose(model.log_density(s), model2.log_density(s))
def test_export_model_overwrite(file_stimuli, tmpdir): model1 = pysaliency.GaussianSaliencyMapModel(width=0.1) model2 = pysaliency.GaussianSaliencyMapModel(width=0.8) filename = str(tmpdir.join('model.hdf5')) partial_stimuli = pysaliency.FileStimuli( filenames=file_stimuli.filenames[:5]) export_model_to_hdf5(model1, partial_stimuli, filename) export_model_to_hdf5(model2, file_stimuli, filename) model3 = pysaliency.HDF5SaliencyMapModel(file_stimuli, filename) for s in file_stimuli: np.testing.assert_allclose(model2.saliency_map(s), model3.saliency_map(s))