igraph / python-igraph

Python interface for igraph
GNU General Public License v2.0
1.31k stars 249 forks source link

TypeError when passing niter into personalized_pagerank() #568

Closed btrantruong closed 2 years ago

btrantruong commented 2 years ago

Describe the bug passing argument for 'niter' causes an error for personalized_pagerank()

Below is the error: TypeError: 'niter' is an invalid keyword argument for this function

However, niter is a legal parameter when I check the parameter names:

import inspect
inspect.getfullargspec(ig.Graph.personalized_pagerank)
FullArgSpec(args=['vertices', 'directed', 'damping', 'reset', 'reset_vertices', 'weights', 'arpack_options', 'implementation', 'niter', 'eps'], varargs=None, varkw=None, defaults=(None, True, 0.85, None, None, None, None, 'prpack', 1000, 0.001), kwonlyargs=[], kwonlydefaults=None, annotations={})

To reproduce

graph = ig.Graph.Read_Ncol(edgelistfile, weights = True, directed=True) # edgelistfile is space-separated with a weight column
personalization = [1/500 if v.index%2==0 else 0 for v in graph.vs]
graph.personalized_pagerank(vertices=None, directed=True, damping=0.85, reset=personalization, weights='weight', niter=100, eps=0.0001)

Version information python=3.8.13 igraph=0.10.1 igraph installed using pip3 install python-igraph

ntamas commented 2 years ago

niter and eps are not valid parameters any more, and in fact earlier versions ignored these arguments unless you used implementation="power", which was based on a naive power iteration and it was deprecated a long time ago. igraph 0.10.0 removed lots of deprecated stuff so this method is not available any more. I will fix the documentation so these arguments do not appear there. The solution is simply to remove niter andeps from the function call; if you don't specify a method, igraph will use PRPACK behind the scenes, which is smart enough to know when to stop.

(Also, I know there are issues with the API docs of the homepage from version 0.10.0, I'm also working on that).