Skip to content
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

Implement Persistence Landscapes #48

Merged
merged 57 commits into from
Mar 15, 2021
Merged

Conversation

catanzaromj
Copy link
Contributor

This PR adds persistence landscapes with visualization and basic arithmetic methods. We implement two PL classes, one approximate for faster computations and one exact with no approximations. The approximate class is defined on a grid and we tried to use numpy vectorization when possible to make it fast, especially for things like linear combinations. There is a quicker 2D plotting method and a slower 3D variant as well. We also implemented L_p norms and transformer methods for the two classes.

persim/__init__.py Outdated Show resolved Hide resolved
persim/pers_landscape.py Outdated Show resolved Hide resolved
Add two edge cases in plapprox
@sauln
Copy link
Member

sauln commented Feb 7, 2021

Sweet! I’ll get ready to merge and deploy everything this afternoon. Anything in particular you’d like me to call out when I make the Twitter announcement?

@catanzaromj
Copy link
Contributor Author

I think we're all set. I will add tests and work on tweaking the results of the ML notebook within the next month or so with a new PR. And I can't think of anything in particular for the announcement. Thanks for all your help with this!

@sauln
Copy link
Member

sauln commented Feb 7, 2021

ahh actually I would prefer if we went ahead and added the tests before we release the code. Ive found testing often uncovers bugs in the implementation, and once it's out, it's easy to never go back and add the tests.

I'm okay letting this sit here a while till the tests are in place, Thank you!

@catanzaromj
Copy link
Contributor Author

I totally get that. I will try to move it up on my list of things to do, but it will still probably be a couple weeks before everything is done.

@catanzaromj
Copy link
Contributor Author

@sauln I'm getting back to this, but I can't import the package.

>>> import persim                                                                                                      
 Traceback (most recent call last):     
File "<stdin>", line 1, in <module>                                                                                     
File "E:\Miniconda\envs\baseenv\lib\site-packages\persim\__init__.py", line 8, in <module>                                    
from .landscapes import *                                                                                           
ModuleNotFoundError: No module named 'persim.landscapes'                                                                

I hope to have the additional tests added soon and I was hoping you could take care of this in the meantime.

@calderds
Copy link
Contributor

@catanzaromj I got this error too and managed to fix it. I can push my fixes to the calder branch of your fork.

Removed .landscapes import to avoid functions being in two different places (persim.PersLandscapeApprox() and persim.landscapes.PersLandscapeApprox()). Now, default usage would be persim.landscapes.PersLandscapeApprox()
@sauln
Copy link
Member

sauln commented Feb 26, 2021

Shoot, sorry about this! Thanks for taking care of it @calderds

The former approximate p_norm method used vector norm from numpy, giving incorrect results. Refactor exact p_norm and move to auxiliary as _p_norm. Now both exact and approximate p_norm methods call _p_norm
Move `death_vector` into auxiliary, remove `linear_combination` since it is no longer needed, rename `snap_PL` to `snap_pl`
Add tests for the methods of PersLandscapeExact, PersLandscapeApprox, auxiliary functions, and PersistenceLandscaper
@catanzaromj
Copy link
Contributor Author

I finished adding a bunch of tests and found a bug in the p_norm method, so it was definitely worth it. I added tests for pretty much everything except the visualization methods, since I don't really know how to test those. Feel free to add those if you'd like. I also did some minor renaming and refactoring, and updated the import statements on the examples given the new directory structure.

@catanzaromj
Copy link
Contributor Author

@sauln I think we're ready to go. Anything else that needs to be taken care of?

@@ -1,2 +1,3 @@
include *.txt
include *.md
include persim/landscapes/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is surprising. Is this necessary? I thought setuptools will automatically include any *.py files.

Copy link
Member

@sauln sauln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you for putting all this work in 🙇

One last thing before we merge: Could you increment the version to 0.3.0 and add some notes to the RELEASE.txt?

@catanzaromj
Copy link
Contributor Author

@sauln Done. Thanks for all your help with this.

@sauln
Copy link
Member

sauln commented Mar 15, 2021

Rad, let's ship it!

@sauln sauln merged commit fe5af88 into scikit-tda:master Mar 15, 2021
@sauln
Copy link
Member

sauln commented Mar 15, 2021

Thank you @catanzaromj , @gabbyangeloro , and @calderds ! I'm very glad to have an implementation of landscapes in the library finally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants