mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Apply suggestions from code review
* Use set operations (|=) rather than in-place methods (update) * Remove second arguments to some asserts in Chain.reduce testing Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
d67d0cd0f9
commit
3669709061
3 changed files with 19 additions and 19 deletions
|
|
@ -906,7 +906,7 @@ class Chain(object):
|
|||
|
||||
def _follow(self, isotopes, level):
|
||||
"""Return all isotopes present up to depth level"""
|
||||
found = set(isotopes)
|
||||
found = isotopes.copy()
|
||||
remaining = set(self.nuclide_dict)
|
||||
if not found.issubset(remaining):
|
||||
raise IndexError(
|
||||
|
|
@ -916,7 +916,7 @@ class Chain(object):
|
|||
if level == 0:
|
||||
return found
|
||||
|
||||
remaining.difference_update(found)
|
||||
remaining -= found
|
||||
|
||||
depth = 0
|
||||
next_iso = set()
|
||||
|
|
@ -952,8 +952,8 @@ class Chain(object):
|
|||
|
||||
# Prepare for next dig
|
||||
depth += 1
|
||||
isotopes.update(next_iso)
|
||||
remaining.difference_update(next_iso)
|
||||
isotopes |= next_iso
|
||||
remaining -= next_iso
|
||||
next_iso.clear()
|
||||
|
||||
# Process isotope that would have started next depth
|
||||
|
|
|
|||
|
|
@ -479,18 +479,18 @@ def test_reduce(gnd_simple_chain):
|
|||
assert u5_round0.n_decay_modes == ref_U5.n_decay_modes
|
||||
for newmode, refmode in zip(u5_round0.decay_modes, ref_U5.decay_modes):
|
||||
assert newmode.target is None
|
||||
assert newmode.type == refmode.type, newmode
|
||||
assert newmode.branching_ratio == refmode.branching_ratio, newmode
|
||||
assert newmode.type == refmode.type
|
||||
assert newmode.branching_ratio == refmode.branching_ratio
|
||||
|
||||
assert u5_round0.n_reaction_paths == ref_U5.n_reaction_paths
|
||||
for newrxn, refrxn in zip(u5_round0.reactions, ref_U5.reactions):
|
||||
assert newrxn.target is None, newrxn
|
||||
assert newrxn.type == refrxn.type, newrxn
|
||||
assert newrxn.Q == refrxn.Q, newrxn
|
||||
assert newrxn.branching_ratio == refrxn.branching_ratio, newrxn
|
||||
assert newrxn.target is None
|
||||
assert newrxn.type == refrxn.type
|
||||
assert newrxn.Q == refrxn.Q
|
||||
assert newrxn.branching_ratio == refrxn.branching_ratio
|
||||
|
||||
assert u5_round0.yield_data is not None
|
||||
assert u5_round0.yield_data.products == ("I135", )
|
||||
assert u5_round0.yield_data.products == ("I135",)
|
||||
assert u5_round0.yield_data.yield_matrix == (
|
||||
ref_U5_yields.yield_matrix[:, ref_U5_yields.products.index("I135")]
|
||||
)
|
||||
|
|
@ -499,15 +499,15 @@ def test_reduce(gnd_simple_chain):
|
|||
assert bareI5.n_decay_modes == ref_iodine.n_decay_modes
|
||||
for newmode, refmode in zip(bareI5.decay_modes, ref_iodine.decay_modes):
|
||||
assert newmode.target is None
|
||||
assert newmode.type == refmode.type, newmode
|
||||
assert newmode.branching_ratio == refmode.branching_ratio, newmode
|
||||
assert newmode.type == refmode.type
|
||||
assert newmode.branching_ratio == refmode.branching_ratio
|
||||
|
||||
assert bareI5.n_reaction_paths == ref_iodine.n_reaction_paths
|
||||
for newrxn, refrxn in zip(bareI5.reactions, ref_iodine.reactions):
|
||||
assert newrxn.target is None, newrxn
|
||||
assert newrxn.type == refrxn.type, newrxn
|
||||
assert newrxn.Q == refrxn.Q, newrxn
|
||||
assert newrxn.branching_ratio == refrxn.branching_ratio, newrxn
|
||||
assert newrxn.target is None
|
||||
assert newrxn.type == refrxn.type
|
||||
assert newrxn.Q == refrxn.Q
|
||||
assert newrxn.branching_ratio == refrxn.branching_ratio
|
||||
|
||||
follow_u5 = gnd_simple_chain.reduce(["U235"], 1)
|
||||
u5_round1 = follow_u5["U235"]
|
||||
|
|
|
|||
|
|
@ -181,9 +181,9 @@ def test_fission_yield_distribution():
|
|||
with_extras = yield_dist.restrict_products(
|
||||
["Xe135", "Sm149", "H1", "U235"])
|
||||
|
||||
assert strict_restrict.products == ("Sm149", "Xe135", )
|
||||
assert strict_restrict.products == ("Sm149", "Xe135")
|
||||
assert strict_restrict.energies == yield_dist.energies
|
||||
assert with_extras.products == ("Sm149", "Xe135", )
|
||||
assert with_extras.products == ("Sm149", "Xe135")
|
||||
assert with_extras.energies == yield_dist.energies
|
||||
for ene, new_yields in strict_restrict.items():
|
||||
for product in strict_restrict.products:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue