mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Explicitly use int(floor(...)) for Python 2 compatibility
This commit is contained in:
parent
2027920fdd
commit
68a01b8fc1
5 changed files with 12 additions and 25 deletions
|
|
@ -27,8 +27,9 @@ except ImportError:
|
|||
MOCK_MODULES = ['numpy', 'numpy.polynomial', 'numpy.polynomial.polynomial',
|
||||
'numpy.ctypeslib', 'scipy', 'scipy.sparse', 'scipy.interpolate',
|
||||
'scipy.integrate', 'scipy.optimize', 'scipy.special',
|
||||
'scipy.stats', 'h5py', 'pandas', 'uncertainties', 'matplotlib',
|
||||
'matplotlib.pyplot','openmoc', 'openmc.data.reconstruct']
|
||||
'scipy.stats', 'scipy.spatial', 'h5py', 'pandas', 'uncertainties',
|
||||
'matplotlib', 'matplotlib.pyplot','openmoc',
|
||||
'openmc.data.reconstruct']
|
||||
sys.modules.update((mod_name, MagicMock()) for mod_name in MOCK_MODULES)
|
||||
|
||||
import numpy as np
|
||||
|
|
|
|||
|
|
@ -607,12 +607,12 @@ class RectLattice(Lattice):
|
|||
element coordinate system
|
||||
|
||||
"""
|
||||
ix = floor((point[0] - self.lower_left[0])/self.pitch[0])
|
||||
iy = floor((point[1] - self.lower_left[1])/self.pitch[1])
|
||||
ix = int(floor((point[0] - self.lower_left[0])/self.pitch[0]))
|
||||
iy = int(floor((point[1] - self.lower_left[1])/self.pitch[1]))
|
||||
if self.ndim == 2:
|
||||
idx = (ix, iy)
|
||||
else:
|
||||
iz = floor((point[2] - self.lower_left[2])/self.pitch[2])
|
||||
iz = int(floor((point[2] - self.lower_left[2])/self.pitch[2]))
|
||||
idx = (ix, iy, iz)
|
||||
return idx, self.get_local_coordinates(point, idx)
|
||||
|
||||
|
|
@ -1019,10 +1019,10 @@ class HexLattice(Lattice):
|
|||
iz = 1
|
||||
else:
|
||||
z = point[2] - self.center[2]
|
||||
iz = floor(z/self.pitch[1] + 0.5*self.num_axial)
|
||||
iz = int(floor(z/self.pitch[1] + 0.5*self.num_axial))
|
||||
alpha = y - x/sqrt(3.)
|
||||
ix = floor(x/(sqrt(0.75) * self.pitch[0]))
|
||||
ia = floor(alpha/self.pitch[0])
|
||||
ix = int(floor(x/(sqrt(0.75) * self.pitch[0])))
|
||||
ia = int(floor(alpha/self.pitch[0]))
|
||||
|
||||
# Check four lattice elements to see which one is closest based on local
|
||||
# coordinates
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import itertools
|
|||
|
||||
from six import add_metaclass, string_types
|
||||
import numpy as np
|
||||
import h5py
|
||||
|
||||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -1682,13 +1683,8 @@ class MGXS(object):
|
|||
ValueError
|
||||
When this method is called before the multi-group cross section is
|
||||
computed from tally data.
|
||||
ImportError
|
||||
When h5py is not installed.
|
||||
|
||||
"""
|
||||
|
||||
import h5py
|
||||
|
||||
# Make directory if it does not exist
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
|
|
|
|||
|
|
@ -12,11 +12,7 @@ from abc import ABCMeta, abstractproperty, abstractmethod
|
|||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
try:
|
||||
import scipy.spatial
|
||||
_SCIPY_AVAILABLE = True
|
||||
except ImportError:
|
||||
_SCIPY_AVAILABLE = False
|
||||
import scipy.spatial
|
||||
|
||||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -742,7 +738,7 @@ def _close_random_pack(domain, particles, contraction_rate):
|
|||
outer_pf = (4/3 * pi * (outer_diameter[0]/2)**3 * n_particles /
|
||||
domain.volume)
|
||||
|
||||
j = floor(-log10(outer_pf - inner_pf))
|
||||
j = int(floor(-log10(outer_pf - inner_pf)))
|
||||
outer_diameter[0] = (outer_diameter[0] - 0.5**j * contraction_rate *
|
||||
initial_outer_diameter / n_particles)
|
||||
|
||||
|
|
@ -837,10 +833,6 @@ def _close_random_pack(domain, particles, contraction_rate):
|
|||
if rods:
|
||||
inner_diameter[0] = rods[0][0]
|
||||
|
||||
if not _SCIPY_AVAILABLE:
|
||||
raise ImportError('SciPy must be installed to perform '
|
||||
'close random packing.')
|
||||
|
||||
n_particles = len(particles)
|
||||
diameter = 2*domain.particle_radius
|
||||
|
||||
|
|
|
|||
|
|
@ -1508,8 +1508,6 @@ class Tally(IDManagerMixin):
|
|||
------
|
||||
KeyError
|
||||
When this method is called before the Tally is populated with data
|
||||
ImportError
|
||||
When Pandas can not be found on the caller's system
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue