mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
raise value error if nuc not found
This commit is contained in:
parent
2ca0fafea0
commit
42696ed4ef
2 changed files with 13 additions and 3 deletions
|
|
@ -1251,7 +1251,17 @@ class Chain:
|
|||
Names of all radioactive decay daughters reachable from the
|
||||
parent.
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
If the nuclide is not present in the chain.
|
||||
|
||||
"""
|
||||
if nuclide not in self.nuclide_dict:
|
||||
raise ValueError(
|
||||
f"Cannot find decay daughters for '{nuclide}': "
|
||||
"nuclide is not in the chain."
|
||||
)
|
||||
daughters = set()
|
||||
stack = [nuclide]
|
||||
visited = set()
|
||||
|
|
|
|||
|
|
@ -607,9 +607,9 @@ def test_get_decay_daughters(gnd_simple_chain):
|
|||
daughters = gnd_simple_chain.get_decay_daughters("Cs135")
|
||||
assert daughters == set()
|
||||
|
||||
# Nuclide not in chain returns empty set
|
||||
daughters = gnd_simple_chain.get_decay_daughters("Xx999")
|
||||
assert daughters == set()
|
||||
# Nuclide not in chain raises ValueError
|
||||
with pytest.raises(ValueError, match="not in the chain"):
|
||||
gnd_simple_chain.get_decay_daughters("Xx999")
|
||||
|
||||
|
||||
def test_get_decay_daughters_cyclic(simple_chain):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue