0

I want to convert PageRank MATLAB/Octave implementation to python, but when it comes to:

a=array([[inf]])  
last_v = dot(ones(N,1),a)

there is a TypeError.

Traceback (most recent call last):
File "/home/googcheng/page_rank.py", line 18, in <module>
pagerank(0,0)
File "/home/googcheng/page_rank.py", line 14, in pagerank
last_v = dot(ones(N,1),a)
File "/usr/lib/python2.7/dist-packages/numpy/core/numeric.py", line 1819, in ones
a = empty(shape, dtype, order)
TypeError: data type not understood

some code https://gist.github.com/3722398

David
  • 91
  • 1
  • 10
  • 3
    You need to include the traceback when reporting a python exception; it'll remove the need for us to guess. – Martijn Pieters Sep 14 '12 at 14:51
  • Welcome to StackOverflow! Along with Marijn's advice, you should also produce an immediately reproducible example (we don't know what `N` is and had to figure out that you had to import `numpy`). Furthermore, this question doesn't really have anything to do with pagerank. – David Robinson Sep 14 '12 at 14:58
  • sorry, title is too wide – David Sep 14 '12 at 15:10

1 Answers1

1

The first argument to ones, the shape, should be a tuple. Change ones(N,1) to ones((N,1)).

Warren Weckesser
  • 110,654
  • 19
  • 194
  • 214