mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Use six.add_metaclass to be compatible with Python 2 and 3
This commit is contained in:
parent
24af2829b9
commit
de009f4c34
12 changed files with 30 additions and 54 deletions
|
|
@ -1,14 +1,14 @@
|
|||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from six import add_metaclass
|
||||
|
||||
import openmc.data
|
||||
from openmc.mixin import EqualityMixin
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class AngleEnergy(EqualityMixin):
|
||||
"""Distribution in angle and energy of a secondary particle."""
|
||||
|
||||
__metaclass = ABCMeta
|
||||
|
||||
@abstractmethod
|
||||
def to_hdf5(self, group):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from collections import Iterable
|
|||
from numbers import Integral, Real
|
||||
from warnings import warn
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
||||
from .function import Tabulated1D, INTERPOLATION_SCHEME
|
||||
|
|
@ -11,11 +12,9 @@ import openmc.checkvalue as cv
|
|||
from openmc.mixin import EqualityMixin
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class EnergyDistribution(EqualityMixin):
|
||||
"""Abstract superclass for all energy distributions."""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from abc import ABCMeta, abstractmethod
|
|||
from collections import Iterable, Callable
|
||||
from numbers import Real, Integral
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -11,11 +12,9 @@ INTERPOLATION_SCHEME = {1: 'histogram', 2: 'linear-linear', 3: 'linear-log',
|
|||
4: 'log-linear', 5: 'log-log'}
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class Function1D(EqualityMixin):
|
||||
"""A function of one independent variable with HDF5 support."""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
@abstractmethod
|
||||
def __call__(self): pass
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
from abc import ABCMeta, abstractproperty
|
||||
from collections import Iterable, OrderedDict
|
||||
import copy
|
||||
from six import with_metaclass
|
||||
from numbers import Real, Integral
|
||||
import sys
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
_FILTER_TYPES = ['universe', 'material', 'cell', 'cellborn', 'surface',
|
||||
'mesh', 'energy', 'energyout', 'mu', 'polar', 'azimuthal',
|
||||
'distribcell', 'delayedgroup']
|
||||
|
|
@ -37,7 +33,8 @@ class FilterMeta(ABCMeta):
|
|||
**kwargs)
|
||||
|
||||
|
||||
class Filter(with_metaclass(FilterMeta, object)):
|
||||
@add_metaclass(FilterMeta)
|
||||
class Filter(object):
|
||||
"""Tally modifier that describes phase-space and other characteristics.
|
||||
|
||||
Parameters
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from numbers import Real, Integral
|
|||
from xml.etree import ElementTree as ET
|
||||
import sys
|
||||
|
||||
from six import ABCMeta
|
||||
import numpy as np
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -16,6 +17,7 @@ if sys.version_info[0] >= 3:
|
|||
basestring = str
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class Lattice(object):
|
||||
"""A repeating structure wherein each element is a universe.
|
||||
|
||||
|
|
@ -42,10 +44,6 @@ class Lattice(object):
|
|||
of the lattice
|
||||
|
||||
"""
|
||||
|
||||
# This is an abstract class which cannot be instantiated
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
def __init__(self, lattice_id=None, name=''):
|
||||
# Initialize Lattice class attributes
|
||||
self.id = lattice_id
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import sys
|
|||
import copy
|
||||
import abc
|
||||
|
||||
from six import ABCMeta
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
|
|
@ -28,6 +29,7 @@ MDGXS_TYPES = ['delayed-nu-fission',
|
|||
MAX_DELAYED_GROUPS = 8
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class MDGXS(MGXS):
|
||||
"""An abstract multi-delayed-group cross section for some energy and delayed
|
||||
group structures within some spatial domain.
|
||||
|
|
@ -117,10 +119,6 @@ class MDGXS(MGXS):
|
|||
The key used to index multi-group cross sections in an HDF5 data store
|
||||
|
||||
"""
|
||||
|
||||
# This is an abstract class which cannot be instantiated
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
def __init__(self, domain=None, domain_type=None, energy_groups=None,
|
||||
delayed_groups=None, by_nuclide=False, name=''):
|
||||
super(MDGXS, self).__init__(domain, domain_type, energy_groups,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import copy
|
|||
import abc
|
||||
import itertools
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
|
|
@ -61,6 +62,7 @@ _DOMAINS = (openmc.Cell,
|
|||
openmc.Mesh)
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class MGXS(object):
|
||||
"""An abstract multi-group cross section for some energy group structure
|
||||
within some spatial domain.
|
||||
|
|
@ -145,10 +147,6 @@ class MGXS(object):
|
|||
The key used to index multi-group cross sections in an HDF5 data store
|
||||
|
||||
"""
|
||||
|
||||
# This is an abstract class which cannot be instantiated
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
def __init__(self, domain=None, domain_type=None,
|
||||
energy_groups=None, by_nuclide=False, name=''):
|
||||
self._name = ''
|
||||
|
|
@ -1530,7 +1528,7 @@ class MGXS(object):
|
|||
|
||||
# Override energy groups bounds with indices
|
||||
all_groups = np.arange(self.num_groups, 0, -1, dtype=np.int)
|
||||
all_groups = np.repeat(all_groups, len(query_nuclides))
|
||||
all_groups = np.repeat(all_groups, len(query_nuclides))
|
||||
if 'energy low [MeV]' in df and 'energyout low [MeV]' in df:
|
||||
df.rename(columns={'energy low [MeV]': 'group in'},
|
||||
inplace=True)
|
||||
|
|
@ -1616,6 +1614,7 @@ class MGXS(object):
|
|||
return 'cm^-1' if xs_type == 'macro' else 'barns'
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class MatrixMGXS(MGXS):
|
||||
"""An abstract multi-group cross section for some energy group structure
|
||||
within some spatial domain. This class is specifically intended for
|
||||
|
|
@ -1703,10 +1702,6 @@ class MatrixMGXS(MGXS):
|
|||
The key used to index multi-group cross sections in an HDF5 data store
|
||||
|
||||
"""
|
||||
|
||||
# This is an abstract class which cannot be instantiated
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@property
|
||||
def filters(self):
|
||||
# Create the non-domain specific Filters for the Tallies
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from heapq import heappush, heappop
|
|||
from math import pi, sin, cos, floor, log10, sqrt
|
||||
from abc import ABCMeta, abstractproperty, abstractmethod
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
try:
|
||||
import scipy.spatial
|
||||
|
|
@ -95,6 +96,7 @@ class TRISO(openmc.Cell):
|
|||
k_min:k_max+1, j_min:j_max+1, i_min:i_max+1]))
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class _Domain(object):
|
||||
"""Container in which to pack particles.
|
||||
|
||||
|
|
@ -123,9 +125,6 @@ class _Domain(object):
|
|||
Volume of the container.
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self, particle_radius, center=[0., 0., 0.]):
|
||||
self._cell_length = None
|
||||
self._limits = None
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
from abc import ABCMeta, abstractmethod
|
||||
from collections import Iterable
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
||||
from openmc.checkvalue import check_type
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class Region(object):
|
||||
"""Region of space that can be assigned to a cell.
|
||||
|
||||
|
|
@ -16,9 +18,6 @@ class Region(object):
|
|||
created through operators of the Surface and Region classes.
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __and__(self, other):
|
||||
return Intersection(self, other)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from numbers import Real
|
|||
import sys
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -14,6 +15,7 @@ if sys.version_info[0] >= 3:
|
|||
basestring = str
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class UnitSphere(object):
|
||||
"""Distribution of points on the unit sphere.
|
||||
|
||||
|
|
@ -31,9 +33,6 @@ class UnitSphere(object):
|
|||
Direction from which polar angle is measured
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self, reference_uvw=None):
|
||||
self._reference_uvw = None
|
||||
if reference_uvw is not None:
|
||||
|
|
@ -184,6 +183,7 @@ class Monodirectional(UnitSphere):
|
|||
return element
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class Spatial(object):
|
||||
"""Distribution of locations in three-dimensional Euclidean space.
|
||||
|
||||
|
|
@ -191,9 +191,6 @@ class Spatial(object):
|
|||
distributions of source sites.
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from numbers import Real
|
|||
import sys
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -16,6 +17,7 @@ _INTERPOLATION_SCHEMES = ['histogram', 'linear-linear', 'linear-log',
|
|||
'log-linear', 'log-log']
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class Univariate(EqualityMixin):
|
||||
"""Probability distribution of a single random variable.
|
||||
|
||||
|
|
@ -23,9 +25,6 @@ class Univariate(EqualityMixin):
|
|||
specific probability distribution.
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from xml.etree import ElementTree as ET
|
|||
import sys
|
||||
from math import sqrt
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
||||
from openmc.checkvalue import check_type, check_value, check_greater_than
|
||||
|
|
@ -642,6 +643,7 @@ class ZPlane(Plane):
|
|||
return point[2] - self.z0
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class Cylinder(Surface):
|
||||
"""A cylinder whose length is parallel to the x-, y-, or z-axis.
|
||||
|
||||
|
|
@ -677,9 +679,6 @@ class Cylinder(Surface):
|
|||
Type of the surface
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
R=1., name=''):
|
||||
super(Cylinder, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
|
@ -1210,7 +1209,7 @@ class Sphere(Surface):
|
|||
z = point[2] - self.z0
|
||||
return x**2 + y**2 + z**2 - self.r**2
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class Cone(Surface):
|
||||
"""A conical surface parallel to the x-, y-, or z-axis.
|
||||
|
||||
|
|
@ -1257,9 +1256,6 @@ class Cone(Surface):
|
|||
Type of the surface
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=0., y0=0., z0=0., R2=1., name=''):
|
||||
super(Cone, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue