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

Maintenance of the Basis class #493

Merged
merged 6 commits into from
Jan 14, 2025
Merged

Maintenance of the Basis class #493

merged 6 commits into from
Jan 14, 2025

Conversation

rileyjmurray
Copy link
Contributor

@rileyjmurray rileyjmurray commented Sep 28, 2024

This PR makes changes to the Basis class to help with my leakage PR (#410).

Specifics, at time of writing:

  • I split the mind-bogglingly-complicated Basis.cast function into four separate functions. Basis.cast dispatches the appropriate function just like before.
  • I removed the "classical_label" keyword argument from Basis.cast. It only appeared in a specific codepath, and it turns out that none of pyGSTI's existing code set this to anything other than its default value.

About EmbeddedBasis ...

It turns out that the EmbeddedBasis class isn't used anywhere in pyGSTi. (There are a few places that import it, but they still never use it.) I discovered this when I got an error trying to access eb.elements for an EmbeddedBasis eb. That trigged evaluation of EmbeddedBasis._lazy_build_elements, which tried to call an undefined function. See here for a repo-wide search for that function.

I'd like to use this PR as an opportunity to either (a) make EmbeddedBasis work, possibly with new semantics, or (b) remove EmbeddedBasis altogether.

After getting @enielse's blessing I've decided to remove EmbeddedBasis.

@rileyjmurray rileyjmurray marked this pull request as ready for review January 7, 2025 16:14
@rileyjmurray rileyjmurray requested review from a team as code owners January 7, 2025 16:14
@rileyjmurray rileyjmurray requested a review from sserita January 7, 2025 16:14
Copy link
Contributor

@coreyostrove coreyostrove left a comment

Choose a reason for hiding this comment

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

Approved, great work!

Copy link
Contributor

@sserita sserita left a comment

Choose a reason for hiding this comment

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

Thanks for this clean up @rileyjmurray, it's super helpful. I've made a few comments and will approve once you take a look at them, but there are no major changes being requested.

@@ -1782,283 +1760,3 @@ def create_simple_equivalent(self, builtin_basis_name=None):
if all([c.name == first_comp_name for c in self.component_bases]):
builtin_basis_name = first_comp_name # if all components have the same name
return BuiltinBasis(builtin_basis_name, self.elsize, sparse=self.sparse)


class EmbeddedBasis(LazyBasis):
Copy link
Contributor

Choose a reason for hiding this comment

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

No action items, just a personal note that we are removing this so that I can include it in my spring cleaning section of the release notes.

Comment on lines +240 to +246
# ^ The original implementation would return this value under two conditions.
# Either arg was None, or isinstance(arg,(tuple,list,ndarray)) and len(arg) == 0.
# We're just slightly relaxing the type requirement by using this check instead.

# At this point, original behavior would check that arg is a tuple, list, or ndarray.
# Instead, we'll just require that arg[0] is well-defined. This is enough to discern
# between the two cases we can still support.
Copy link
Contributor

Choose a reason for hiding this comment

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

These comments are helpful while doing review, but will be increasingly less useful as time goes on and we forget what the "original" was doing. Thoughts on removing these comments (at minimum) or replacing them with something that is more self-contained and explain what the check is looking for and why we cast specific ways in that case (stretch)?

@sserita sserita added this to the 0.9.13 milestone Jan 13, 2025
@sserita sserita merged commit c4410d5 into develop Jan 14, 2025
4 checks passed
@sserita sserita deleted the basis-maint branch January 14, 2025 17:49
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.

3 participants