New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make HITS raise exceptions consistent with power iterations #7084
Conversation
Specifically, instead of raising `ValueError` or `sp.sparse.linalg.ArpackNoConvergence`, change `nx.hits` to raise `nx.PowerIterationFailedConvergence` just like other algorithms that have power iterations. This makes it easier for backends to raise consistent exceptions (`ArpackNoConvergence` is particularly awkward to match).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Thanks!
This is an API change. Should we do the deprecation workflow? |
No opinion from me, but I think you're right it is technically an API change. What's the networkx deprecation mechanism for this? Raise a warning and/or put a notice in the docstring that the exceptions will change? |
I'm inclined to see if we can get away without one. AFAICT this will only burn folks that are explicitly catching |
if max_iter <= 0: | ||
raise nx.PowerIterationFailedConvergence(max_iter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit, but I think a ValueError
may be better here. "Practicality over Purity" though, so if this is a huge pain for backends then not a blocker!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PowerIterationFailedConvergence
was chosen here to match pagerank
, eigenvector_centrality
, and katz_centrality
. I agree ValueError
can make sense (esp. for max_iter < 0
), but I would want to update the other algorithms too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for consistency then, thanks!
…#7084) Specifically, instead of raising `ValueError` or `sp.sparse.linalg.ArpackNoConvergence`, change `nx.hits` to raise `nx.PowerIterationFailedConvergence` just like other algorithms that have power iterations. This makes it easier for backends to raise consistent exceptions (`ArpackNoConvergence` is particularly awkward to match).
Specifically, instead of raising
ValueError
orsp.sparse.linalg.ArpackNoConvergence
, changenx.hits
to raisenx.PowerIterationFailedConvergence
just like other algorithms that have power iterations. This makes it easier for backends to raise consistent exceptions (ArpackNoConvergence
is particularly awkward to match).