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

Remove redundant total_ordering decorator usage #4203

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented Nov 28, 2024

Summary

  • Remove redundant total_ordering decorator usage, as total_ordering is already applied on superclasses and child classes did not redefine any rich comparison operations.
  • Clean up comment of equality definition of core.IStructure
  • Minor import clean up (avoid from io import StringIO when it's used only twice as io is already imported)
  • Minor docstring clean up

needed_attrs = ("lattice", "sites", "properties")

# Return NotImplemented as in https://docs.python.org/3/library/functools.html#functools.total_ordering
Copy link
Contributor Author

@DanielYang59 DanielYang59 Nov 28, 2024

Choose a reason for hiding this comment

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

I guess total_ordering was applied on IStructure at some point but I believe this comment should be removed now (currently it more servers as an equality definition):

class IStructure(SiteCollection, MSONable):

Also current implementation of IStructure doesn't fulfill the prerequisite of applying total_ordering (only __eq__ is defined):

The class must define one of lt(), le(), gt(), or ge(). In addition, the class should supply an eq() method.

@DanielYang59 DanielYang59 marked this pull request as ready for review November 28, 2024 13:54
@DanielYang59 DanielYang59 marked this pull request as draft November 28, 2024 14:43
@DanielYang59 DanielYang59 marked this pull request as ready for review November 28, 2024 15:13
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.

1 participant