Implemented __gt__ method for AggregateFilter

This commit is contained in:
wbinventor@gmail.com 2016-02-11 12:07:23 -05:00
parent ef60d9d2f5
commit bbbb115196
4 changed files with 19 additions and 15 deletions

View file

@ -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
return merged_filter

View file

@ -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

View file

@ -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

View file

@ -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))