Пример #1
0
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
Пример #2
0
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
Пример #3
0
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'
Пример #4
0
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'
Пример #5
0
def test_dict_mixed():
    value = {
            frozenset([1,2,3]) : 4,
            'hello': 2
    }
    v = hash_one(value)
    assert len(v)
Пример #6
0
def test_dict_mixed():
    value = {
            frozenset([1,2,3]) : 4,
            'hello': 2
    }
    v = hash_one(value)
    assert len(v)
Пример #7
0
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
Пример #8
0
 def __jug_hash__(self):
     from jug.hash import hash_one
     return hash_one(self.experiment_name)
Пример #9
0
 def __jug_hash__(self):
     from jug.hash import hash_one
     return hash_one({'type': 'Dataset', 'data': self.name})
Пример #10
0
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)
Пример #11
0
def test_hash_set():
    assert hash_one(set([1, 2, 3])) != hash_one([1, 2, 3])
Пример #12
0
def test_hash_set():
    assert hash_one(set([1,2,3])) != hash_one([1,2,3])
Пример #13
0
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])