Skip to content

Merge ElementBase into Element? #2999

Closed

Description

@janosh

@shyuep Should we merge ElementBase into Element? It says ElementBase has no enum values so it can be subclassed but it isn't actually subclassed anywhere in pymatgen. Seems cleaner to only have an Element class.

class ElementBase(Enum):
"""Element class defined without any enum values so it can be subclassed."""
def __init__(self, symbol: str):

Activity

  1. mkhorton commented on May 18, 2023

    @mkhorton
    Member

    Why was ElementBase created to start with, presumably for good reason? I vaguely remember this, can try and find the PR.

  2. janosh commented on May 18, 2023

    @janosh
    MemberAuthor

    Here's the PR: #2005 by @jmmshn.

    It also lists subclasses as the reason for creating ElementBase.

  3. mkhorton commented on May 18, 2023

    @mkhorton
    Member

    I see the mention for API use. Perhaps it was used to define a class for intercalant elements?

  4. jmmshn commented on May 18, 2023

    @jmmshn
    Contributor

    I think it was to get nested as_dict / from_dict to work properly. So the problem was that all the classes in emmet that had these classes required very custom construction and I wanted to have a a definition of these classes that behaved more like dataclasses so serialization was less troublesome. There were many times where the objects serialized only when they were top level.

  5. janosh commented on May 18, 2023

    @janosh
    MemberAuthor

    @jmmshn Thanks for the context! I'll add this to the ElementBase doc str.

  6. added a commit that references this issue on Feb 9, 2024
    ea3d300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingBreaking changeneeds discussionNeeds discussion to agree on actionable next steps

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions