def test_hash_numpy(): A = np.arange(10, dtype=np.float32) dig0 = hash_one(A) A += 1 dig1 = hash_one(A) assert dig0 != dig1 A = np.zeros((20,20), np.float32) A[2,::2] = np.arange(10) dig2 = hash_one(A[2,::2]) assert dig0 == dig2 dig3 = hash_one(A[2,::2].astype(np.float64)) assert dig3 != dig0
def test_util_timed_path(): from jug.hash import hash_one jug.task.Task.store = dict_store() system("touch test_file") t0 = jug.utils.timed_path('test_file') t1 = jug.utils.timed_path('test_file') h0 = hash_one(t0) h1 = hash_one(t1) assert h0 == h1 sleep(1.1) system("touch test_file") h1 = hash_one(t1) assert h0 != h1 assert value(t0) == 'test_file' assert value(t1) == 'test_file'
def test_dict_mixed(): value = { frozenset([1,2,3]) : 4, 'hello': 2 } v = hash_one(value) assert len(v)
def test_util_timed_path(tmpdir): from jug.hash import hash_one jug.task.Task.store = dict_store() tmpdir = str(tmpdir) test_file = path.join(tmpdir, 'test_file') with open(test_file, 'wt') as out: out.write("Hello World") t0 = jug.utils.timed_path(test_file) t1 = jug.utils.timed_path(test_file) h0 = hash_one(t0) h1 = hash_one(t1) assert h0 == h1 sleep(1.1) with open(test_file, 'wt') as out: out.write("Hello World") h1 = hash_one(t1) assert h0 != h1 assert value(t0) == test_file assert value(t1) == test_file
def __jug_hash__(self): from jug.hash import hash_one return hash_one(self.experiment_name)
def __jug_hash__(self): from jug.hash import hash_one return hash_one({'type': 'Dataset', 'data': self.name})
def test_hash_numpy_copy(): X = np.arange(10) assert hash_one(X[::-1]) != hash_one(X) assert hash_one(X.copy()) == hash_one(X)
def test_hash_set(): assert hash_one(set([1, 2, 3])) != hash_one([1, 2, 3])
def test_hash_set(): assert hash_one(set([1,2,3])) != hash_one([1,2,3])
def test_hash_numpy_copy(): X = np.arange(10) assert hash_one(X[::-1]) != hash_one(X) assert hash_one(X.copy()) == hash_one(X) assert hash_one(X[::-1].copy()) == hash_one(X[::-1])