-
Notifications
You must be signed in to change notification settings - Fork 238
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
Add visualization of Stiefel Manifold #1807
base: main
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report
@@ Coverage Diff @@
## master #1807 +/- ##
==========================================
+ Coverage 80.29% 87.11% +6.82%
==========================================
Files 121 125 +4
Lines 12830 12809 -21
==========================================
+ Hits 10301 11157 +856
+ Misses 2529 1652 -877
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Rename the ipynb to stiefel.ipynb
@@ -0,0 +1,450 @@ | |||
"""Stiefel manifold module.""" |
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.
Rename file to stiefel.py
from geomstats.visualization import Sphere | ||
|
||
# %% | ||
""" |
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.
Put this in the docstring of the class StiefelSphere
from geomstats.geometry.hypersphere import Hypersphere | ||
from geomstats.visualization import Sphere | ||
|
||
# %% |
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.
Remove this unnecessary comment
@@ -0,0 +1,149 @@ | |||
"""Stiefel manifold visualization test module.""" |
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.
rename this file: test_visualization_stiefel.py
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.
Thanks, looking great!
Please submit a review of this PR with the following changes:
- Instead of copy-pasting code from the visualization of Kendall shape spaces, you should import that code and have your methods call their methods. You will be, in effect, wrapping that code into a new object, which is cleaner.
- Address DeepSource issues.
- See my comment regarding the line that you can add to avoid getting the errors in pytorch.
- Try adding a section "Setup" to your notebook, as in this example, so that the import error goes away.
|
||
# %% | ||
""" | ||
Consider <n=3, p=1> Stiefel Manifold. |
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.
Should this be n=3, p=2? A pair of two orthonormal vectors in 3D? Double check
|
||
class StiefelSphere: | ||
""" | ||
Class used to plot something in Stiefel shape space of 2D triangles. |
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.
Add reference showing that the stiefel space St(2, 3) is indeed the shape space of triangles.
Look at other code in geomstats repo to see how to properly add a reference in a docstring
|
||
References | ||
---------- | ||
Absil, Pierre-Antoine. "Stiefel Manifolds and their Applications." (2009) |
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.
Format this reference, using examples from other docstring in geomstats' code.
Otherwise, this will not render properly on the documentation website of geomstats, geomstats.ai
|
||
class StiefelSphere: | ||
""" | ||
Class used to plot something in Stiefel shape space of 2D triangles. |
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.
The one liner of the docstring should come direclty after """
|
||
Attributes | ||
---------- | ||
ax : NoneType |
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.
No indent before ax
matplotlib.use("Agg") # NOQA | ||
|
||
|
||
class TestStiefelManifold(tests.conftest.TestCase): |
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 should be TestStiefelSphere or TestStiefelCircle
--> one test class per class being tested, and the classs names should 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.
Then, the names of the test methods do not need to be prefixed by "test_stiefel_circle" or "test_stiefel_sphere" because they are already in a class named TestStiefelCircle
or TestStiefelSphere
self.v21 = Stiefel(2, 1) | ||
self.v22 = Stiefel(2, 2) | ||
self.v31 = Stiefel(3, 1) | ||
self.St_sph = StiefelSphere() |
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.
no uppercase letters in python, unless the variable is a Class, which it is not here (it is an object)
self.St_cir.add_points(group1_points_to_circle[:, :, 0]) | ||
self.St_cir.draw_curve(color="b", lw=3, label="geodesic line") | ||
|
||
def test_stifel_circle_draw_tangent_space(self): |
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.
NIT: stiefel not stifel
self.St_sph.clear_points() | ||
self.St_sph.draw_points(self.sph_ax) | ||
|
||
def test_stiefel_sphere_draw_mesh(self): |
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.
Put this line above the test functions that fail in pytorch:
@geomstats.tests.np_only
after importing geomstats.tests
at the top of the file.
The github actions errors will go away
def test_stiefel_circle_plot_rendering(self): | ||
"""Test drawing the manifold with regularly sampled data.""" | ||
self.St_cir.plot_rendering(self.v21, 100) | ||
# self.St_cir.plot_rendering(self.v22, 100) |
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.
Rm leftover comment
View / edit / reply to this conversation on ReviewNB ninamiolane commented on 2023-02-13T17:17:55Z Rename this notebook to |
View / edit / reply to this conversation on ReviewNB ninamiolane commented on 2023-02-13T17:17:56Z Change "In this presentation" to "Here," Change "This rest of the presentation is" to "This notebook is" |
View / edit / reply to this conversation on ReviewNB ninamiolane commented on 2023-02-13T17:17:57Z Line #2. # begin Remove the comments here (they are unnecessary) |
View / edit / reply to this conversation on ReviewNB ninamiolane commented on 2023-02-13T17:17:58Z Line #1. ########################################################################### Remove unnecessary comments in the code, and put a markdown block with clean text instead. |
View / edit / reply to this conversation on ReviewNB ninamiolane commented on 2023-02-13T17:17:59Z Ditto: remove comments and put a well-written text in a markdown cell instead |
View / edit / reply to this conversation on ReviewNB ninamiolane commented on 2023-02-13T17:18:00Z Ditto re comments and text |
View / edit / reply to this conversation on ReviewNB ninamiolane commented on 2023-02-13T17:18:00Z NIT: implemented |
Checklist
Description
Add visualization of Stiefel Manifold and corresponding unit test code
Issue
Additional context