def saved_random_dataset(): n_features = 5 n_samples = 10 features = np.random.rand(n_samples, n_features) labels = np.random.rand(n_samples) path_to_save = 'test_pickle_save.pkl' dataset = Dataset(features, labels) dataset.save_to_pickle(path_to_save) return path_to_save, dataset
def test_save_and_load_to_pickle_identical_file_multiple_labels(): n_features = 5 n_samples = 10 n_labels = 3 features = np.random.rand(n_samples, n_features) labels = np.random.rand(n_samples, n_labels) path_to_save = 'test_pickle_save.pkl' dataset = Dataset(features, labels) dataset.save_to_pickle(path_to_save) loaded_dataset = Dataset() loaded_dataset.load_from_pickle(path_to_save, range(n_features), range(n_features, n_features + n_labels)) assert np.array_equal(loaded_dataset.features, dataset.features) assert np.array_equal(loaded_dataset.labels, dataset.labels)