scikit-tda / persim

Distances and representations of persistence diagrams
https://persim.scikit-tda.org
MIT License
125 stars 55 forks source link

Is persim.plot still available? #33

Closed tmelorc closed 4 years ago

tmelorc commented 4 years ago

I'm using Python 3.8 and I have these:

$ pip3.8 list -u
Package         Version
--------------- -------
cycler          0.10.0 
Cython          0.29.14
hopcroftkarp    1.2.5  
Jinja2          2.11.1 
joblib          0.14.1 
kiwisolver      1.1.0  
kmapper         1.2.0  
llvmlite        0.31.0 
MarkupSafe      1.1.1  
matplotlib      3.1.3  
numba           0.48.0 
numpy           1.18.1 
persim          0.1.2  
Pillow          7.0.0  
pip             20.0.2 
pyparsing       2.4.6  
python-dateutil 2.8.1  
ripser          0.4.1  
scikit-learn    0.22.1 
scikit-tda      0.0.3  
scipy           1.4.1  
six             1.14.0 
tadasets        0.0.4  
umap-learn      0.3.10 

The code below from http://persim.scikit-tda.org/notebooks/distances.html

import numpy as np
import persim
import persim.plot
import tadasets
import ripser
import matplotlib.pyplot as plt

gives the error

ModuleNotFoundError: No module named 'persim.plot'

Removing the import persim.plot the error

AttributeError: module 'ripser' has no attribute 'plot_dgms' 

appears when calling ripser.plot_dgms().

Any idea how to solve it? Maybe documentation is outdated?

Code

import numpy as np
import persim
#import persim.plot
import tadasets
import ripser
import matplotlib.pyplot as plt

data_clean = tadasets.dsphere(d=1, n=100, noise=0.0)
data_noisy = tadasets.dsphere(d=1, n=100, noise=0.1)

plt.scatter(data_clean[:,0], data_clean[:,1], label="clean data")
plt.scatter(data_noisy[:,0], data_noisy[:,1], label="noisy data")
plt.axis('equal')
plt.legend()
plt.show()

dgm_clean = ripser.ripser(data_clean)['dgms'][1]
dgm_noisy = ripser.ripser(data_noisy)['dgms'][1]

ripser.plot_dgms([dgm_clean, dgm_noisy] , labels=['Clean $H_1$', 'Noisy $H_1$'])
tmelorc commented 4 years ago

Just to inform, it works if remove import persim.plot and replace ripser.plot_dgms by persim.plot_diagrams.

It would be good to update documentation.

sauln commented 4 years ago

Thanks for catching this, it would be really helpful if you could submit a PR with the doc changes!

tmelorc commented 4 years ago

Thanks for catching this, it would be really helpful if you could submit a PR with the doc changes!

I'm not sure if I can use Git but I'll do my best to collaborate. Thanks.

tmelorc commented 4 years ago

So, I'm trying to do a PR. I'm not sure if it will work. Please, when you can, check if it works.

sauln commented 4 years ago

Yes, it worked as is merged #34. Thank you!

FaisalAhmed77 commented 2 years ago

I got error in line 15. What is wrong there ? Thanks

---> 15 persim.landscapes.plot_diagrams(dgms_H1, title="Persistence Diagram of H1", ax=axs[0]) 16 17 persim.landscapes.plot_diagrams(dgms_DR1, title="Persistence Diagram of D1", ax=axs[1])

AttributeError: module 'persim' has no attribute 'landscapes'

ganeshlandge commented 2 years ago

I got error in line 15. What is wrong there ? Thanks

---> 15 persim.landscapes.plot_diagrams(dgms_H1, title="Persistence Diagram of H1", ax=axs[0]) 16 17 persim.landscapes.plot_diagrams(dgms_DR1, title="Persistence Diagram of D1", ax=axs[1])

AttributeError: module 'persim' has no attribute 'landscapes'

I am also getting same error, @FaisalAhmed77 did you get solution for this error?

jaygam111 commented 2 years ago

When I run the Example Plots for Torus vs Sphere code, got an error.

AttributeError: module 'persim' has no attribute 'landscapes'

Any idea how to solve this?