Skip to content

The spartan can't suit the Numpy array #254

@stmatengss

Description

@stmatengss

When i'm defining a matrix like this:

a=np.array([[0,1,1,0],
[1,0,0,1],
[1,0,0,1],
[1,1,0,0]],dtype=float)

Then, defining a function:

def PageRank(mat):
diff_sum=Inf
point_num=mat.shape[0]
pr=sp.ones((point_num,1),float)
pr=pr/point_num
for i in range(n_point):
cal=0
for j in range(n_point):
cal+=mat[j,i]
for j in range(n_point):
mat[j,i]/=cal
for cal_times in range(10):
mat.glom()
print (expr.dot(mat,pr)).glom()
new_pr=(expr.dot(mat,pr))DI+pr(1-DI)
diff=sp.sub(new_pr, pr)
diff_sum=sp.sum(diff)
print diff_sum.glom()
#debug(diff_sum)
pr=new_pr
#debug(pr)
return pr

when I'm doing PageRank(a), the result can't use the function glom() ( #res.glom() is error# )
The errors:
Traceback (most recent call last):
File "/home/stmatengss/workspace/testPy/pageRankMy.py", line 90, in
res=PageRank(buff)
File "/home/stmatengss/workspace/testPy/pageRankMy.py", line 41, in PageRank
print (expr.dot(mat,pr)).glom()
File "/home/stmatengss/spartan/spartan/expr/operator/base.py", line 502, in glom
return glom(self)
File "/home/stmatengss/spartan/spartan/expr/operator/base.py", line 657, in glom
value = evaluate(value)
File "/home/stmatengss/spartan/spartan/expr/operator/base.py", line 685, in evaluate
return node.evaluate()
File "/home/stmatengss/spartan/spartan/expr/operator/base.py", line 299, in evaluate
value = self._evaluate(ctx, deps)
File "/home/stmatengss/spartan/spartan/expr/operator/map.py", line 323, in _evaluate
sparse=(arrays[0].sparse and arrays[1].sparse))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions