def test_library_io(get_library): get_library.pickle_library('file_01.pickle') loaded_library = load_DiffractionLibrary('file_01.pickle', safety=True) os.remove('file_01.pickle') # We can't check that the entire libraries are the same as the memory # location of the 'Sim' changes for i in range(len(get_library['Phase']['orientations'])): np.testing.assert_allclose(get_library['Phase']['orientations'][i], loaded_library['Phase']['orientations'][i]) np.testing.assert_allclose(get_library['Phase']['intensities'][i], loaded_library['Phase']['intensities'][i]) np.testing.assert_allclose(get_library['Phase']['pixel_coords'][i], loaded_library['Phase']['pixel_coords'][i])
def test_library_io(get_library): get_library.pickle_library("file_01.pickle") loaded_library = load_DiffractionLibrary("file_01.pickle", safety=True) os.remove("file_01.pickle") # We can't check that the entire libraries are the same as the memory # location of the 'Sim' changes for i in range(len(get_library["Phase"]["orientations"])): np.testing.assert_allclose( get_library["Phase"]["orientations"][i], loaded_library["Phase"]["orientations"][i], ) np.testing.assert_allclose( get_library["Phase"]["intensities"][i], loaded_library["Phase"]["intensities"][i], ) np.testing.assert_allclose( get_library["Phase"]["pixel_coords"][i], loaded_library["Phase"]["pixel_coords"][i], )
def test_unsafe_loading(get_library): get_library.pickle_library('file_01.pickle') loaded_library = load_DiffractionLibrary('file_01.pickle')