From e0b0b2f976c61225a178c7715caf2656a1f6741f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 15 Dec 2018 21:32:51 +0100 Subject: moving stuff --- faiss/util.py | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 faiss/util.py (limited to 'faiss/util.py') diff --git a/faiss/util.py b/faiss/util.py deleted file mode 100644 index 97afbc22..00000000 --- a/faiss/util.py +++ /dev/null @@ -1,29 +0,0 @@ -import time -import simplejson as json -import pickle -from os import path -from collections import namedtuple - -# Converts JSON el['key'] to Pythonic object-style el.key -def _json_object_hook(d): - return namedtuple('X', d.keys())(*d.values()) - -# Load a JSON recipe -def load_recipe(path): - with open(path) as fh: - return json.load(fh, object_hook=_json_object_hook) - -# Load a pickle file -def load_pickle(data_dir, pkl_fn): - load_start = time.time() - with open(path.join(str(data_dir), str(pkl_fn)), 'rb') as fh: - raw = fh.read() - data = pickle.loads(raw) - load_end = time.time() - load_time = load_end - load_start - print("Pickle load time: {:.1f}s".format(load_time)) - return data - -def read_json(fn): - with open(fn, 'r') as json_file: - return json.load(json_file) -- cgit v1.2.3-70-g09d2