diff --git a/openmc/cross.py b/openmc/cross.py index 435557ede..31006cbf7 100644 --- a/openmc/cross.py +++ b/openmc/cross.py @@ -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 diff --git a/openmc/tallies.py b/openmc/tallies.py index 71c84a280..c8090fc17 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -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: