Fix test error and deprecation warnings from numpy 1.25 (#2573)

This commit is contained in:
Paul Romano 2023-06-22 13:26:22 -05:00 committed by GitHub
parent 8ce5c7366c
commit 93a0855c7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 9 deletions

View file

@ -1074,13 +1074,12 @@ class CMFDRun:
# Get acceleration map, otherwise set all regions to be accelerated
if self._mesh.map is not None:
check_length('CMFD coremap', self._mesh.map,
np.product(self._indices[0:3]))
np.prod(self._indices[:3]))
if openmc.lib.master():
self._coremap = np.array(self._mesh.map)
else:
if openmc.lib.master():
self._coremap = np.ones((np.product(self._indices[0:3])),
dtype=int)
self._coremap = np.ones(np.prod(self._indices[:3]), dtype=int)
# Check CMFD tallies accummulated before feedback turned on
if self._feedback and self._solver_begin < self._tally_begin:
@ -1434,7 +1433,7 @@ class CMFDRun:
# nfissxs
# Calculate volume
vol = np.product(self._hxyz, axis=3)
vol = np.prod(self._hxyz, axis=3)
# Reshape phi by number of groups
phi = self._phi.reshape((n, ng))

View file

@ -263,10 +263,10 @@ class Model:
model.materials = openmc.Materials.from_xml_element(root.find('materials'))
model.geometry = openmc.Geometry.from_xml_element(root.find('geometry'), model.materials)
if root.find('tallies'):
if root.find('tallies') is not None:
model.tallies = openmc.Tallies.from_xml_element(root.find('tallies'), meshes)
if root.find('plots'):
if root.find('plots') is not None:
model.plots = openmc.Plots.from_xml_element(root.find('plots'))
return model
@ -575,10 +575,15 @@ class Model:
cell_id = int(name.split()[1])
cell = cells[cell_id]
if cell.fill_type in ('material', 'distribmat'):
cell.temperature = group['temperature'][()]
temperature = group['temperature'][()]
cell.temperature = temperature
if self.is_initialized:
lib_cell = openmc.lib.cells[cell_id]
lib_cell.set_temperature(group['temperature'][()])
if temperature.size > 1:
for i, T in enumerate(temperature):
lib_cell.set_temperature(T, i)
else:
lib_cell.set_temperature(temperature[0])
# Make sure number of materials matches
mats_group = fh['materials']

View file

@ -2,6 +2,7 @@
from pathlib import Path
import shutil
import sys
import numpy as np
import pytest
@ -45,6 +46,7 @@ def model():
return openmc.Model(geometry, materials, settings)
@pytest.mark.skipif(sys.version_info < (3, 9), reason="Requires Python 3.9+")
@pytest.mark.parametrize("rate, dest_mat, power, ref_result", [
(1e-5, None, 0.0, 'no_depletion_only_removal'),
(-1e-5, None, 0.0, 'no_depletion_only_feed'),

View file

@ -181,7 +181,7 @@ class CMFDTestHarness(TestHarness):
outstr += '\ncmfd openmc source comparison\n'
outstr += '\n'.join(['{:.6E}'.format(x) for x in cmfd_run.src_cmp])
outstr += '\ncmfd source\n'
cmfdsrc = np.reshape(cmfd_run.cmfd_src, np.product(cmfd_run.indices),
cmfdsrc = np.reshape(cmfd_run.cmfd_src, np.prod(cmfd_run.indices),
order='F')
outstr += '\n'.join(['{:.6E}'.format(x) for x in cmfdsrc])
outstr += '\n'