fixed error in cross.py and added remove_filter attribute to tally summation

This commit is contained in:
Sam Shaner 2015-11-19 16:47:55 -05:00
parent e2d2f90c5b
commit df3b9ed017
2 changed files with 6 additions and 10 deletions

View file

@ -356,7 +356,7 @@ class CrossFilter(object):
def type(self, filter_type):
if filter_type not in _FILTER_TYPES.values():
msg = 'Unable to set Filter type to "{0}" since it is not one ' \
'of the supported types'.format(type)
'of the supported types'.format(filter_type)
raise ValueError(msg)
self._type = filter_type

View file

@ -2430,7 +2430,7 @@ class Tally(object):
return new_tally
def summation(self, scores=[], filter_type=None,
filter_bins=[], nuclides=[]):
filter_bins=[], nuclides=[], remove_filter=False):
"""Vectorized sum of tally data across scores, filter bins and/or
nuclides using tally addition.
@ -2459,6 +2459,9 @@ class Tally(object):
nuclides : list of str
A list of nuclide name strings to sum across
(e.g., ['U-235', 'U-238']; default is [])
remove_filter : bool
If a filter is being summed over, this bool indicates whether to
remove that filter in the returned tally.
Returns
-------
@ -2466,13 +2469,6 @@ class Tally(object):
A new tally which encapsulates the sum of data requested.
"""
# If user input filter type but no bins, sum across all bins and
# remove the filter
if filter_type in _FILTER_TYPES and len(filter_bins) == 0:
remove_filter = True
else:
remove_filter = False
# If user did not specify any scores, do not sum across scores
if len(scores) == 0:
scores = [[]]
@ -2523,7 +2519,7 @@ class Tally(object):
# Add back the filter(s) which were summed across to derived tally,
# if filter bins were input; otherwise, leave out summed filter(s)
if remove_filter:
if remove_filter and filter_type is not None:
# Rename tally sum indicating a summation over a particular filter
tally_sum.name = 'sum({0}, {1})'.format(self.name, filter_type)
else: