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

Special linear #1810

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Special linear #1810

wants to merge 3 commits into from

Conversation

rimika-jaiswal
Copy link
Collaborator

Checklist

  • My pull request has a clear and explanatory title.
  • If necessary, my code is vectorized.
  • I added appropriate unit tests.
  • I made sure the code passes all unit tests. (refer to comment below)
  • My PR follows PEP8 guidelines. (refer to comment below)
  • My PR follows geomstats coding style and API.
  • My code is properly documented and I made sure the documentation renders properly. (Link)
  • I linked to issues and PRs that are relevant to this PR.

Description

Modified special_linear.py in geomstats.geometry and added codes on visualization for the special linear group
Submission as a part of geomviz hw of ECE594N
Co-authored-by: Pieter Derksen 98928045+pieterderksen-ucsb@users.noreply.github.com
Co-authored-by: Molly Kaplan 123593445+mollykaplan@users.noreply.github.com

Issue

Fixes inconsistencies in special_linear coming due to differences in the older (when special_linear was originally written by luisfpereira) and current versions of geomstats.

Additional context

Modified special_linear.py in geomstats.geometry
Added a file called special_linear in geomstats.visualization and modified __init__.py accordingly
Added a file called test_visualization_special_linear in tests.tests_geomstats to check the visualization functions defined
Added a notebook called special_linear in notebooks which checks the modifications to special_linear.py in geomstats.geometry and the functions defined in test_visualization_special_linear.py. Also added a file special_linear.py in notebooks to shows the animations.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Collaborator

@ninamiolane ninamiolane left a comment

Choose a reason for hiding this comment

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

Address the following before we can merge:

Copy link
Collaborator

@ninamiolane ninamiolane left a comment

Choose a reason for hiding this comment

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

Very nice!

"""Evaluate if a point belongs to the group.

Check the size and the value of the determinant.
Parameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

Clean the docstring style.

See errors in GitHub action's linting: they ask you to add blank lines between the sections of a docstring.
Also see the ECE594n HW guidelines which show an example of how docstring should be formatted.

return has_right_shape

def projection(self, point):
"""Project a point in embedding space to the group.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto

return gs.einsum("...ij,...->...ij", proj_point, 1.0 / scale_coeff)

def random_point(self, n_samples=1, bound=1.0):
"""Sample in the group.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto

"""Class for the Lie algebra sl(n) of the Special Linear group.

This is the space of matrices of size n with vanishing trace.
Parameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto

cubes = Cubes()
cubes.animate(points=points)

return ax
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using black on this file should make these warnings go away

Y_trans = pts[1]
Z_trans = pts[2]
ax.scatter3D(X_trans, Y_trans, Z_trans)
pts_T = gs.transpose(pts)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto: no uppercase

)

def animate(self, points, ax=None, **point_draw_kwargs):
"""Animation of the unit cube.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto: "Animate..."

@@ -0,0 +1,5 @@
from tests.tests_geomstats.test_visualization_special_linear import *
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this file, this is not a notebook.

from tests.conftest import TestCase
from tests.data_generation import _LieGroupTestData, _MatrixLieAlgebraTestData

# from tests.parametrizers import LieGroupParametrizer, MatrixLieAlgebraParametrizer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rm leftover comment

# from tests.parametrizers import LieGroupParametrizer, MatrixLieAlgebraParametrizer


# TODO: very similar to GeneralLinear tests (simplify common points)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rm leftover comment

skip_test_exp_log_composition = True
skip_test_log_exp_composition = True

class TestDataSpecialLinear(_LieGroupTestData):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hard/Expert (you can, but don't have to, address it): put this class into a special file within the tests/data folder and adapt the code accordingly. You can get inspiration on how it is done for other classes in geomstats: we have two files: one test file, and one data file.

@@ -0,0 +1,337 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

To make this notebook pass, try adding a Set up section with the code pasted from this example.

Correct typo in title


Reply via ReviewNB

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

Successfully merging this pull request may close these issues.

None yet

3 participants