From bbbb115196b479a117d6dc48021c1a2bdb62bbe8 Mon Sep 17 00:00:00 2001 From: "wbinventor@gmail.com" Date: Thu, 11 Feb 2016 12:07:23 -0500 Subject: [PATCH] Implemented __gt__ method for AggregateFilter --- openmc/arithmetic.py | 20 +++++++++++++------- openmc/element.py | 3 +++ openmc/mgxs/mgxs.py | 5 +++-- openmc/tallies.py | 6 ------ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/openmc/arithmetic.py b/openmc/arithmetic.py index 13f300968a..bbb303b140 100644 --- a/openmc/arithmetic.py +++ b/openmc/arithmetic.py @@ -647,7 +647,7 @@ class AggregateNuclide(object): @nuclides.setter def nuclides(self, nuclides): cv.check_iterable_type('nuclides', nuclides, - (basestring, Nuclide, CrossNuclide)) + (basestring, Nuclide, CrossNuclide)) self._nuclides = nuclides @aggregate_op.setter @@ -716,8 +716,16 @@ class AggregateFilter(object): return not self == other def __gt__(self, other): - # FIXME - return False + if self.type != other.type: + if self.aggregate_filter.type in _FILTER_TYPES and \ + other.aggregate_filter.type in _FILTER_TYPES: + delta = _FILTER_TYPES.index(self.aggregate_filter.type) - \ + _FILTER_TYPES.index(other.aggregate_filter.type) + return True if delta > 0 else False + else: + return False + else: + return False def __lt__(self, other): return not self > other @@ -789,9 +797,7 @@ class AggregateFilter(object): @bins.setter def bins(self, bins): cv.check_iterable_type('bins', bins, Iterable) - self._bins = [] - for bin in bins: - self._bins.append(tuple(bin)) + self._bins = map(tuple, bins) @aggregate_op.setter def aggregate_op(self, aggregate_op): @@ -956,4 +962,4 @@ class AggregateFilter(object): # Assign merged bins to merged filter merged_filter.bins = list(merged_bins) - return merged_filter \ No newline at end of file + return merged_filter diff --git a/openmc/element.py b/openmc/element.py index 4880dfaf23..dda110ea7a 100644 --- a/openmc/element.py +++ b/openmc/element.py @@ -57,6 +57,9 @@ class Element(object): def __ne__(self, other): return not self == other + def __gt__(self, other): + return repr(self) > repr(other) + def __lt__(self, other): return not self > other diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index b4c107139d..fb70b1bc8d 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -1917,7 +1917,8 @@ class ScatterMatrixXS(MGXS): self._correction = correction def get_slice(self, nuclides=[], groups=[]): - """Build a sliced MGXS for the specified nuclides and energy groups. + """Build a sliced ScatterMatrix for the specified nuclides and + energy groups. This method constructs a new MGXS to encapsulate a subset of the data represented by this MGXS. The subset of data to include in the tally @@ -2308,7 +2309,7 @@ class Chi(MGXS): return self._xs_tally def get_slice(self, nuclides=[], groups=[]): - """Build a sliced MGXS for the specified nuclides and energy groups. + """Build a sliced Chi for the specified nuclides and energy groups. This method constructs a new MGXS to encapsulate a subset of the data represented by this MGXS. The subset of data to include in the tally diff --git a/openmc/tallies.py b/openmc/tallies.py index 6b04403329..b15e730386 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -2188,12 +2188,6 @@ class Tally(object): """ - # Check that results have been read -# if not self.derived and self.sum is None: -# msg = 'Unable to use tally arithmetic with Tally ID="{0}" ' \ -# 'since it does not contain any results.'.format(self.id) -# raise ValueError(msg) - cv.check_type('filter1', filter1, (Filter, CrossFilter, AggregateFilter)) cv.check_type('filter2', filter2, (Filter, CrossFilter, AggregateFilter))