def test_remote_file(): """ Ensures that opening a local file works. """ host = "129.16.35.202" path = "/mnt/array1/share/MLDatasets/test/data_0.npz" with read_file("sftp://" + host + path, "rb") as file: data = np.load(file) assert np.all(np.isclose(data["x"], 0.0))
def test_local_file(tmp_path): """ Ensures that opening a local file works. """ with open(tmp_path / "test.txt", "w") as file: file.write("test") with read_file(tmp_path / "test.txt") as file: content = file.read() assert content == "test"
def load(filename): """ Load normalizer from file. Args: filename: The path to the file containing the normalizer. Returns: The loaded Normalizer object """ with read_file(filename, "rb") as file: return pickle.load(file)