def test_file_storage_save(): meta = StorageMeta() storage = BatchStorageFile(meta, directory="test") X = np.array([1, 2, 3]) y = np.array([0, 0, 0]) filename = storage.save(X, y) assert os.path.isfile(filename)
def test_file_storage_load(): meta = StorageMeta() storage = BatchStorageFile(meta, directory="test") X = np.array([1, 2, 3]) y = np.array([0, 0, 0]) storage.save(X, y) X_data, y_data = storage.load(0) assert np.array_equal(X_data, X) assert np.array_equal(y_data, y)
def file_builder_factory(feature_set, look_back, look_forward, batch_size, directory=None, batch_seconds=1, stride=1, validation_split=0, pseudo_stratify=False, stratify_nbatch_groupings=20, n_workers=None, seed=None, normalize=True, custom_transforms=None, session_norm_filter=None, verbose=False): storage_meta = StorageMeta(validation_split=validation_split) storage = BatchStorageFile(storage_meta, directory=directory) translate = Translate(feature_set, look_back, look_forward, batch_seconds, stride, normalize, verbose, custom_transforms, session_norm_filter) return Builder(storage=storage, translate=translate, batch_size=batch_size, pseudo_stratify=pseudo_stratify, stratify_nbatch_groupings=stratify_nbatch_groupings, verbose=verbose, seed=seed, n_workers=n_workers)
def test_file_storage_metadata_val(): meta = StorageMeta(validation_split=1.0) storage = BatchStorageFile(meta, directory="test") X = np.array([1, 2, 3]) y = np.array([0, 0, 0]) storage.save(X, y) storage.save_meta({}) params = storage.load_meta() assert len(params["val_ids"]) == 1 assert params["val_map"][params["val_ids"][0]] == "IDv_0" assert len(params["train_ids"]) == 0
def test_file_storage_directory(): meta = StorageMeta() storage = BatchStorageFile(meta, directory="test") tools.eq_(storage.directory, "test") assert os.path.exists("test"), True
def test_load_empty_file_meta(): BatchStorageFile(StorageMeta(), directory="test").load_meta()