mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Test failure modes for Chain.set_capture_branches
Remove one validation check, that the passed item is a dict of strings. The check is covered when every key is inspected to ensure all parents exist in the chain
This commit is contained in:
parent
5b7253bca0
commit
a7b6737069
2 changed files with 19 additions and 2 deletions
|
|
@ -525,8 +525,6 @@ class Chain(object):
|
|||
|
||||
# Check for validity before manipulation
|
||||
|
||||
check_type("branch_ratios", branch_ratios, dict, str)
|
||||
|
||||
for parent, sub in branch_ratios.items():
|
||||
if parent not in self:
|
||||
if strict:
|
||||
|
|
|
|||
|
|
@ -310,3 +310,22 @@ def test_capture_branch_no_rxn():
|
|||
phrase = "U234 does not have capture reactions"
|
||||
with pytest.raises(AttributeError, match=phrase):
|
||||
chain.set_capture_branches(u4br)
|
||||
|
||||
|
||||
def test_capture_branch_failures(simple_chain):
|
||||
"""Test failure modes for setting capture branch ratios"""
|
||||
|
||||
# Parent isotope not present
|
||||
br = {"X": {"A": 0.6, "B": 0.7}}
|
||||
with pytest.raises(KeyError, match="X"):
|
||||
simple_chain.set_capture_branches(br)
|
||||
|
||||
# Product isotope not present
|
||||
br = {"C": {"X": 0.4, "A": 0.2, "B": 0.4}}
|
||||
with pytest.raises(KeyError, match="X"):
|
||||
simple_chain.set_capture_branches(br)
|
||||
|
||||
# Sum of ratios > 1.0
|
||||
br = {"C": {"A": 1.0, "B": 1.0}}
|
||||
with pytest.raises(ValueError, match="C ratios"):
|
||||
simple_chain.set_capture_branches(br)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue