def test_dump(im_i, tmp_pathplus): im_i.dump(tmp_pathplus / "im_i_dump.dat") # Errors for obj in [*test_sequences, test_dict, *test_numbers]: with pytest.raises(TypeError): im_i.dump(obj) # Read and check values assert (tmp_pathplus / "im_i_dump.dat").exists() loaded_im_i = _pickle_load_path(tmp_pathplus / "im_i_dump.dat") assert loaded_im_i == im_i assert len(loaded_im_i) == len(im_i)
def test_dump(data, tmp_pathplus): data.dump(tmp_pathplus / "JCAMP_dump.dat") # Errors for obj in [*test_sequences, test_dict, *test_numbers]: with pytest.raises(TypeError): data.dump(obj) # Read and check values assert (tmp_pathplus / "JCAMP_dump.dat").exists() loaded_data = _pickle_load_path(tmp_pathplus / "JCAMP_dump.dat") assert loaded_data == data assert len(loaded_data) == len(data)
def test_dump(peak, tmp_pathplus): peak.dump(tmp_pathplus / "Peak_dump.dat") # Errors for obj in [ test_list_strs, test_dict, test_list_ints, test_tuple, *test_numbers ]: with pytest.raises(TypeError): peak.dump(obj) # Read and check values assert (tmp_pathplus / "Peak_dump.dat").exists() loaded_peak = _pickle_load_path(tmp_pathplus / "Peak_dump.dat") assert loaded_peak == peak
def load_expr(file_name: PathLike) -> Experiment: """ Loads an experiment saved with :meth:`pyms.Experiment.Experiment.dump`. :param file_name: Experiment file name. :return: The loaded experiment. :author: Vladimir Likic, Andrew Isaac, Dominic Davis-Foster (type assertions and pathlib support) """ if not is_path(file_name): raise TypeError("'file_name' must be a string or a PathLike object") file_name = prepare_filepath(file_name, mkdirs=False) expr = _pickle_load_path(file_name) if not isinstance(expr, Experiment): raise TypeError("The loaded file is not an experiment file") return expr