Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Chain.form_matrix to work with scipy 1.12 #2922

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions openmc/deplete/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,12 @@ def form_matrix(self, rates, fission_yields=None):
--------
:meth:`get_default_fission_yields`
"""
matrix = defaultdict(float)
reactions = set()

# Use DOK matrix as intermediate representation for matrix
n = len(self)
matrix = sp.dok_matrix((n, n))

if fission_yields is None:
fission_yields = self.get_default_fission_yields()

Expand Down Expand Up @@ -674,11 +677,8 @@ def form_matrix(self, rates, fission_yields=None):
# Clear set of reactions
reactions.clear()

# Use DOK matrix as intermediate representation, then convert to CSC and return
n = len(self)
matrix_dok = sp.dok_matrix((n, n))
dict.update(matrix_dok, matrix)
return matrix_dok.tocsc()
# Return CSC representation instead of DOK
return matrix.tocsc()

def form_rr_term(self, tr_rates, mats):
"""Function to form the transfer rate term matrices.
Expand Down Expand Up @@ -711,7 +711,9 @@ def form_rr_term(self, tr_rates, mats):
Sparse matrix representing transfer term.

"""
matrix = defaultdict(float)
# Use DOK as intermediate representation
n = len(self)
matrix = sp.dok_matrix((n, n))

for i, nuc in enumerate(self.nuclides):
elm = re.split(r'\d+', nuc.name)[0]
Expand All @@ -737,10 +739,9 @@ def form_rr_term(self, tr_rates, mats):
else:
matrix[i, i] = 0.0
#Nothing else is allowed
n = len(self)
matrix_dok = sp.dok_matrix((n, n))
dict.update(matrix_dok, matrix)
return matrix_dok.tocsc()

# Return CSC instead of DOK
return matrix.tocsc()

def get_branch_ratios(self, reaction="(n,gamma)"):
"""Return a dictionary with reaction branching ratios
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
# Dependencies
'python_requires': '>=3.7',
'install_requires': [
'numpy>=1.9', 'h5py', 'scipy<1.12', 'ipython', 'matplotlib',
'numpy>=1.9', 'h5py', 'scipy', 'ipython', 'matplotlib',
'pandas', 'lxml', 'uncertainties'
],
'extras_require': {
Expand Down