示例#1
0
def test_load_and_save_H():
    print "\n-- 'load_H', 'save_H'"
    H, _, _ = load_H(join(data_directory, 'Torus_H.csv'), zeroindexing=False)
    print "Loaded H: \n", H
    print "Shape: ", H.shape

    filename2 = 'Torus_H2.csv'
    print "Saving and loading can lead to different precision"
    save_H(join(data_directory, filename2), H)
    H, _, _ = load_H(join(data_directory, filename2))
    print H
    print "Shape: ", H.shape
    save_H(join(data_directory, 'Torus_H3.csv'), H)

    print "\nLoading always leads to float"
    H = np.array([[1, 2, 3], [4, 5, 6]])  # change 6 to 6.5
    print "Original H:\n", H
    print "Shape: ", H.shape
    filename3 = 'test_load_and_save_H.csv'
    save_H(join(data_directory, filename3), H, delimiter=' ')
    H, _, _ = load_H(join(data_directory, filename3), delimiter=None)
    print "Loaded H:\n", H
    print "Shape: ", H.shape
示例#2
0
def test_load_and_save_H():
    print "\n-- 'load_H', 'save_H'"
    H, _, _ = load_H(join(data_directory, 'Torus_H.csv'), zeroindexing=False)
    print "Loaded H: \n", H
    print "Shape: ", H.shape

    filename2 = 'Torus_H2.csv'
    print "Saving and loading can lead to different precision"
    save_H(join(data_directory, filename2), H)
    H, _, _ = load_H(join(data_directory, filename2))
    print H
    print "Shape: ", H.shape
    save_H(join(data_directory, 'Torus_H3.csv'), H)

    print "\nLoading always leads to float"
    H = np.array([[1, 2, 3],
                  [4, 5, 6]])        # change 6 to 6.5
    print "Original H:\n", H
    print "Shape: ", H.shape
    filename3 = 'test_load_and_save_H.csv'
    save_H(join(data_directory, filename3), H, delimiter=' ')
    H, _, _ = load_H(join(data_directory, filename3), delimiter=None)
    print "Loaded H:\n", H
    print "Shape: ", H.shape
示例#3
0
def test_eps_convergence_linbp_Torus():
    print "\n-- 'eps_convergence_linbp' for Torus ---"
    W, n = load_W(join(data_directory, 'Torus_W.csv'), zeroindexing=False)
    print 'W dense:\n', W.todense()
    print 'W:\n', W
    Hc, k, _ = load_H(join(data_directory, 'Torus_H.csv'), zeroindexing=False)
    print "H\n", Hc
    print

    # Simple spectral = 0.658
    start = time.time()
    eps = eps_convergence_linbp(Hc, W)
    end = time.time()-start
    print "Eps:", eps
    print "Time needed:", end

    # Echo spectral = 0.488
    start = time.time()
    eps = eps_convergence_linbp(Hc, W, echo=True)
    end = time.time()-start
    print "Eps:", eps
    print "Time needed:", end
示例#4
0
def test_eps_convergence_linbp_Torus():
    print "\n-- 'eps_convergence_linbp' for Torus ---"
    W, n = load_W(join(data_directory, 'Torus_W.csv'), zeroindexing=False)
    print 'W dense:\n', W.todense()
    print 'W:\n', W
    Hc, k, _ = load_H(join(data_directory, 'Torus_H.csv'), zeroindexing=False)
    print "H\n", Hc
    print

    # Simple spectral = 0.658
    start = time.time()
    eps = eps_convergence_linbp(Hc, W)
    end = time.time() - start
    print "Eps:", eps
    print "Time needed:", end

    # Echo spectral = 0.488
    start = time.time()
    eps = eps_convergence_linbp(Hc, W, echo=True)
    end = time.time() - start
    print "Eps:", eps
    print "Time needed:", end