Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Small fixes
  • Loading branch information
paulromano committed May 2, 2024
commit cc6498fee32f155f53d54e7a75b067172d13da14
11 changes: 4 additions & 7 deletions openmc/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Trigger(EqualityMixin):

"""

def __init__(self, trigger_type: str, threshold: float, ignore_zeros: bool=False):
def __init__(self, trigger_type: str, threshold: float, ignore_zeros: bool = False):
self.trigger_type = trigger_type
self.threshold = threshold
self.ignore_zeros = ignore_zeros
Expand Down Expand Up @@ -70,11 +70,11 @@ def threshold(self):
def threshold(self, threshold):
cv.check_type('tally trigger threshold', threshold, Real)
self._threshold = threshold

@property
def ignore_zeros(self):
return self._ignore_zeros

@ignore_zeros.setter
def ignore_zeros(self, ignore_zeros):
cv.check_type('tally trigger ignores zeros', ignore_zeros, bool)
Expand Down Expand Up @@ -133,10 +133,7 @@ def from_xml_element(cls, elem: ET.Element):
threshold = float(elem.get("threshold"))
ignore_zeros = str(elem.get("ignore_zeros", "false")).lower()
# Try to convert to bool. Let Trigger error out on instantiation.
if ignore_zeros in ("true", "1"):
ignore_zeros = True
elif ignore_zeros in ("false", "0"):
ignore_zeros = False
ignore_zeros = ignore_zeros in ('true', '1')
trigger = cls(trigger_type, threshold, ignore_zeros)

# Add scores if present
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/test_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def test_tally_trigger_null_score(run_in_tmpdir):

def test_tally_trigger_zero_ignored(run_in_tmpdir):
pincell = openmc.examples.pwr_pin_cell()
# create an energy filter below and around the O-16(n,p) threshold

# create an energy filter below and around the O-16(n,p) threshold (1.02e7 eV)
e_filter = openmc.EnergyFilter([0.0, 1e7, 2e7])

# create a tally with triggers applied
Expand Down