From 1a65b7d81a6500e6803309af6750e0f4279e759c Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sat, 18 May 2024 10:43:07 +0800 Subject: [PATCH] add is_rare_earth and deprecate the old --- docs/compatibility.md | 4 ---- pymatgen/core/periodic_table.py | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/docs/compatibility.md b/docs/compatibility.md index 49cbc673b73..705cb1e8a06 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -67,10 +67,6 @@ Windows and Linux. ## Recent Breaking Changes -## v2024.xx.xx - -Scandium (Sc) and Yttrium (Y) would be included into `is_rare_earth_metal` property for `Element` after 2025-05-15, in [#3817](https://github.com/materialsproject/pymatgen/pull/3817). - ## v2024.1.26 The mixture of `(get|from)_str` and `(get|from)_string` methods on various `pymatgen` classes were migrated to a consistent `(get|from)_str` everywhere in [#3158](https://github.com/materialsproject/pymatgen/pull/3158) and several follow-up PRs. The deprecation release was [v2023.8.10](https://github.com/materialsproject/pymatgen/releases/tag/v2023.8.10) and the removal release resulting in a breaking change was [v2024.1.26](https://github.com/materialsproject/pymatgen/releases/tag/v2024.1.26). Migration to the new API in all cases is to replace: diff --git a/pymatgen/core/periodic_table.py b/pymatgen/core/periodic_table.py index b4b1667b28a..f46bcd82049 100644 --- a/pymatgen/core/periodic_table.py +++ b/pymatgen/core/periodic_table.py @@ -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 @@ -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: