mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Use six.string_types instead of basestring
This commit is contained in:
parent
de009f4c34
commit
5a126d086e
30 changed files with 154 additions and 209 deletions
|
|
@ -2,14 +2,13 @@ import sys
|
|||
import copy
|
||||
from collections import Iterable
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
from openmc.filter import _FILTER_TYPES
|
||||
import openmc.checkvalue as cv
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
# Acceptable tally arithmetic binary operations
|
||||
_TALLY_ARITHMETIC_OPS = ['+', '-', '*', '/', '^']
|
||||
|
|
@ -86,18 +85,18 @@ class CrossScore(object):
|
|||
@left_score.setter
|
||||
def left_score(self, left_score):
|
||||
cv.check_type('left_score', left_score,
|
||||
(basestring, CrossScore, AggregateScore))
|
||||
string_types + (CrossScore, AggregateScore))
|
||||
self._left_score = left_score
|
||||
|
||||
@right_score.setter
|
||||
def right_score(self, right_score):
|
||||
cv.check_type('right_score', right_score,
|
||||
(basestring, CrossScore, AggregateScore))
|
||||
string_types + (CrossScore, AggregateScore))
|
||||
self._right_score = right_score
|
||||
|
||||
@binary_op.setter
|
||||
def binary_op(self, binary_op):
|
||||
cv.check_type('binary_op', binary_op, basestring)
|
||||
cv.check_type('binary_op', binary_op, string_types)
|
||||
cv.check_value('binary_op', binary_op, _TALLY_ARITHMETIC_OPS)
|
||||
self._binary_op = binary_op
|
||||
|
||||
|
|
@ -202,7 +201,7 @@ class CrossNuclide(object):
|
|||
|
||||
@binary_op.setter
|
||||
def binary_op(self, binary_op):
|
||||
cv.check_type('binary_op', binary_op, basestring)
|
||||
cv.check_type('binary_op', binary_op, string_types)
|
||||
cv.check_value('binary_op', binary_op, _TALLY_ARITHMETIC_OPS)
|
||||
self._binary_op = binary_op
|
||||
|
||||
|
|
@ -343,7 +342,7 @@ class CrossFilter(object):
|
|||
|
||||
@binary_op.setter
|
||||
def binary_op(self, binary_op):
|
||||
cv.check_type('binary_op', binary_op, basestring)
|
||||
cv.check_type('binary_op', binary_op, string_types)
|
||||
cv.check_value('binary_op', binary_op, _TALLY_ARITHMETIC_OPS)
|
||||
self._binary_op = binary_op
|
||||
|
||||
|
|
@ -495,12 +494,12 @@ class AggregateScore(object):
|
|||
|
||||
@scores.setter
|
||||
def scores(self, scores):
|
||||
cv.check_iterable_type('scores', scores, basestring)
|
||||
cv.check_iterable_type('scores', scores, string_types)
|
||||
self._scores = scores
|
||||
|
||||
@aggregate_op.setter
|
||||
def aggregate_op(self, aggregate_op):
|
||||
cv.check_type('aggregate_op', aggregate_op, (basestring, CrossScore))
|
||||
cv.check_type('aggregate_op', aggregate_op, string_types +(CrossScore,))
|
||||
cv.check_value('aggregate_op', aggregate_op, _TALLY_AGGREGATE_OPS)
|
||||
self._aggregate_op = aggregate_op
|
||||
|
||||
|
|
@ -575,12 +574,12 @@ class AggregateNuclide(object):
|
|||
@nuclides.setter
|
||||
def nuclides(self, nuclides):
|
||||
cv.check_iterable_type('nuclides', nuclides,
|
||||
(basestring, openmc.Nuclide, CrossNuclide))
|
||||
string_types + (openmc.Nuclide, CrossNuclide))
|
||||
self._nuclides = nuclides
|
||||
|
||||
@aggregate_op.setter
|
||||
def aggregate_op(self, aggregate_op):
|
||||
cv.check_type('aggregate_op', aggregate_op, basestring)
|
||||
cv.check_type('aggregate_op', aggregate_op, string_types)
|
||||
cv.check_value('aggregate_op', aggregate_op, _TALLY_AGGREGATE_OPS)
|
||||
self._aggregate_op = aggregate_op
|
||||
|
||||
|
|
@ -711,7 +710,7 @@ class AggregateFilter(object):
|
|||
|
||||
@aggregate_op.setter
|
||||
def aggregate_op(self, aggregate_op):
|
||||
cv.check_type('aggregate_op', aggregate_op, basestring)
|
||||
cv.check_type('aggregate_op', aggregate_op, string_types)
|
||||
cv.check_value('aggregate_op', aggregate_op, _TALLY_AGGREGATE_OPS)
|
||||
self._aggregate_op = aggregate_op
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from xml.etree import ElementTree as ET
|
|||
import sys
|
||||
import warnings
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
|
|
@ -12,9 +13,6 @@ import openmc.checkvalue as cv
|
|||
from openmc.surface import Halfspace
|
||||
from openmc.region import Region, Intersection, Complement
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
# A static variable for auto-generated Cell IDs
|
||||
AUTO_CELL_ID = 10000
|
||||
|
|
@ -243,7 +241,7 @@ class Cell(object):
|
|||
@name.setter
|
||||
def name(self, name):
|
||||
if name is not None:
|
||||
cv.check_type('cell name', name, basestring)
|
||||
cv.check_type('cell name', name, string_types)
|
||||
self._name = name
|
||||
else:
|
||||
self._name = ''
|
||||
|
|
@ -251,7 +249,7 @@ class Cell(object):
|
|||
@fill.setter
|
||||
def fill(self, fill):
|
||||
if fill is not None:
|
||||
if isinstance(fill, basestring):
|
||||
if isinstance(fill, string_types):
|
||||
if fill.strip().lower() != 'void':
|
||||
msg = 'Unable to set Cell ID="{0}" to use a non-Material ' \
|
||||
'or Universe fill "{1}"'.format(self._id, fill)
|
||||
|
|
@ -336,7 +334,7 @@ class Cell(object):
|
|||
@distribcell_paths.setter
|
||||
def distribcell_paths(self, distribcell_paths):
|
||||
cv.check_iterable_type('distribcell_paths', distribcell_paths,
|
||||
basestring)
|
||||
string_types)
|
||||
self._distribcell_paths = distribcell_paths
|
||||
|
||||
def add_surface(self, surface, halfspace):
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@ from numbers import Real, Integral
|
|||
from xml.etree import ElementTree as ET
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
|
||||
from openmc.clean_xml import clean_xml_indentation
|
||||
from openmc.checkvalue import (check_type, check_length, check_value,
|
||||
check_greater_than, check_less_than)
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
class CMFDMesh(object):
|
||||
"""A structured Cartesian mesh used for Coarse Mesh Finite Difference (CMFD)
|
||||
|
|
@ -339,7 +338,7 @@ class CMFD(object):
|
|||
|
||||
@display.setter
|
||||
def display(self, display):
|
||||
check_type('CMFD display', display, basestring)
|
||||
check_type('CMFD display', display, string_types)
|
||||
check_value('CMFD display', display,
|
||||
['balance', 'dominance', 'entropy', 'source'])
|
||||
self._display = display
|
||||
|
|
|
|||
|
|
@ -20,15 +20,12 @@ from os import SEEK_CUR
|
|||
import struct
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
from openmc.mixin import EqualityMixin
|
||||
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
def ascii_to_binary(ascii_file, binary_file):
|
||||
"""Convert an ACE file in ASCII format (type 1) to binary format (type 2).
|
||||
|
||||
|
|
@ -156,7 +153,7 @@ class Library(EqualityMixin):
|
|||
"""
|
||||
|
||||
def __init__(self, filename, table_names=None, verbose=False):
|
||||
if isinstance(table_names, basestring):
|
||||
if isinstance(table_names, string_types):
|
||||
table_names = [table_names]
|
||||
if table_names is not None:
|
||||
table_names = set(table_names)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,6 @@ from .function import Function1D, Tabulated1D, Polynomial, Sum
|
|||
import openmc.checkvalue as cv
|
||||
from openmc.mixin import EqualityMixin
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
def _extract_458_data(filename):
|
||||
"""Read an ENDF file and extract the MF=1, MT=458 values.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from itertools import chain
|
|||
from numbers import Integral, Real
|
||||
from warnings import warn
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
import h5py
|
||||
|
||||
|
|
@ -18,9 +19,6 @@ from .urr import ProbabilityTables
|
|||
import openmc.checkvalue as cv
|
||||
from openmc.mixin import EqualityMixin
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
def _get_metadata(zaid, metastable_scheme='nndc'):
|
||||
"""Return basic identifying data for a nuclide with a given ZAID.
|
||||
|
|
@ -226,7 +224,7 @@ class IncidentNeutron(EqualityMixin):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
cv.check_type('name', name, basestring)
|
||||
cv.check_type('name', name, string_types)
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
|
|
@ -277,7 +275,7 @@ class IncidentNeutron(EqualityMixin):
|
|||
def urr(self, urr):
|
||||
cv.check_type('probability table dictionary', urr, MutableMapping)
|
||||
for key, value in urr:
|
||||
cv.check_type('probability table temperature', key, basestring)
|
||||
cv.check_type('probability table temperature', key, string_types)
|
||||
cv.check_type('probability tables', value, ProbabilityTables)
|
||||
self._urr = urr
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from collections import Iterable
|
|||
from numbers import Real
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -9,9 +10,6 @@ from openmc.mixin import EqualityMixin
|
|||
from .function import Tabulated1D, Polynomial, Function1D
|
||||
from .angle_energy import AngleEnergy
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
class Product(EqualityMixin):
|
||||
"""Secondary particle emitted in a nuclear reaction
|
||||
|
|
@ -114,7 +112,7 @@ class Product(EqualityMixin):
|
|||
|
||||
@particle.setter
|
||||
def particle(self, particle):
|
||||
cv.check_type('product particle type', particle, basestring)
|
||||
cv.check_type('product particle type', particle, string_types)
|
||||
self._particle = particle
|
||||
|
||||
@yield_.setter
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from copy import deepcopy
|
|||
from numbers import Real, Integral
|
||||
from warnings import warn
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -349,7 +350,7 @@ class Reaction(EqualityMixin):
|
|||
def xs(self, xs):
|
||||
cv.check_type('reaction cross section dictionary', xs, MutableMapping)
|
||||
for key, value in xs.items():
|
||||
cv.check_type('reaction cross section temperature', key, basestring)
|
||||
cv.check_type('reaction cross section temperature', key, string_types)
|
||||
cv.check_type('reaction cross section', value, Function1D)
|
||||
self._xs = xs
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
import re
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
|
||||
import openmc
|
||||
from openmc.checkvalue import check_type, check_length
|
||||
from openmc.data import NATURAL_ABUNDANCE
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
|
||||
class Element(object):
|
||||
"""A natural element used in a material via <element>. Internally, OpenMC will
|
||||
|
|
@ -43,7 +41,7 @@ class Element(object):
|
|||
return False
|
||||
else:
|
||||
return True
|
||||
elif isinstance(other, basestring) and other == self.name:
|
||||
elif isinstance(other, string_types) and other == self.name:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
@ -78,7 +76,7 @@ class Element(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
check_type('element name', name, basestring)
|
||||
check_type('element name', name, string_types)
|
||||
check_length('element name', name, 1, 2)
|
||||
self._name = name
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ import subprocess
|
|||
from numbers import Integral
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
from six import string_types
|
||||
|
||||
|
||||
def _run(command, output, cwd):
|
||||
|
|
@ -89,7 +88,7 @@ def run(particles=None, threads=None, geometry_debug=False,
|
|||
if geometry_debug:
|
||||
post_args += '-g '
|
||||
|
||||
if isinstance(restart_file, basestring):
|
||||
if isinstance(restart_file, string_types):
|
||||
post_args += '-r {0} '.format(restart_file)
|
||||
|
||||
if tracks:
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
from __future__ import division
|
||||
|
||||
import abc
|
||||
from abc import ABCMeta
|
||||
from collections import OrderedDict, Iterable
|
||||
from math import sqrt, floor
|
||||
from numbers import Real, Integral
|
||||
from xml.etree import ElementTree as ET
|
||||
import sys
|
||||
|
||||
from six import ABCMeta
|
||||
from six import add_metaclass, string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
import openmc
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class Lattice(object):
|
||||
|
|
@ -104,7 +101,7 @@ class Lattice(object):
|
|||
@name.setter
|
||||
def name(self, name):
|
||||
if name is not None:
|
||||
cv.check_type('lattice name', name, basestring)
|
||||
cv.check_type('lattice name', name, string_types)
|
||||
self._name = name
|
||||
else:
|
||||
self._name = ''
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import sys
|
||||
|
||||
from openmc.checkvalue import check_type
|
||||
from six import string_types
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
from openmc.checkvalue import check_type
|
||||
|
||||
|
||||
class Macroscopic(object):
|
||||
|
|
@ -34,7 +33,7 @@ class Macroscopic(object):
|
|||
return False
|
||||
else:
|
||||
return True
|
||||
elif isinstance(other, basestring) and other == self.name:
|
||||
elif isinstance(other, string_types) and other == self.name:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
@ -55,5 +54,5 @@ class Macroscopic(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
check_type('name', name, basestring)
|
||||
check_type('name', name, string_types)
|
||||
self._name = name
|
||||
|
|
|
|||
|
|
@ -5,14 +5,13 @@ import warnings
|
|||
from xml.etree import ElementTree as ET
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
|
||||
import openmc
|
||||
import openmc.data
|
||||
import openmc.checkvalue as cv
|
||||
from openmc.clean_xml import sort_xml_elements, clean_xml_indentation
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
# A static variable for auto-generated Material IDs
|
||||
AUTO_MATERIAL_ID = 10000
|
||||
|
|
@ -207,7 +206,7 @@ class Material(object):
|
|||
def name(self, name):
|
||||
if name is not None:
|
||||
cv.check_type('name for Material ID="{0}"'.format(self._id),
|
||||
name, basestring)
|
||||
name, string_types)
|
||||
self._name = name
|
||||
else:
|
||||
self._name = ''
|
||||
|
|
@ -256,7 +255,7 @@ class Material(object):
|
|||
warnings.warn('This feature is not yet implemented in a release '
|
||||
'version of openmc')
|
||||
|
||||
if not isinstance(filename, basestring) and filename is not None:
|
||||
if not isinstance(filename, string_types) and filename is not None:
|
||||
msg = 'Unable to add OTF material file to Material ID="{0}" with a ' \
|
||||
'non-string name "{1}"'.format(self._id, filename)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -290,7 +289,7 @@ class Material(object):
|
|||
'macroscopic data-set has already been added'.format(self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
if not isinstance(nuclide, (openmc.Nuclide, basestring)):
|
||||
if not isinstance(nuclide, string_types + (openmc.Nuclide,)):
|
||||
msg = 'Unable to add a Nuclide to Material ID="{0}" with a ' \
|
||||
'non-Nuclide value "{1}"'.format(self._id, nuclide)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -355,7 +354,7 @@ class Material(object):
|
|||
'has already been added'.format(self._id, macroscopic)
|
||||
raise ValueError(msg)
|
||||
|
||||
if not isinstance(macroscopic, (openmc.Macroscopic, basestring)):
|
||||
if not isinstance(macroscopic, string_types + (openmc.Macroscopic,)):
|
||||
msg = 'Unable to add a Macroscopic to Material ID="{0}" with a ' \
|
||||
'non-Macroscopic value "{1}"'.format(self._id, macroscopic)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -425,7 +424,7 @@ class Material(object):
|
|||
'macroscopic data-set has already been added'.format(self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
if not isinstance(element, (openmc.Element, basestring)):
|
||||
if not isinstance(element, string_types + (openmc.Element,)):
|
||||
msg = 'Unable to add an Element to Material ID="{0}" with a ' \
|
||||
'non-Element value "{1}"'.format(self._id, element)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -490,7 +489,7 @@ class Material(object):
|
|||
'macroscopic data-set has already been added'.format(self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
if not isinstance(name, basestring):
|
||||
if not isinstance(name, string_types):
|
||||
msg = 'Unable to add an S(a,b) table to Material ID="{0}" with a ' \
|
||||
'non-string table name "{1}"'.format(self._id, name)
|
||||
raise ValueError(msg)
|
||||
|
|
|
|||
|
|
@ -3,15 +3,13 @@ from numbers import Real, Integral
|
|||
from xml.etree import ElementTree as ET
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
import openmc
|
||||
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
# "Static" variable for auto-generated and Mesh IDs
|
||||
AUTO_MESH_ID = 10000
|
||||
|
||||
|
|
@ -131,7 +129,7 @@ class Mesh(object):
|
|||
def name(self, name):
|
||||
if name is not None:
|
||||
cv.check_type('name for mesh ID="{0}"'.format(self._id),
|
||||
name, basestring)
|
||||
name, string_types)
|
||||
self._name = name
|
||||
else:
|
||||
self._name = ''
|
||||
|
|
@ -139,7 +137,7 @@ class Mesh(object):
|
|||
@type.setter
|
||||
def type(self, meshtype):
|
||||
cv.check_type('type for mesh ID="{0}"'.format(self._id),
|
||||
meshtype, basestring)
|
||||
meshtype, string_types)
|
||||
cv.check_value('type for mesh ID="{0}"'.format(self._id),
|
||||
meshtype, ['regular'])
|
||||
self._type = meshtype
|
||||
|
|
|
|||
|
|
@ -8,10 +8,6 @@ import numpy as np
|
|||
import openmc.checkvalue as cv
|
||||
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
class EnergyGroups(object):
|
||||
"""An energy groups structure used for multi-group cross-sections.
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from numbers import Integral
|
|||
from collections import OrderedDict
|
||||
from warnings import warn
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
|
|
@ -14,10 +15,6 @@ import openmc.checkvalue as cv
|
|||
from openmc.tallies import ESTIMATOR_TYPES
|
||||
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
class Library(object):
|
||||
"""A multi-energy-group and multi-delayed-group cross section library for
|
||||
some energy group structure.
|
||||
|
|
@ -259,7 +256,7 @@ class Library(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
cv.check_type('name', name, basestring)
|
||||
cv.check_type('name', name, string_types)
|
||||
self._name = name
|
||||
|
||||
@mgxs_types.setter
|
||||
|
|
@ -268,7 +265,7 @@ class Library(object):
|
|||
if mgxs_types == 'all':
|
||||
self._mgxs_types = all_mgxs_types
|
||||
else:
|
||||
cv.check_iterable_type('mgxs_types', mgxs_types, basestring)
|
||||
cv.check_iterable_type('mgxs_types', mgxs_types, string_types)
|
||||
for mgxs_type in mgxs_types:
|
||||
cv.check_value('mgxs_type', mgxs_type, all_mgxs_types)
|
||||
self._mgxs_types = mgxs_types
|
||||
|
|
@ -730,8 +727,8 @@ class Library(object):
|
|||
'since a statepoint has not yet been loaded'
|
||||
raise ValueError(msg)
|
||||
|
||||
cv.check_type('filename', filename, basestring)
|
||||
cv.check_type('directory', directory, basestring)
|
||||
cv.check_type('filename', filename, string_types)
|
||||
cv.check_type('directory', directory, string_types)
|
||||
|
||||
import h5py
|
||||
|
||||
|
|
@ -773,8 +770,8 @@ class Library(object):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_type('filename', filename, basestring)
|
||||
cv.check_type('directory', directory, basestring)
|
||||
cv.check_type('filename', filename, string_types)
|
||||
cv.check_type('directory', directory, string_types)
|
||||
|
||||
# Make directory if it does not exist
|
||||
if not os.path.exists(directory):
|
||||
|
|
@ -808,8 +805,8 @@ class Library(object):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_type('filename', filename, basestring)
|
||||
cv.check_type('directory', directory, basestring)
|
||||
cv.check_type('filename', filename, string_types)
|
||||
cv.check_type('directory', directory, string_types)
|
||||
|
||||
# Make directory if it does not exist
|
||||
if not os.path.exists(directory):
|
||||
|
|
@ -883,8 +880,8 @@ class Library(object):
|
|||
|
||||
cv.check_type('domain', domain, (openmc.Material, openmc.Cell,
|
||||
openmc.Universe, openmc.Mesh))
|
||||
cv.check_type('xsdata_name', xsdata_name, basestring)
|
||||
cv.check_type('nuclide', nuclide, basestring)
|
||||
cv.check_type('xsdata_name', xsdata_name, string_types)
|
||||
cv.check_type('nuclide', nuclide, string_types)
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
cv.check_type('order', order, (type(None), Integral))
|
||||
if order is not None:
|
||||
|
|
@ -1069,7 +1066,7 @@ class Library(object):
|
|||
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
if xsdata_names is not None:
|
||||
cv.check_iterable_type('xsdata_names', xsdata_names, basestring)
|
||||
cv.check_iterable_type('xsdata_names', xsdata_names, string_types)
|
||||
|
||||
# If gathering material-specific data, set the xs_type to macro
|
||||
if not self.by_nuclide:
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import warnings
|
|||
import os
|
||||
import sys
|
||||
import copy
|
||||
import abc
|
||||
from abc import ABCMeta
|
||||
|
||||
from six import ABCMeta
|
||||
from six import add_metaclass, string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
|
|
@ -16,8 +16,6 @@ from openmc.mgxs import MGXS
|
|||
from openmc.mgxs.mgxs import _DOMAIN_TO_FILTER
|
||||
import openmc.checkvalue as cv
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
# Supported cross section types
|
||||
MDGXS_TYPES = ['delayed-nu-fission',
|
||||
|
|
@ -320,7 +318,7 @@ class MDGXS(MGXS):
|
|||
filter_bins = []
|
||||
|
||||
# Construct a collection of the domain filter bins
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral,
|
||||
max_depth=3)
|
||||
for subdomain in subdomains:
|
||||
|
|
@ -328,7 +326,7 @@ class MDGXS(MGXS):
|
|||
filter_bins.append((subdomain,))
|
||||
|
||||
# Construct list of energy group bounds tuples for all requested groups
|
||||
if not isinstance(groups, basestring):
|
||||
if not isinstance(groups, string_types):
|
||||
cv.check_iterable_type('groups', groups, Integral)
|
||||
for group in groups:
|
||||
filters.append(openmc.EnergyFilter)
|
||||
|
|
@ -336,7 +334,7 @@ class MDGXS(MGXS):
|
|||
(self.energy_groups.get_group_bounds(group),))
|
||||
|
||||
# Construct list of delayed group tuples for all requested groups
|
||||
if not isinstance(delayed_groups, basestring):
|
||||
if not isinstance(delayed_groups, string_types):
|
||||
cv.check_type('delayed groups', delayed_groups, list, int)
|
||||
for delayed_group in delayed_groups:
|
||||
filters.append(openmc.DelayedGroupFilter)
|
||||
|
|
@ -432,7 +430,7 @@ class MDGXS(MGXS):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
cv.check_iterable_type('energy_groups', groups, Integral)
|
||||
cv.check_type('delayed groups', delayed_groups, list, int)
|
||||
|
||||
|
|
@ -542,7 +540,7 @@ class MDGXS(MGXS):
|
|||
return
|
||||
|
||||
# Construct a collection of the subdomains to report
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral)
|
||||
elif self.domain_type == 'distribcell':
|
||||
subdomains = np.arange(self.num_subdomains, dtype=np.int)
|
||||
|
|
@ -559,7 +557,7 @@ class MDGXS(MGXS):
|
|||
elif nuclides == 'sum':
|
||||
nuclides = ['sum']
|
||||
else:
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
else:
|
||||
nuclides = ['sum']
|
||||
|
||||
|
|
@ -649,8 +647,8 @@ class MDGXS(MGXS):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_type('filename', filename, basestring)
|
||||
cv.check_type('directory', directory, basestring)
|
||||
cv.check_type('filename', filename, string_types)
|
||||
cv.check_type('directory', directory, string_types)
|
||||
cv.check_value('format', format, ['csv', 'excel', 'pickle', 'latex'])
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
||||
|
|
@ -740,11 +738,11 @@ class MDGXS(MGXS):
|
|||
|
||||
"""
|
||||
|
||||
if not isinstance(groups, basestring):
|
||||
if not isinstance(groups, string_types):
|
||||
cv.check_iterable_type('groups', groups, Integral)
|
||||
if nuclides != 'all' and nuclides != 'sum':
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
if not isinstance(delayed_groups, basestring):
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
if not isinstance(delayed_groups, string_types):
|
||||
cv.check_type('delayed groups', delayed_groups, list, int)
|
||||
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
|
@ -819,7 +817,7 @@ class MDGXS(MGXS):
|
|||
columns = ['group in']
|
||||
|
||||
# Select out those groups the user requested
|
||||
if not isinstance(groups, basestring):
|
||||
if not isinstance(groups, string_types):
|
||||
if 'group in' in df:
|
||||
df = df[df['group in'].isin(groups)]
|
||||
if 'group out' in df:
|
||||
|
|
@ -1210,7 +1208,7 @@ class ChiDelayed(MDGXS):
|
|||
filter_bins = []
|
||||
|
||||
# Construct a collection of the domain filter bins
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral,
|
||||
max_depth=3)
|
||||
for subdomain in subdomains:
|
||||
|
|
@ -1218,7 +1216,7 @@ class ChiDelayed(MDGXS):
|
|||
filter_bins.append((subdomain,))
|
||||
|
||||
# Construct list of energy group bounds tuples for all requested groups
|
||||
if not isinstance(groups, basestring):
|
||||
if not isinstance(groups, string_types):
|
||||
cv.check_iterable_type('groups', groups, Integral)
|
||||
for group in groups:
|
||||
filters.append(openmc.EnergyoutFilter)
|
||||
|
|
@ -1226,7 +1224,7 @@ class ChiDelayed(MDGXS):
|
|||
(self.energy_groups.get_group_bounds(group),))
|
||||
|
||||
# Construct list of delayed group tuples for all requested groups
|
||||
if not isinstance(delayed_groups, basestring):
|
||||
if not isinstance(delayed_groups, string_types):
|
||||
cv.check_type('delayed groups', delayed_groups, list, int)
|
||||
for delayed_group in delayed_groups:
|
||||
filters.append(openmc.DelayedGroupFilter)
|
||||
|
|
@ -1274,7 +1272,7 @@ class ChiDelayed(MDGXS):
|
|||
|
||||
# Get chi delayed for user-specified nuclides in the domain
|
||||
else:
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
xs = self.xs_tally.get_values(filters=filters,
|
||||
filter_bins=filter_bins,
|
||||
nuclides=nuclides, value=value)
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import warnings
|
|||
import os
|
||||
import sys
|
||||
import copy
|
||||
import abc
|
||||
from abc import ABCMeta
|
||||
import itertools
|
||||
|
||||
from six import add_metaclass
|
||||
from six import add_metaclass, string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
|
|
@ -17,9 +17,6 @@ import openmc.checkvalue as cv
|
|||
from openmc.tallies import ESTIMATOR_TYPES
|
||||
from openmc.mgxs import EnergyGroups
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
# Supported cross section types
|
||||
MGXS_TYPES = ['total',
|
||||
|
|
@ -366,7 +363,7 @@ class MGXS(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
cv.check_type('name', name, basestring)
|
||||
cv.check_type('name', name, string_types)
|
||||
self._name = name
|
||||
|
||||
@by_nuclide.setter
|
||||
|
|
@ -376,7 +373,7 @@ class MGXS(object):
|
|||
|
||||
@nuclides.setter
|
||||
def nuclides(self, nuclides):
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
self._nuclides = nuclides
|
||||
|
||||
@estimator.setter
|
||||
|
|
@ -560,7 +557,7 @@ class MGXS(object):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_type('nuclide', nuclide, basestring)
|
||||
cv.check_type('nuclide', nuclide, string_types)
|
||||
|
||||
# Get list of all nuclides in the spatial domain
|
||||
nuclides = self.domain.get_nuclide_densities()
|
||||
|
|
@ -786,7 +783,7 @@ class MGXS(object):
|
|||
filter_bins = []
|
||||
|
||||
# Construct a collection of the domain filter bins
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral,
|
||||
max_depth=3)
|
||||
for subdomain in subdomains:
|
||||
|
|
@ -794,7 +791,7 @@ class MGXS(object):
|
|||
filter_bins.append((subdomain,))
|
||||
|
||||
# Construct list of energy group bounds tuples for all requested groups
|
||||
if not isinstance(groups, basestring):
|
||||
if not isinstance(groups, string_types):
|
||||
cv.check_iterable_type('groups', groups, Integral)
|
||||
for group in groups:
|
||||
filters.append(openmc.EnergyFilter)
|
||||
|
|
@ -956,7 +953,7 @@ class MGXS(object):
|
|||
"""
|
||||
|
||||
# Construct a collection of the subdomain filter bins to average across
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral)
|
||||
elif self.domain_type == 'distribcell':
|
||||
subdomains = np.arange(self.num_subdomains)
|
||||
|
|
@ -1011,7 +1008,7 @@ class MGXS(object):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
cv.check_iterable_type('energy_groups', groups, Integral)
|
||||
|
||||
# Build lists of filters and filter bins to slice
|
||||
|
|
@ -1165,7 +1162,7 @@ class MGXS(object):
|
|||
"""
|
||||
|
||||
# Construct a collection of the subdomains to report
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral)
|
||||
elif self.domain_type == 'distribcell':
|
||||
subdomains = np.arange(self.num_subdomains, dtype=np.int)
|
||||
|
|
@ -1182,7 +1179,7 @@ class MGXS(object):
|
|||
elif nuclides == 'sum':
|
||||
nuclides = ['sum']
|
||||
else:
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
else:
|
||||
nuclides = ['sum']
|
||||
|
||||
|
|
@ -1300,7 +1297,7 @@ class MGXS(object):
|
|||
xs_results = h5py.File(filename, 'w')
|
||||
|
||||
# Construct a collection of the subdomains to report
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral)
|
||||
elif self.domain_type == 'distribcell':
|
||||
subdomains = np.arange(self.num_subdomains, dtype=np.int)
|
||||
|
|
@ -1321,7 +1318,7 @@ class MGXS(object):
|
|||
elif nuclides == 'sum':
|
||||
nuclides = ['sum']
|
||||
else:
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
else:
|
||||
nuclides = ['sum']
|
||||
|
||||
|
|
@ -1399,8 +1396,8 @@ class MGXS(object):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_type('filename', filename, basestring)
|
||||
cv.check_type('directory', directory, basestring)
|
||||
cv.check_type('filename', filename, string_types)
|
||||
cv.check_type('directory', directory, string_types)
|
||||
cv.check_value('format', format, ['csv', 'excel', 'pickle', 'latex'])
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
||||
|
|
@ -1486,10 +1483,10 @@ class MGXS(object):
|
|||
|
||||
"""
|
||||
|
||||
if not isinstance(groups, basestring):
|
||||
if not isinstance(groups, string_types):
|
||||
cv.check_iterable_type('groups', groups, Integral)
|
||||
if nuclides != 'all' and nuclides != 'sum':
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
||||
# Get a Pandas DataFrame from the derived xs tally
|
||||
|
|
@ -1561,7 +1558,7 @@ class MGXS(object):
|
|||
columns = ['group in']
|
||||
|
||||
# Select out those groups the user requested
|
||||
if not isinstance(groups, basestring):
|
||||
if not isinstance(groups, string_types):
|
||||
if 'group in' in df:
|
||||
df = df[df['group in'].isin(groups)]
|
||||
if 'group out' in df:
|
||||
|
|
@ -1781,7 +1778,7 @@ class MatrixMGXS(MGXS):
|
|||
filter_bins = []
|
||||
|
||||
# Construct a collection of the domain filter bins
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral,
|
||||
max_depth=3)
|
||||
for subdomain in subdomains:
|
||||
|
|
@ -1789,7 +1786,7 @@ class MatrixMGXS(MGXS):
|
|||
filter_bins.append((subdomain,))
|
||||
|
||||
# Construct list of energy group bounds tuples for all requested groups
|
||||
if not isinstance(in_groups, basestring):
|
||||
if not isinstance(in_groups, string_types):
|
||||
cv.check_iterable_type('groups', in_groups, Integral)
|
||||
for group in in_groups:
|
||||
filters.append(openmc.EnergyFilter)
|
||||
|
|
@ -1797,7 +1794,7 @@ class MatrixMGXS(MGXS):
|
|||
self.energy_groups.get_group_bounds(group),))
|
||||
|
||||
# Construct list of energy group bounds tuples for all requested groups
|
||||
if not isinstance(out_groups, basestring):
|
||||
if not isinstance(out_groups, string_types):
|
||||
cv.check_iterable_type('groups', out_groups, Integral)
|
||||
for group in out_groups:
|
||||
filters.append(openmc.EnergyoutFilter)
|
||||
|
|
@ -1943,7 +1940,7 @@ class MatrixMGXS(MGXS):
|
|||
"""
|
||||
|
||||
# Construct a collection of the subdomains to report
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral)
|
||||
elif self.domain_type == 'distribcell':
|
||||
subdomains = np.arange(self.num_subdomains, dtype=np.int)
|
||||
|
|
@ -1960,7 +1957,7 @@ class MatrixMGXS(MGXS):
|
|||
if nuclides == 'sum':
|
||||
nuclides = ['sum']
|
||||
else:
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
else:
|
||||
nuclides = ['sum']
|
||||
|
||||
|
|
@ -3616,21 +3613,21 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
filter_bins = []
|
||||
|
||||
# Construct a collection of the domain filter bins
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral, max_depth=3)
|
||||
for subdomain in subdomains:
|
||||
filters.append(_DOMAIN_TO_FILTER[self.domain_type])
|
||||
filter_bins.append((subdomain,))
|
||||
|
||||
# Construct list of energy group bounds tuples for all requested groups
|
||||
if not isinstance(in_groups, basestring):
|
||||
if not isinstance(in_groups, string_types):
|
||||
cv.check_iterable_type('groups', in_groups, Integral)
|
||||
for group in in_groups:
|
||||
filters.append(openmc.EnergyFilter)
|
||||
filter_bins.append((self.energy_groups.get_group_bounds(group),))
|
||||
|
||||
# Construct list of energy group bounds tuples for all requested groups
|
||||
if not isinstance(out_groups, basestring):
|
||||
if not isinstance(out_groups, string_types):
|
||||
cv.check_iterable_type('groups', out_groups, Integral)
|
||||
for group in out_groups:
|
||||
filters.append(openmc.EnergyoutFilter)
|
||||
|
|
@ -3804,7 +3801,7 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
"""
|
||||
|
||||
# Construct a collection of the subdomains to report
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral)
|
||||
elif self.domain_type == 'distribcell':
|
||||
subdomains = np.arange(self.num_subdomains, dtype=np.int)
|
||||
|
|
@ -3821,7 +3818,7 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
if nuclides == 'sum':
|
||||
nuclides = ['sum']
|
||||
else:
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
else:
|
||||
nuclides = ['sum']
|
||||
|
||||
|
|
@ -4604,14 +4601,14 @@ class Chi(MGXS):
|
|||
filter_bins = []
|
||||
|
||||
# Construct a collection of the domain filter bins
|
||||
if not isinstance(subdomains, basestring):
|
||||
if not isinstance(subdomains, string_types):
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral, max_depth=3)
|
||||
for subdomain in subdomains:
|
||||
filters.append(_DOMAIN_TO_FILTER[self.domain_type])
|
||||
filter_bins.append((subdomain,))
|
||||
|
||||
# Construct list of energy group bounds tuples for all requested groups
|
||||
if not isinstance(groups, basestring):
|
||||
if not isinstance(groups, string_types):
|
||||
cv.check_iterable_type('groups', groups, Integral)
|
||||
for group in groups:
|
||||
filters.append(openmc.EnergyoutFilter)
|
||||
|
|
@ -4656,7 +4653,7 @@ class Chi(MGXS):
|
|||
|
||||
# Get chi for user-specified nuclides in the domain
|
||||
else:
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
xs = self.xs_tally.get_values(filters=filters,
|
||||
filter_bins=filter_bins,
|
||||
nuclides=nuclides, value=value)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from numbers import Real, Integral
|
|||
from xml.etree import ElementTree as ET
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
|
|
@ -11,8 +12,6 @@ from openmc.checkvalue import check_type, check_value, check_greater_than, \
|
|||
check_iterable_type
|
||||
from openmc.clean_xml import sort_xml_elements, clean_xml_indentation
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
# Supported incoming particle MGXS angular treatment representations
|
||||
_REPRESENTATIONS = ['isotropic', 'angle']
|
||||
|
|
@ -360,7 +359,7 @@ class XSdata(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
check_type('name for XSdata', name, basestring)
|
||||
check_type('name for XSdata', name, string_types)
|
||||
self._name = name
|
||||
|
||||
@energy_groups.setter
|
||||
|
|
@ -383,7 +382,7 @@ class XSdata(object):
|
|||
@alias.setter
|
||||
def alias(self, alias):
|
||||
if alias is not None:
|
||||
check_type('alias', alias, basestring)
|
||||
check_type('alias', alias, string_types)
|
||||
self._alias = alias
|
||||
else:
|
||||
self._alias = self._name
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ from numbers import Integral
|
|||
import sys
|
||||
import warnings
|
||||
|
||||
from openmc.checkvalue import check_type
|
||||
from six import string_types
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
from openmc.checkvalue import check_type
|
||||
|
||||
|
||||
class Nuclide(object):
|
||||
|
|
@ -39,7 +38,7 @@ class Nuclide(object):
|
|||
return False
|
||||
else:
|
||||
return True
|
||||
elif isinstance(other, basestring) and other == self.name:
|
||||
elif isinstance(other, string_types) and other == self.name:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
@ -73,7 +72,7 @@ class Nuclide(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
check_type('name', name, basestring)
|
||||
check_type('name', name, string_types)
|
||||
self._name = name
|
||||
|
||||
if '-' in name:
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@ from xml.etree import ElementTree as ET
|
|||
import sys
|
||||
import warnings
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
from openmc.clean_xml import clean_xml_indentation
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
# A static variable for auto-generated Plot IDs
|
||||
AUTO_PLOT_ID = 10000
|
||||
|
|
@ -166,7 +165,7 @@ class Plot(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
cv.check_type('plot name', name, basestring)
|
||||
cv.check_type('plot name', name, string_types)
|
||||
self._name = name
|
||||
|
||||
@width.setter
|
||||
|
|
@ -191,24 +190,24 @@ class Plot(object):
|
|||
|
||||
@filename.setter
|
||||
def filename(self, filename):
|
||||
cv.check_type('filename', filename, basestring)
|
||||
cv.check_type('filename', filename, string_types)
|
||||
self._filename = filename
|
||||
|
||||
@color.setter
|
||||
def color(self, color):
|
||||
cv.check_type('plot color', color, basestring)
|
||||
cv.check_type('plot color', color, string_types)
|
||||
cv.check_value('plot color', color, ['cell', 'mat'])
|
||||
self._color = color
|
||||
|
||||
@type.setter
|
||||
def type(self, plottype):
|
||||
cv.check_type('plot type', plottype, basestring)
|
||||
cv.check_type('plot type', plottype, string_types)
|
||||
cv.check_value('plot type', plottype, ['slice', 'voxel'])
|
||||
self._type = plottype
|
||||
|
||||
@basis.setter
|
||||
def basis(self, basis):
|
||||
cv.check_type('plot basis', basis, basestring)
|
||||
cv.check_type('plot basis', basis, string_types)
|
||||
cv.check_value('plot basis', basis, ['xy', 'xz', 'yz'])
|
||||
self._basis = basis
|
||||
|
||||
|
|
@ -387,7 +386,7 @@ class Plot(object):
|
|||
cv.check_less_than('alpha', alpha, 1., equality=True)
|
||||
|
||||
# Get a background (R,G,B) tuple to apply in alpha compositing
|
||||
if isinstance(background, basestring):
|
||||
if isinstance(background, string_types):
|
||||
if background == 'white':
|
||||
background = (255, 255, 255)
|
||||
elif background == 'black':
|
||||
|
|
|
|||
|
|
@ -4,15 +4,13 @@ import warnings
|
|||
from xml.etree import ElementTree as ET
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
from openmc.clean_xml import clean_xml_indentation
|
||||
import openmc.checkvalue as cv
|
||||
from openmc import Nuclide, VolumeCalculation, Source
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
class Settings(object):
|
||||
"""Settings used for an OpenMC simulation.
|
||||
|
|
@ -527,7 +525,7 @@ class Settings(object):
|
|||
|
||||
@output_path.setter
|
||||
def output_path(self, output_path):
|
||||
cv.check_type('output path', output_path, basestring)
|
||||
cv.check_type('output path', output_path, string_types)
|
||||
self._output_path = output_path
|
||||
|
||||
@verbosity.setter
|
||||
|
|
@ -583,12 +581,12 @@ class Settings(object):
|
|||
|
||||
@cross_sections.setter
|
||||
def cross_sections(self, cross_sections):
|
||||
cv.check_type('cross sections', cross_sections, basestring)
|
||||
cv.check_type('cross sections', cross_sections, string_types)
|
||||
self._cross_sections = cross_sections
|
||||
|
||||
@multipole_library.setter
|
||||
def multipole_library(self, multipole_library):
|
||||
cv.check_type('cross sections', multipole_library, basestring)
|
||||
cv.check_type('cross sections', multipole_library, string_types)
|
||||
self._multipole_library = multipole_library
|
||||
|
||||
@ptables.setter
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@ from numbers import Real
|
|||
import sys
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from six import string_types
|
||||
|
||||
from openmc.stats.univariate import Univariate
|
||||
from openmc.stats.multivariate import UnitSphere, Spatial
|
||||
import openmc.checkvalue as cv
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
class Source(object):
|
||||
"""Distribution of phase space coordinates for source sites.
|
||||
|
|
@ -79,7 +78,7 @@ class Source(object):
|
|||
|
||||
@file.setter
|
||||
def file(self, filename):
|
||||
cv.check_type('source file', filename, basestring)
|
||||
cv.check_type('source file', filename, string_types)
|
||||
self._file = filename
|
||||
|
||||
@space.setter
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ import numpy as np
|
|||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
|
||||
if sys.version > '3':
|
||||
long = int
|
||||
|
||||
|
||||
class StatePoint(object):
|
||||
"""State information on a simulation at a certain point in time (at the end
|
||||
|
|
|
|||
|
|
@ -11,9 +11,6 @@ import numpy as np
|
|||
import openmc.checkvalue as cv
|
||||
from openmc.stats.univariate import Univariate, Uniform
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class UnitSphere(object):
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ import numpy as np
|
|||
import openmc.checkvalue as cv
|
||||
from openmc.mixin import EqualityMixin
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
_INTERPOLATION_SCHEMES = ['histogram', 'linear-linear', 'linear-log',
|
||||
'log-linear', 'log-log']
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@ from xml.etree import ElementTree as ET
|
|||
import sys
|
||||
from math import sqrt
|
||||
|
||||
from six import add_metaclass
|
||||
from six import add_metaclass, string_types
|
||||
import numpy as np
|
||||
|
||||
from openmc.checkvalue import check_type, check_value, check_greater_than
|
||||
from openmc.region import Region, Intersection
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
# A static variable for auto-generated Surface IDs
|
||||
AUTO_SURFACE_ID = 10000
|
||||
|
|
@ -135,14 +133,14 @@ class Surface(object):
|
|||
@name.setter
|
||||
def name(self, name):
|
||||
if name is not None:
|
||||
check_type('surface name', name, basestring)
|
||||
check_type('surface name', name, string_types)
|
||||
self._name = name
|
||||
else:
|
||||
self._name = ''
|
||||
|
||||
@boundary_type.setter
|
||||
def boundary_type(self, boundary_type):
|
||||
check_type('boundary type', boundary_type, basestring)
|
||||
check_type('boundary type', boundary_type, string_types)
|
||||
check_value('boundary type', boundary_type, _BC_TYPES)
|
||||
self._boundary_type = boundary_type
|
||||
|
||||
|
|
|
|||
|
|
@ -11,15 +11,13 @@ import sys
|
|||
import warnings
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
from openmc.clean_xml import clean_xml_indentation
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
|
||||
# "Static" variable for auto-generated Tally IDs
|
||||
AUTO_TALLY_ID = 10000
|
||||
|
|
@ -33,9 +31,9 @@ _PRODUCT_TYPES = ['tensor', 'entrywise']
|
|||
|
||||
# The following indicate acceptable types when setting Tally.scores,
|
||||
# Tally.nuclides, and Tally.filters
|
||||
_SCORE_CLASSES = (basestring, openmc.CrossScore, openmc.AggregateScore)
|
||||
_NUCLIDE_CLASSES = (basestring, openmc.Nuclide, openmc.CrossNuclide,
|
||||
openmc.AggregateNuclide)
|
||||
_SCORE_CLASSES = string_types + (openmc.CrossScore, openmc.AggregateScore)
|
||||
_NUCLIDE_CLASSES = string_types + (openmc.Nuclide, openmc.CrossNuclide,
|
||||
openmc.AggregateNuclide)
|
||||
_FILTER_CLASSES = (openmc.Filter, openmc.CrossFilter, openmc.AggregateFilter)
|
||||
|
||||
# Valid types of estimators
|
||||
|
|
@ -431,7 +429,7 @@ class Tally(object):
|
|||
@name.setter
|
||||
def name(self, name):
|
||||
if name is not None:
|
||||
cv.check_type('tally name', name, basestring)
|
||||
cv.check_type('tally name', name, string_types)
|
||||
self._name = name
|
||||
else:
|
||||
self._name = ''
|
||||
|
|
@ -478,7 +476,7 @@ class Tally(object):
|
|||
raise ValueError(msg)
|
||||
|
||||
# If score is a string, strip whitespace
|
||||
if isinstance(score, basestring):
|
||||
if isinstance(score, string_types):
|
||||
scores[i] = score.strip()
|
||||
|
||||
self._scores = cv.CheckedList(_SCORE_CLASSES, 'tally scores', scores)
|
||||
|
|
@ -1355,7 +1353,7 @@ class Tally(object):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_iterable_type('nuclides', nuclides, basestring)
|
||||
cv.check_iterable_type('nuclides', nuclides, string_types)
|
||||
|
||||
# Determine the score indices from any of the requested scores
|
||||
if nuclides:
|
||||
|
|
@ -1390,7 +1388,7 @@ class Tally(object):
|
|||
"""
|
||||
|
||||
for score in scores:
|
||||
if not isinstance(score, (basestring, openmc.CrossScore)):
|
||||
if not isinstance(score, string_types + (openmc.CrossScore,)):
|
||||
msg = 'Unable to get score indices for score "{0}" in Tally ' \
|
||||
'ID="{1}" since it is not a string or CrossScore'\
|
||||
.format(score, self.id)
|
||||
|
|
@ -1585,7 +1583,7 @@ class Tally(object):
|
|||
column_name = 'score'
|
||||
|
||||
for score in self.scores:
|
||||
if isinstance(score, (basestring, openmc.CrossScore)):
|
||||
if isinstance(score, string_types + (openmc.CrossScore,)):
|
||||
scores.append(str(score))
|
||||
elif isinstance(score, openmc.AggregateScore):
|
||||
scores.append(score.name)
|
||||
|
|
@ -1700,13 +1698,13 @@ class Tally(object):
|
|||
msg = 'The Tally ID="{0}" has no data to export'.format(self.id)
|
||||
raise KeyError(msg)
|
||||
|
||||
if not isinstance(filename, basestring):
|
||||
if not isinstance(filename, string_types):
|
||||
msg = 'Unable to export the results for Tally ID="{0}" to ' \
|
||||
'filename="{1}" since it is not a ' \
|
||||
'string'.format(self.id, filename)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not isinstance(directory, basestring):
|
||||
elif not isinstance(directory, string_types):
|
||||
msg = 'Unable to export the results for Tally ID="{0}" to ' \
|
||||
'directory="{1}" since it is not a ' \
|
||||
'string'.format(self.id, directory)
|
||||
|
|
@ -2354,11 +2352,11 @@ class Tally(object):
|
|||
raise ValueError(msg)
|
||||
|
||||
# Check that the scores are valid
|
||||
if not isinstance(score1, (basestring, openmc.CrossScore)):
|
||||
if not isinstance(score1, string_types + (openmc.CrossScore,)):
|
||||
msg = 'Unable to swap score1 "{0}" in Tally ID="{1}" since it is ' \
|
||||
'not a string or CrossScore'.format(score1, self.id)
|
||||
raise ValueError(msg)
|
||||
elif not isinstance(score2, (basestring, openmc.CrossScore)):
|
||||
elif not isinstance(score2, string_types + (openmc.CrossScore,)):
|
||||
msg = 'Unable to swap score2 "{0}" in Tally ID="{1}" since it is ' \
|
||||
'not a string or CrossScore'.format(score2, self.id)
|
||||
raise ValueError(msg)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ import sys
|
|||
import warnings
|
||||
from collections import Iterable
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
from six import string_types
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
import openmc.checkvalue as cv
|
||||
|
||||
|
||||
class Trigger(object):
|
||||
|
|
@ -77,7 +76,7 @@ class Trigger(object):
|
|||
|
||||
@scores.setter
|
||||
def scores(self, scores):
|
||||
cv.check_type('trigger scores', scores, Iterable, basestring)
|
||||
cv.check_type('trigger scores', scores, Iterable, string_types)
|
||||
|
||||
# Set scores making sure not to have duplicates
|
||||
self._scores = []
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@ from numbers import Integral
|
|||
import random
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
||||
# A dictionary for storing IDs of cell elements that have already been written,
|
||||
# used to optimize the writing process
|
||||
|
|
@ -118,7 +117,7 @@ class Universe(object):
|
|||
@name.setter
|
||||
def name(self, name):
|
||||
if name is not None:
|
||||
cv.check_type('universe name', name, basestring)
|
||||
cv.check_type('universe name', name, string_types)
|
||||
self._name = name
|
||||
else:
|
||||
self._name = ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue