diff --git a/openmc/mixin.py b/openmc/mixin.py index d144492399..dc2e91f51a 100644 --- a/openmc/mixin.py +++ b/openmc/mixin.py @@ -7,8 +7,8 @@ import openmc.checkvalue as cv class EqualityMixin: - """A Class which provides generic __eq__ and __ne__ functionality which - can easily be inherited by downstream classes. + """A Class which provides a generic __eq__ method that can be inherited + by downstream classes. """ def __eq__(self, other): diff --git a/openmc/trigger.py b/openmc/trigger.py index 1543d1ada7..fa0ffbbb27 100644 --- a/openmc/trigger.py +++ b/openmc/trigger.py @@ -3,9 +3,10 @@ from xml.etree import ElementTree as ET from collections.abc import Iterable import openmc.checkvalue as cv +from openmc.mixin import EqualityMixin -class Trigger: +class Trigger(EqualityMixin): """A criterion for when to finish a simulation based on tally uncertainties. Parameters @@ -33,14 +34,11 @@ class Trigger: self.threshold = threshold self._scores = [] - def __eq__(self, other): - return str(self) == str(other) - def __repr__(self): string = 'Trigger\n' - string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._trigger_type) - string += '{0: <16}{1}{2}\n'.format('\tThreshold', '=\t', self._threshold) - string += '{0: <16}{1}{2}\n'.format('\tScores', '=\t', self._scores) + string += '{: <16}=\t{}\n'.format('\tType', self._trigger_type) + string += '{: <16}=\t{}\n'.format('\tThreshold', self._threshold) + string += '{: <16}=\t{}\n'.format('\tScores', self._scores) return string @property