Skip to content

Commit

Permalink
add is_rare_earth and deprecate the old
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed May 18, 2024
1 parent bc11505 commit 1a65b7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
4 changes: 0 additions & 4 deletions docs/compatibility.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions pymatgen/core/periodic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import TYPE_CHECKING

import numpy as np
from monty.dev import deprecated
from monty.json import MSONable

from pymatgen.core.units import SUPPORTED_UNIT_NAMES, FloatWithUnit, Ha_to_eV, Length, Mass, Unit
Expand Down Expand Up @@ -696,20 +697,20 @@ def is_post_transition_metal(self) -> bool:
return self.symbol in ("Al", "Ga", "In", "Tl", "Sn", "Pb", "Bi")

@property
@deprecated(message="Please use is_rare_earth instead, which is corrected to include Y and Sc.")
def is_rare_earth_metal(self) -> bool:
"""True if element is a rare earth metal, Lanthanides (La) series and Actinides (Ac) series.
WARNING: This property would be updated to include Scandium (Sc) and
Yttrium (Y) after 2025-05-15.
Reference: https://en.wikipedia.org/wiki/Rare-earth_element.
This property is Deprecated, and scheduled for removal after 2025-01-01.
"""
warnings.warn(
"Y and Sc would be considered rare earth metal after 2025-05-15.",
stacklevel=2,
)
return self.is_lanthanoid or self.is_actinoid

return self.is_lanthanoid or self.is_actinoid # or self.symbol in {"Sc", "Y"}
@property
def is_rare_earth(self) -> bool:
"""True if element is a rare earth element, including Lanthanides (La)
series, Actinides (Ac) series, Scandium (Sc) and Yttrium (Y).
"""
return self.is_lanthanoid or self.is_actinoid or self.symbol in {"Sc", "Y"}

@property
def is_metal(self) -> bool:
Expand Down

0 comments on commit 1a65b7d

Please sign in to comment.