mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
deepcopy method for FissionYield class
This commit is contained in:
parent
aea5628819
commit
2afefba206
1 changed files with 8 additions and 3 deletions
|
|
@ -13,7 +13,7 @@ try:
|
|||
except ImportError:
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from numpy import empty, searchsorted
|
||||
import numpy as np
|
||||
|
||||
from openmc.checkvalue import check_type
|
||||
|
||||
|
|
@ -470,7 +470,7 @@ class FissionYieldDistribution(Mapping):
|
|||
shared_prod = set.union(*(set(x) for x in fission_yields.values()))
|
||||
ordered_prod = sorted(shared_prod)
|
||||
|
||||
yield_matrix = empty((len(energies), len(shared_prod)))
|
||||
yield_matrix = np.empty((len(energies), len(shared_prod)))
|
||||
|
||||
for g_index, energy in enumerate(energies):
|
||||
prod_map = fission_yields[energy]
|
||||
|
|
@ -560,7 +560,7 @@ class FissionYieldDistribution(Mapping):
|
|||
return None
|
||||
|
||||
products = sorted(overlap)
|
||||
indices = searchsorted(self.products, products)
|
||||
indices = np.searchsorted(self.products, products)
|
||||
|
||||
# coerce back to dictionary to pass back to __init__
|
||||
new_yields = {}
|
||||
|
|
@ -681,6 +681,11 @@ class FissionYield(Mapping):
|
|||
return "<{} containing {} products and yields>".format(
|
||||
self.__class__.__name__, len(self))
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
result = FissionYield(self.products, np.copy(self.yields))
|
||||
memo[id(self)] = result
|
||||
return result
|
||||
|
||||
# Avoid greedy numpy operations like np.float64 * fission_yield
|
||||
# converting this to an array on the fly. Force __rmul__ and
|
||||
# __radd__. See issue #1492
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue