-
Notifications
You must be signed in to change notification settings - Fork 880
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
[Deprecation] Replace Element
property is_rare_earth_metal
with is_rare_earth
to include Y and Sc
#3817
[Deprecation] Replace Element
property is_rare_earth_metal
with is_rare_earth
to include Y and Sc
#3817
Conversation
@janosh. Can you please review this one? Thanks! |
Just want to mention here that I expect lot's of code to be broken. |
Thanks for commenting! I'm not sure quite to properly notify users in this case (except for insert a warning in the |
Maybe, rename the property and deprecate the old one? |
I think there is no reason to rename it (as the name seems proper to me)? Just the implementation need to be corrected. Maybe I didn't make myself clear enough, perhaps we could first change the @property
def is_rare_earth_metal(self) -> bool:
"""True if element is a rare earth metal, including Scandium (Sc),
Yttrium (Y), Lanthanides (La) series and Actinides (Ac) series.
Reference: https://en.wikipedia.org/wiki/Rare-earth_element.
"""
warning.warn("Y and Sc would be considered rare earth metal in a later version of pymatgen.")
return self.is_lanthanoid or self.is_actinoid And then really change the implementation after some grace period? But personally such breaking change is acceptable as I would consider it a "fix". What do you think? |
Renaming for the deprecation. I personally don't think it is acceptable without proper deprecation. |
Sorry I didn't quite understand.
Yes I'm feeling this is too "core/fundamental" to just change without any warning. Let's hear what Janosh is going to say :) |
Element
Element
Element
Element
Instead of a breaking change, could you @DanielYang59 add a separate property
Speaking from experience, it's really hard to estimate what the downstream effects of a breaking change like this are. I unintentionally broke features in one of MP's more highly used codes, matminer, simply by adding data for higher-Z elements to pymatgen's That code is not as actively maintained as pymatgen is, and I think most users expect pymatgen functionality to be stable |
Great suggestion! |
I agree with @JaGeo and @esoteric-ephemera - NO BREAKING CHANGES UNLESS ABSOLUTELY NECESSARY. |
Thanks for the suggestion and sharing your experience, that would be very helpful. Yes I totally agree adding a property would be safer, but why should we keep a definition that doesn't align with IUPAC standard? I assume this might cause unexpected behavior too. |
Let me look into this myself, but on first glance I agree with @DanielYang59 here: we absolutely should follow IUPAC conventions (or similar standards bodies), pymatgen is not the appropriate arbiter of what is or isn’t a rare earth element. This would then be a bug that needs fixing. |
![]() From the latest edition of the IUPAC Red Book, 2005, p51. This concurs with the 1985 edition. I also appreciated this note (p52), since it caused some confusion for myself: ![]() I would therefore consider this a bug. Fixing the bug might indeed be a breaking change: I'm glad to see more caution around breaking changes, they are painful, but for a bug it has to be the correct course of action. I think consensus seems to be that "rare earth element" is not a useful name in any case, but nevertheless if it is used, we should be consistent with standards. |
Not necessarily right? Excel has had a bug since its inception due it assuming incorrectly that the year 1900 was a leap year. This can break excel code between mac excel, which has the epoch as the leap year 1904, and ms-dos-based excel, which has the epoch as the fake leap year 1900. But it's been maintained and documented heavily by Microsoft because it could break a lot of code built on top of it I prefer the non-breaking solution of raising a warning when using the We've had a good amount of software instability lately, especially in atomate2 and emmet, due to breaking changes. I am admittedly being overly cautious |
I appreciate the point, and I sympathise with it. I have long been an advocate for not making breaking changes wherever possible -- I have often been the recipient myself of some amount of pain from unnecessary breaking changes. That said, I think we can make a distinction between a breaking change which is scientifically meaningful, and a breaking change which is not scientifically motivated. The IUPAC creates conventions for good reasons. I am thinking of the student using pymatgen and being misled, for example. Your suggestion of a warning is a good one if we are very concerned by the change:
This creates some messiness, but I could see this as a compromise. Nevertheless, warnings are often not seen. There is still a danger here. It also does not fix any mistaken usage in downstream code, whose developers might appreciate the fix without additional action being required on their part -- this is the complementary argument. At least within the Materials Project stack or closely-linked codes, this is also something we can inspect. We can look for usages of My recommendation would still be to implement the fix. |
@janosh Can you please suggest on this one? |
@DanielYang59 fwiw, i agree with @mkhorton and the changes you propose in this PR but i prefer for others to make the decision. given there are precisely zero internal calls to |
I suggest we do a correct |
I like this idea, because I would implement this tomorrow |
Element
is_rare_earth_metal
with is_rare_earth
to include Y and Sc for Element
is_rare_earth_metal
with is_rare_earth
to include Y and Sc for Element
Element
property is_rare_earth_metal
with is_rare_earth
to include Y and Sc
I hope everyone is happy now :) |
Element
property is_rare_earth_metal
with is_rare_earth
to include Y and Sc Element
property is_rare_earth_metal
with is_rare_earth
to include Y and Sc
Great, @DanielYang59 ! I am happy as well with this solution! |
Summary
Element
propertyis_rare_earth_metal
withis_rare_earth
to include Y and Sc, removeis_rare_earth_metal
after2025-01-01
.pymatgen/pymatgen/core/periodic_table.py
Lines 689 to 692 in 6c696cd
monty
version to use thedeadline
argumentReference
From the 1985 IUPAC Red Book:
And Wikipedia: