Beispiel #1
0
def test_stack(shape, axis):
    xx = sparse.random(shape, density=0.5)
    x = xx.todense()
    yy = sparse.random(shape, density=0.5)
    y = yy.todense()
    zz = sparse.random(shape, density=0.5)
    z = zz.todense()

    assert_eq(np.stack([x, y, z], axis=axis),
              sparse.stack([xx, yy, zz], axis=axis))
Beispiel #2
0
def test_large_concat_stack():
    data = np.array([1], dtype=np.uint8)
    coords = np.array([[255]], dtype=np.uint8)

    xs = COO(coords, data, shape=(256, ), has_duplicates=False, sorted=True)
    x = xs.todense()

    assert_eq(np.stack([x, x]), sparse.stack([xs, xs]))

    assert_eq(np.concatenate((x, x)), sparse.concatenate((xs, xs)))
Beispiel #3
0
def test_stack(shape, axis):
    x = random_x(shape)
    xx = COO.from_numpy(x)
    y = random_x(shape)
    yy = COO.from_numpy(y)
    z = random_x(shape)
    zz = COO.from_numpy(z)

    assert_eq(np.stack([x, y, z], axis=axis),
              sparse.stack([xx, yy, zz], axis=axis))
        print("curv: ", curv)
        if curv == 'both':
            edge_feat_list = [ollivier_curv_vals, forman_curv_vals]
        elif curv == 'ollivier':
            edge_feat_list = [ollivier_curv_vals]
        else:
            edge_feat_list = [forman_curv_vals]
        ########################################### END ###########################################
        vals = []
        for mat in edge_feat_list:
            vals.append((mat + mat.transpose() + EYE > 0).astype(np.float32))
            if args.encode_edge_direction:
                vals.append((mat + EYE > 0).astype(np.float32))
                vals.append((mat.transpose() + EYE > 0).astype(np.float32))
        vals = [sparse.as_coo(x) for x in vals]
        vals = sparse.stack(vals, axis=0)
        vals = vals.todense()

        vals = aml_graph.normalize_adj(vals,
                                       args.edge_norm,
                                       assume_symmetric_input=False)
        temp_vals = vals
        vals = [vals]

        ret = np.concatenate(vals, 1)

        edges = np.transpose(ret, [1, 2, 0])

        #edges = edges.todense()

        # ************************************************************