epfl-lts2 / pygsp

Graph Signal Processing in Python
https://pygsp.rtfd.io
BSD 3-Clause "New" or "Revised" License
483 stars 93 forks source link

Error when running the sample code in the README file #83

Closed aweinstein closed 4 years ago

aweinstein commented 4 years ago

This sample code in the Readme file

>>> from pygsp import graphs, filters
>>> G = graphs.Logo()
>>> G.compute_fourier_basis()  # Fourier to plot the eigenvalues.
>>> # G.estimate_lmax() is otherwise sufficient.
>>> g = filters.Heat(G, scale=50)
>>> fig, ax = g.plot()

throws the error line 79, in __init__ super(Heat, self).__init__(G, g, **kwargs) TypeError: __init__() got an unexpected keyword argument 'scale'.

The problem seems to be that filters. Heat doesn't have a scale parameter.

In a related note, I noticed that the content in Read the Docs page is not the same as the Readme file (perhaps that's how it should be, I'm not really familiar in how "Read the Docs" is built). In particular, in the read the docs, the example calls the filter function as g = filters.Heat(G, tau=100), which uses the correct parameter.

I'm running PyGSP 0.5.1 (installed using conda).

mdeff commented 4 years ago

That's because you're seeing the README from the master branch (which contains development code for the next release), while Read the Docs points by default to the doc for version 0.5.1 as published on PyPI and conda-forge. (The content is indeed the same for the same version. You can check that by looking at the repo at tag 0.5.1.)

As you correctly inferred, the parameter tau was renamed to a more explicit scale for the next version.

You have two options:

  1. Use the released version (installed by pip install pygsp and conda install pygsp) and follow the released doc. (The code you'll get is tag 0.5.1.)
  2. Use the dev version (installed with pip install git+https://github.com/epfl-lts2/pygsp) and follow the dev doc. The dev version obviously moves much faster, and code might break if the API changes (e.g., the tau to scale for Heat).
aweinstein commented 4 years ago

Thanks for the answer!