From f02fbe5ab970578733cecf99fa6cb65ad02cbbb3 Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Tue, 25 Apr 2017 09:55:49 -0400 Subject: [PATCH 1/8] fixed tally alignment method in tallies.py --- openmc/tallies.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/openmc/tallies.py b/openmc/tallies.py index 0bf87de101..7515883f61 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -1853,7 +1853,7 @@ class Tally(object): other_copy.sparse = False # Align the tally data based on desired hybrid product - data = self_copy._align_tally_data(other_copy, filter_product, + data = self_copy._align_tally_data(other, other_copy, filter_product, nuclide_product, score_product) # Perform tally arithmetic operation @@ -1948,8 +1948,8 @@ class Tally(object): self_filter.stride = stride stride *= self_filter.num_bins - def _align_tally_data(self, other, filter_product, nuclide_product, - score_product): + def _align_tally_data(self, other_old, other, filter_product, + nuclide_product, score_product): """Aligns data from two tallies for tally arithmetic. This is a helper method to construct a dict of dicts of the "aligned" @@ -1963,8 +1963,12 @@ class Tally(object): Parameters ---------- + other_old : openmc.Tally + The tally to outer product with this tally with the old tally + alignment other : openmc.Tally - The tally to outer product with this tally + The tally to outer product with this tally with the new tally + alignment filter_product : {'entrywise'} The type of product to be performed between filter data. Currently, only the entrywise product is supported for the filter product. @@ -2009,7 +2013,7 @@ class Tally(object): # If necessary, swap other filter if other_index != i: - other._swap_filters(self_filter, other.filters[i]) + other._swap_filters(self_filter, other.filters[i], other_old) # Repeat and tile the data by nuclide in preparation for performing # the tensor product across nuclides. @@ -2110,7 +2114,7 @@ class Tally(object): data['other']['std. dev.'] = other.std_dev return data - def _swap_filters(self, filter1, filter2): + def _swap_filters(self, filter1, filter2, other_old): """Reverse the ordering of two filters in this tally This is a helper method for tally arithmetic which helps align the data @@ -2124,6 +2128,8 @@ class Tally(object): filter2 : Filter The filter to swap with filter1 + other_old : openmc.Tally + A copy of this tally with the old filter alignment Raises ------ @@ -2177,7 +2183,7 @@ class Tally(object): if self.mean is not None: for bin1, bin2 in itertools.product(filter1_bins, filter2_bins): filter_bins = [(bin1,), (bin2,)] - data = self.get_values( + data = other_old.get_values( filters=filters, filter_bins=filter_bins, value='mean') indices = self.get_filter_indices(filters, filter_bins) self.mean[indices, :, :] = data @@ -2186,7 +2192,7 @@ class Tally(object): if self.std_dev is not None: for bin1, bin2 in itertools.product(filter1_bins, filter2_bins): filter_bins = [(bin1,), (bin2,)] - data = self.get_values( + data = other_old.get_values( filters=filters, filter_bins=filter_bins, value='std_dev') indices = self.get_filter_indices(filters, filter_bins) self.std_dev[indices, :, :] = data From a59c167d34498ed2159ee4118f819b447883468b Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Tue, 25 Apr 2017 09:58:47 -0400 Subject: [PATCH 2/8] added other_old to _swap_filter method --- openmc/tallies.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openmc/tallies.py b/openmc/tallies.py index 7515883f61..8df26c1333 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -912,7 +912,8 @@ class Tally(object): for i, filter1 in enumerate(self.filters): for filter2 in other.filters: if filter1 != filter2 and filter1.can_merge(filter2): - other_copy._swap_filters(other_copy.filters[i], filter2) + other_copy._swap_filters(other_copy.filters[i], filter2, + other) merged_tally.filters[i] = filter1.merge(filter2) join_right = filter1 < filter2 merge_axis = i From 61fab479e01cfa75b469f8de5d15211654be8722 Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Tue, 25 Apr 2017 13:59:55 -0400 Subject: [PATCH 3/8] fixed bug for misaligned energy and energyout filters --- openmc/tallies.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openmc/tallies.py b/openmc/tallies.py index 8df26c1333..998abb1ed3 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -1344,7 +1344,7 @@ class Tally(object): # If a user-requested Filter, get the user-requested bins for j, test_filter in enumerate(filters): - if isinstance(self_filter, test_filter): + if type(self_filter) == test_filter: bins = filter_bins[j] user_filter = True break @@ -2126,7 +2126,6 @@ class Tally(object): ---------- filter1 : Filter The filter to swap with filter2 - filter2 : Filter The filter to swap with filter1 other_old : openmc.Tally From b212612657147602b110cd526a6abab0568410fe Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Tue, 25 Apr 2017 14:45:36 -0400 Subject: [PATCH 4/8] fixed issue in tallies.py in making sure static copy of other filter gets updated and updated tests --- openmc/tallies.py | 4 ++ tests/test_mgxs_library_hdf5/results_true.dat | 52 +++++++++---------- .../results_true.dat | 40 +++++++------- 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/openmc/tallies.py b/openmc/tallies.py index 998abb1ed3..b7b5e5f3b8 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -2001,6 +2001,10 @@ class Tally(object): other._std_dev = np.repeat(other.std_dev, filter_copy.num_bins, axis=0) other.filters.append(filter_copy) + # Create a new static copy of the other tally to use in swapping filters + if len(other_missing_filters) > 0: + other_old = copy.deepcopy(other) + # Add filters present in other but not in self to self for self_filter in self_missing_filters: filter_copy = copy.deepcopy(self_filter) diff --git a/tests/test_mgxs_library_hdf5/results_true.dat b/tests/test_mgxs_library_hdf5/results_true.dat index f3426cd40a..1c95510970 100644 --- a/tests/test_mgxs_library_hdf5/results_true.dat +++ b/tests/test_mgxs_library_hdf5/results_true.dat @@ -105,18 +105,18 @@ domain=10000 type=prompt-nu-fission matrix [[3.14909051e-03 0.00000000e+00] [2.86750878e-02 0.00000000e+00]] domain=10000 type=delayed-nu-fission -[[2.29808266e-05 1.06974147e-04] - [1.43606354e-04 5.52167849e-04] - [1.51382232e-04 5.27147626e-04] - [7.42603126e-05 2.22017986e-04] - [4.14908415e-05 9.10244168e-05] - [1.70015984e-05 3.81298021e-05]] -[[1.66363187e-06 9.49155601e-06] - [1.05907827e-05 4.89925095e-05] - [1.12671254e-05 4.67725251e-05] - [5.22610330e-06 1.87563055e-05] - [2.99830756e-06 7.68983466e-06] - [1.22654681e-06 3.22124422e-06]] +[[4.31687649e-06 1.06974147e-04] + [2.69760050e-05 5.52167849e-04] + [2.84366794e-05 5.27147626e-04] + [7.42603126e-05 1.18190938e-03] + [4.14908415e-05 4.84567103e-04] + [1.70015984e-05 2.02983423e-04]] +[[2.89748553e-07 9.49155601e-06] + [1.85003751e-06 4.89925095e-05] + [1.97097930e-06 4.67725251e-05] + [5.22610330e-06 1.04867938e-04] + [2.99830756e-06 4.29944539e-05] + [1.22654681e-06 1.80102228e-05]] domain=10000 type=chi-delayed [[0.00000000e+00 0.00000000e+00] [1.00000000e+00 0.00000000e+00] @@ -131,18 +131,18 @@ domain=10000 type=chi-delayed [0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]] domain=10000 type=beta -[[4.89188226e-05 2.27713711e-04] - [3.05691952e-04 1.17538858e-03] - [3.22244307e-04 1.12212853e-03] - [3.82159878e-03 1.14255332e-02] - [2.13520982e-03 4.68431640e-03] - [8.74939593e-04 1.96224336e-03]] -[[4.67388636e-06 2.46946655e-05] - [2.95223864e-05 1.27466313e-04] - [3.12884979e-05 1.21690467e-04] - [3.21434953e-04 1.09939768e-03] - [1.82980531e-04 4.50738369e-04] - [7.48900067e-05 1.88812689e-04]] +[[2.22155945e-04 2.27713711e-04] + [1.38824446e-03 1.17538858e-03] + [1.46341397e-03 1.12212853e-03] + [3.82159878e-03 2.51590670e-03] + [2.13520982e-03 1.03148823e-03] + [8.74939593e-04 4.32086725e-04]] +[[1.80847602e-05 2.46946655e-05] + [1.14688936e-04 1.27466313e-04] + [1.21787672e-04 1.21690467e-04] + [3.21434953e-04 2.72840272e-04] + [1.82980531e-04 1.11860871e-04] + [7.48900067e-05 4.68581181e-05]] domain=10000 type=decay-rate [[1.34450193e-02 1.33360001e-02] [3.20638663e-02 3.27389978e-02] @@ -167,7 +167,7 @@ domain=10000 type=delayed-nu-fission matrix [1.18579136e-03 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] - [8.59786782e-04 0.00000000e+00]] + [4.82335163e-03 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]] @@ -184,7 +184,7 @@ domain=10000 type=delayed-nu-fission matrix [1.18610370e-03 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] - [2.22194557e-04 0.00000000e+00]] + [1.23402593e-03 0.00000000e+00]] [[0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]] diff --git a/tests/test_mgxs_library_no_nuclides/results_true.dat b/tests/test_mgxs_library_no_nuclides/results_true.dat index e3481ce4ec..a6a0c374e0 100644 --- a/tests/test_mgxs_library_no_nuclides/results_true.dat +++ b/tests/test_mgxs_library_no_nuclides/results_true.dat @@ -128,19 +128,19 @@ 2 10000 1 2 total 0.000000 0.000000 1 10000 2 1 total 0.445819 0.028675 0 10000 2 2 total 0.000000 0.000000 - material delayedgroup group in nuclide mean std. dev. -1 10000 1 1 total 0.000023 0.000002 -3 10000 2 1 total 0.000144 0.000011 -5 10000 3 1 total 0.000151 0.000011 -7 10000 4 1 total 0.000074 0.000005 -9 10000 5 1 total 0.000041 0.000003 -11 10000 6 1 total 0.000017 0.000001 -0 10000 1 2 total 0.000107 0.000009 -2 10000 2 2 total 0.000552 0.000049 -4 10000 3 2 total 0.000527 0.000047 -6 10000 4 2 total 0.000222 0.000019 -8 10000 5 2 total 0.000091 0.000008 -10 10000 6 2 total 0.000038 0.000003 + material delayedgroup group in nuclide mean std. dev. +1 10000 1 1 total 0.000004 2.897486e-07 +3 10000 2 1 total 0.000027 1.850038e-06 +5 10000 3 1 total 0.000028 1.970979e-06 +7 10000 4 1 total 0.000074 5.226103e-06 +9 10000 5 1 total 0.000041 2.998308e-06 +11 10000 6 1 total 0.000017 1.226547e-06 +0 10000 1 2 total 0.000107 9.491556e-06 +2 10000 2 2 total 0.000552 4.899251e-05 +4 10000 3 2 total 0.000527 4.677253e-05 +6 10000 4 2 total 0.001182 1.048679e-04 +8 10000 5 2 total 0.000485 4.299445e-05 +10 10000 6 2 total 0.000203 1.801022e-05 material delayedgroup group out nuclide mean std. dev. 1 10000 1 1 total 0.0 0.000000 3 10000 2 1 total 1.0 0.869128 @@ -155,18 +155,18 @@ 8 10000 5 2 total 0.0 0.000000 10 10000 6 2 total 0.0 0.000000 material delayedgroup group in nuclide mean std. dev. -1 10000 1 1 total 0.000049 0.000005 -3 10000 2 1 total 0.000306 0.000030 -5 10000 3 1 total 0.000322 0.000031 +1 10000 1 1 total 0.000222 0.000018 +3 10000 2 1 total 0.001388 0.000115 +5 10000 3 1 total 0.001463 0.000122 7 10000 4 1 total 0.003822 0.000321 9 10000 5 1 total 0.002135 0.000183 11 10000 6 1 total 0.000875 0.000075 0 10000 1 2 total 0.000228 0.000025 2 10000 2 2 total 0.001175 0.000127 4 10000 3 2 total 0.001122 0.000122 -6 10000 4 2 total 0.011426 0.001099 -8 10000 5 2 total 0.004684 0.000451 -10 10000 6 2 total 0.001962 0.000189 +6 10000 4 2 total 0.002516 0.000273 +8 10000 5 2 total 0.001031 0.000112 +10 10000 6 2 total 0.000432 0.000047 material delayedgroup group in nuclide mean std. dev. 1 10000 1 1 total 0.013445 0.001084 3 10000 2 1 total 0.032064 0.002658 @@ -196,7 +196,7 @@ 1 10000 1 2 1 total 0.000000 0.000000 5 10000 2 2 1 total 0.002538 0.001561 9 10000 3 2 1 total 0.001186 0.001186 -13 10000 4 2 1 total 0.000860 0.000222 +13 10000 4 2 1 total 0.004823 0.001234 17 10000 5 2 1 total 0.000000 0.000000 21 10000 6 2 1 total 0.000000 0.000000 0 10000 1 2 2 total 0.000000 0.000000 From ad3043970dd8e4559c319766e1072deed79759e0 Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Tue, 25 Apr 2017 16:55:10 -0400 Subject: [PATCH 5/8] changed == to is --- openmc/tallies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/tallies.py b/openmc/tallies.py index b7b5e5f3b8..f1754f2630 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -1344,7 +1344,7 @@ class Tally(object): # If a user-requested Filter, get the user-requested bins for j, test_filter in enumerate(filters): - if type(self_filter) == test_filter: + if type(self_filter) is test_filter: bins = filter_bins[j] user_filter = True break From f275b712991a76b94da3dffa2b92d60536ea13c4 Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Wed, 26 Apr 2017 12:55:13 -0400 Subject: [PATCH 6/8] updated to only modify the _swap_filters method --- openmc/tallies.py | 111 +++++++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 51 deletions(-) diff --git a/openmc/tallies.py b/openmc/tallies.py index f1754f2630..7d7ba2e7a1 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -912,8 +912,7 @@ class Tally(object): for i, filter1 in enumerate(self.filters): for filter2 in other.filters: if filter1 != filter2 and filter1.can_merge(filter2): - other_copy._swap_filters(other_copy.filters[i], filter2, - other) + other_copy._swap_filters(other_copy.filters[i], filter2) merged_tally.filters[i] = filter1.merge(filter2) join_right = filter1 < filter2 merge_axis = i @@ -1854,7 +1853,7 @@ class Tally(object): other_copy.sparse = False # Align the tally data based on desired hybrid product - data = self_copy._align_tally_data(other, other_copy, filter_product, + data = self_copy._align_tally_data(other_copy, filter_product, nuclide_product, score_product) # Perform tally arithmetic operation @@ -1949,8 +1948,8 @@ class Tally(object): self_filter.stride = stride stride *= self_filter.num_bins - def _align_tally_data(self, other_old, other, filter_product, - nuclide_product, score_product): + def _align_tally_data(self, other, filter_product, nuclide_product, + score_product): """Aligns data from two tallies for tally arithmetic. This is a helper method to construct a dict of dicts of the "aligned" @@ -1964,12 +1963,8 @@ class Tally(object): Parameters ---------- - other_old : openmc.Tally - The tally to outer product with this tally with the old tally - alignment other : openmc.Tally - The tally to outer product with this tally with the new tally - alignment + The tally to outer product with this tally. filter_product : {'entrywise'} The type of product to be performed between filter data. Currently, only the entrywise product is supported for the filter product. @@ -1997,14 +1992,12 @@ class Tally(object): # Add filters present in self but not in other to other for other_filter in other_missing_filters: filter_copy = copy.deepcopy(other_filter) - other._mean = np.repeat(other.mean, filter_copy.num_bins, axis=0) - other._std_dev = np.repeat(other.std_dev, filter_copy.num_bins, axis=0) + other._mean = np.repeat(other.mean, + filter_copy.num_bins, axis=0) + other._std_dev = np.repeat(other.std_dev, + filter_copy.num_bins, axis=0) other.filters.append(filter_copy) - # Create a new static copy of the other tally to use in swapping filters - if len(other_missing_filters) > 0: - other_old = copy.deepcopy(other) - # Add filters present in other but not in self to self for self_filter in self_missing_filters: filter_copy = copy.deepcopy(self_filter) @@ -2018,7 +2011,7 @@ class Tally(object): # If necessary, swap other filter if other_index != i: - other._swap_filters(self_filter, other.filters[i], other_old) + other._swap_filters(self_filter, other.filters[i]) # Repeat and tile the data by nuclide in preparation for performing # the tensor product across nuclides. @@ -2046,9 +2039,11 @@ class Tally(object): # Add nuclides present in self but not in other to other for nuclide in other_missing_nuclides: other._mean = \ - np.insert(other.mean, other.num_nuclides, 0, axis=1) + np.insert(other.mean, other.num_nuclides, + 0, axis=1) other._std_dev = \ - np.insert(other.std_dev, other.num_nuclides, 0, axis=1) + np.insert(other.std_dev, other.num_nuclides, + 0, axis=1) other.nuclides.append(nuclide) # Add nuclides present in other but not in self to self @@ -2071,9 +2066,12 @@ class Tally(object): # the tensor product across scores. if score_product == 'tensor': self._mean = np.repeat(self.mean, other.num_scores, axis=2) - self._std_dev = np.repeat(self.std_dev, other.num_scores, axis=2) - other._mean = np.tile(other.mean, (1, 1, self.num_scores)) - other._std_dev = np.tile(other.std_dev, (1, 1, self.num_scores)) + self._std_dev = np.repeat(self.std_dev, other.num_scores, + axis=2) + other._mean = \ + np.tile(other.mean, (1, 1, self.num_scores)) + other._std_dev = \ + np.tile(other.std_dev, (1, 1, self.num_scores)) # Add scores to each tally such that each tally contains the complete set # of scores necessary to perform an entrywise product. New scores added @@ -2088,8 +2086,12 @@ class Tally(object): # Add scores present in self but not in other to other for score in other_missing_scores: - other._mean = np.insert(other.mean, other.num_scores, 0, axis=2) - other._std_dev = np.insert(other.std_dev, other.num_scores, 0, axis=2) + other._mean = \ + np.insert(other.mean, other.num_scores, 0, + axis=2) + other._std_dev = \ + np.insert(other.std_dev, other.num_scores, 0, + axis=2) other.scores.append(score) # Add scores present in other but not in self to self @@ -2119,7 +2121,7 @@ class Tally(object): data['other']['std. dev.'] = other.std_dev return data - def _swap_filters(self, filter1, filter2, other_old): + def _swap_filters(self, filter1, filter2): """Reverse the ordering of two filters in this tally This is a helper method for tally arithmetic which helps align the data @@ -2132,8 +2134,6 @@ class Tally(object): The filter to swap with filter2 filter2 : Filter The filter to swap with filter1 - other_old : openmc.Tally - A copy of this tally with the old filter alignment Raises ------ @@ -2158,15 +2158,6 @@ class Tally(object): 'does not contain such a filter'.format(filter2.type, self.id) raise ValueError(msg) - # Swap the filters in the copied version of this Tally - filter1_index = self.filters.index(filter1) - filter2_index = self.filters.index(filter2) - self.filters[filter1_index] = filter2 - self.filters[filter2_index] = filter1 - - # Update the tally's filter strides - self._update_filter_strides() - # Construct lists of tuples for the bins in each of the two filters filters = [type(filter1), type(filter2)] if isinstance(filter1, openmc.DistribcellFilter): @@ -2183,23 +2174,41 @@ class Tally(object): else: filter2_bins = [filter2.get_bin(i) for i in range(filter2.num_bins)] - # Adjust the mean data array to relect the new filter order - if self.mean is not None: - for bin1, bin2 in itertools.product(filter1_bins, filter2_bins): - filter_bins = [(bin1,), (bin2,)] - data = other_old.get_values( - filters=filters, filter_bins=filter_bins, value='mean') - indices = self.get_filter_indices(filters, filter_bins) - self.mean[indices, :, :] = data + # Create variables to store views of data in the misaligned structure + mean = {} + std_dev = {} - # Adjust the std_dev data array to relect the new filter order - if self.std_dev is not None: - for bin1, bin2 in itertools.product(filter1_bins, filter2_bins): - filter_bins = [(bin1,), (bin2,)] - data = other_old.get_values( + # Store the data from the misaligned structure + for i, (bin1, bin2) in enumerate(itertools.product(filter1_bins, filter2_bins)): + filter_bins = [(bin1,), (bin2,)] + + if self.mean is not None: + mean[i] = self.get_values( + filters=filters, filter_bins=filter_bins, value='mean') + + if self.std_dev is not None: + std_dev[i] = self.get_values( filters=filters, filter_bins=filter_bins, value='std_dev') - indices = self.get_filter_indices(filters, filter_bins) - self.std_dev[indices, :, :] = data + + # Swap the filters in the copied version of this Tally + filter1_index = self.filters.index(filter1) + filter2_index = self.filters.index(filter2) + self.filters[filter1_index] = filter2 + self.filters[filter2_index] = filter1 + + # Update the tally's filter strides + self._update_filter_strides() + + # Realign the data + for i, (bin1, bin2) in enumerate(itertools.product(filter1_bins, filter2_bins)): + filter_bins = [(bin1,), (bin2,)] + indices = self.get_filter_indices(filters, filter_bins) + + if self.mean is not None: + self.mean[indices, :, :] = mean[i] + + if self.std_dev is not None: + self.std_dev[indices, :, :] = std_dev[i] def _swap_nuclides(self, nuclide1, nuclide2): """Reverse the ordering of two nuclides in this tally From d9825f18a27266e38dc8e42af3bb0731a95d9d13 Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Wed, 26 Apr 2017 12:57:11 -0400 Subject: [PATCH 7/8] removed unnecessary modifications --- openmc/tallies.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/openmc/tallies.py b/openmc/tallies.py index 7d7ba2e7a1..59f9012cd5 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -1964,7 +1964,7 @@ class Tally(object): Parameters ---------- other : openmc.Tally - The tally to outer product with this tally. + The tally to outer product with this tally filter_product : {'entrywise'} The type of product to be performed between filter data. Currently, only the entrywise product is supported for the filter product. @@ -1992,10 +1992,8 @@ class Tally(object): # Add filters present in self but not in other to other for other_filter in other_missing_filters: filter_copy = copy.deepcopy(other_filter) - other._mean = np.repeat(other.mean, - filter_copy.num_bins, axis=0) - other._std_dev = np.repeat(other.std_dev, - filter_copy.num_bins, axis=0) + other._mean = np.repeat(other.mean, filter_copy.num_bins, axis=0) + other._std_dev = np.repeat(other.std_dev, filter_copy.num_bins, axis=0) other.filters.append(filter_copy) # Add filters present in other but not in self to self @@ -2039,11 +2037,9 @@ class Tally(object): # Add nuclides present in self but not in other to other for nuclide in other_missing_nuclides: other._mean = \ - np.insert(other.mean, other.num_nuclides, - 0, axis=1) + np.insert(other.mean, other.num_nuclides, 0, axis=1) other._std_dev = \ - np.insert(other.std_dev, other.num_nuclides, - 0, axis=1) + np.insert(other.std_dev, other.num_nuclides, 0, axis=1) other.nuclides.append(nuclide) # Add nuclides present in other but not in self to self @@ -2068,10 +2064,8 @@ class Tally(object): self._mean = np.repeat(self.mean, other.num_scores, axis=2) self._std_dev = np.repeat(self.std_dev, other.num_scores, axis=2) - other._mean = \ - np.tile(other.mean, (1, 1, self.num_scores)) - other._std_dev = \ - np.tile(other.std_dev, (1, 1, self.num_scores)) + other._mean = np.tile(other.mean, (1, 1, self.num_scores)) + other._std_dev = np.tile(other.std_dev, (1, 1, self.num_scores)) # Add scores to each tally such that each tally contains the complete set # of scores necessary to perform an entrywise product. New scores added From 4655aecde69a22f828c598065ecf3c259096c3f3 Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Wed, 26 Apr 2017 12:58:27 -0400 Subject: [PATCH 8/8] removed additional unnecessary modifications --- openmc/tallies.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/openmc/tallies.py b/openmc/tallies.py index 59f9012cd5..e0283571c9 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -2062,8 +2062,7 @@ class Tally(object): # the tensor product across scores. if score_product == 'tensor': self._mean = np.repeat(self.mean, other.num_scores, axis=2) - self._std_dev = np.repeat(self.std_dev, other.num_scores, - axis=2) + self._std_dev = np.repeat(self.std_dev, other.num_scores, axis=2) other._mean = np.tile(other.mean, (1, 1, self.num_scores)) other._std_dev = np.tile(other.std_dev, (1, 1, self.num_scores)) @@ -2080,12 +2079,8 @@ class Tally(object): # Add scores present in self but not in other to other for score in other_missing_scores: - other._mean = \ - np.insert(other.mean, other.num_scores, 0, - axis=2) - other._std_dev = \ - np.insert(other.std_dev, other.num_scores, 0, - axis=2) + other._mean = np.insert(other.mean, other.num_scores, 0, axis=2) + other._std_dev = np.insert(other.std_dev, other.num_scores, 0, axis=2) other.scores.append(score) # Add scores present in other but not in self to self