Closed
Labels
breakingBreaking changeBreaking changeneeds discussionNeeds discussion to agree on actionable next stepsNeeds discussion to agree on actionable next steps
Description
@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.
pymatgen/pymatgen/core/periodic_table.py
Lines 30 to 33 in 3d4d160
| class ElementBase(Enum): | |
| """Element class defined without any enum values so it can be subclassed.""" | |
| def __init__(self, symbol: str): |
Metadata
Metadata
Assignees
Labels
breakingBreaking changeBreaking changeneeds discussionNeeds discussion to agree on actionable next stepsNeeds discussion to agree on actionable next steps
Activity
mkhorton commentedon May 18, 2023
Why was
ElementBasecreated to start with, presumably for good reason? I vaguely remember this, can try and find the PR.janosh commentedon May 18, 2023
Here's the PR: #2005 by @jmmshn.
It also lists subclasses as the reason for creating
ElementBase.mkhorton commentedon May 18, 2023
I see the mention for API use. Perhaps it was used to define a class for intercalant elements?
jmmshn commentedon May 18, 2023
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.
janosh commentedon May 18, 2023
@jmmshn Thanks for the context! I'll add this to the
ElementBasedoc str.add doc str explaining need for class ElementBase (closes materialspr…