Skip to content

Commit

Permalink
Fix Chain.form_matrix to work with scipy 1.12 (#2922)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Mar 23, 2024
1 parent 23f19a0 commit ce7efa4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
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

0 comments on commit ce7efa4

Please sign in to comment.