Skip to content
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

Add is_radioactive property to Element class #3804

Merged
merged 5 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pymatgen/core/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def contains_element_type(self, category: str) -> bool:
category (str): one of "noble_gas", "transition_metal",
"post_transition_metal", "rare_earth_metal", "metal", "metalloid",
"alkali", "alkaline", "halogen", "chalcogen", "lanthanoid",
"actinoid", "quadrupolar", "s-block", "p-block", "d-block", "f-block"
"actinoid", "radioactive", "quadrupolar", "s-block", "p-block", "d-block", "f-block"

Returns:
bool: True if any elements in Composition match category, otherwise False
Expand Down
6 changes: 6 additions & 0 deletions pymatgen/core/periodic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ def is_actinoid(self) -> bool:
"""True if element is a actinoid."""
return 88 < self.Z < 104

@property
def is_radioactive(self) -> bool:
"""True if element is a radioactive element."""
return self.Z in (43, 61) or self.Z > 83

@property
def is_quadrupolar(self) -> bool:
"""Check if this element can be quadrupolar."""
Expand Down Expand Up @@ -1512,6 +1517,7 @@ class ElementType(Enum):
chalcogen = "chalcogen" # O, S, Se, Te, Po
lanthanoid = "lanthanoid" # La-Lu
actinoid = "actinoid" # Ac-Lr
radioactive = "radioactive" # Tc, Pm, Po-Lr
quadrupolar = "quadrupolar"
s_block = "s-block"
p_block = "p-block"
Expand Down
3 changes: 2 additions & 1 deletion tests/core/test_periodic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def test_attributes(self):
("U", "Pu"): "is_actinoid",
("Si", "Ge"): "is_metalloid",
("O", "Te"): "is_chalcogen",
("Tc", "Po"): "is_radioactive",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for the new is_radioactive property.

It seems that tests for the newly introduced is_radioactive property are missing. Would you like me to help generate these tests or should I open a GitHub issue to track this task?

}

for key, val in is_true.items():
Expand Down Expand Up @@ -607,4 +608,4 @@ def test_get_el_sp():
def test_element_type():
assert isinstance(ElementType.actinoid, Enum)
assert isinstance(ElementType.metalloid, Enum)
assert len(ElementType) == 17
assert len(ElementType) == 18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the expected count of ElementType enum.

The test for the length of the ElementType enum should reflect the addition of the new "radioactive" category. The expected count should be updated from 18 to 19 to accommodate this change.

- assert len(ElementType) == 18
+ assert len(ElementType) == 19

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
assert len(ElementType) == 18
assert len(ElementType) == 19