Skip to content

Commit

Permalink
sets used instead of lists when membership testing (openmc-dev#3021)
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell authored and church89 committed Jul 18, 2024
1 parent 7edec52 commit 073c5c3
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 23 deletions.
4 changes: 2 additions & 2 deletions openmc/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@


# Acceptable tally arithmetic binary operations
_TALLY_ARITHMETIC_OPS = ['+', '-', '*', '/', '^']
_TALLY_ARITHMETIC_OPS = {'+', '-', '*', '/', '^'}

# Acceptable tally aggregation operations
_TALLY_AGGREGATE_OPS = ['sum', 'avg']
_TALLY_AGGREGATE_OPS = {'sum', 'avg'}


class CrossScore:
Expand Down
4 changes: 2 additions & 2 deletions openmc/data/photon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
R0 = CM_PER_ANGSTROM * PLANCK_C / (2.0 * pi * FINE_STRUCTURE * MASS_ELECTRON_EV)

# Electron subshell labels
_SUBSHELLS = [None, 'K', 'L1', 'L2', 'L3', 'M1', 'M2', 'M3', 'M4', 'M5',
_SUBSHELLS = (None, 'K', 'L1', 'L2', 'L3', 'M1', 'M2', 'M3', 'M4', 'M5',
'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'O1', 'O2', 'O3',
'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4',
'P5', 'P6', 'P7', 'P8', 'P9', 'P10', 'P11', 'Q1', 'Q2', 'Q3']
'P5', 'P6', 'P7', 'P8', 'P9', 'P10', 'P11', 'Q1', 'Q2', 'Q3')

_REACTION_NAME = {
501: ('Total photon interaction', 'total'),
Expand Down
12 changes: 4 additions & 8 deletions openmc/mgxs_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,17 @@
# Supported incoming particle MGXS angular treatment representations
REPRESENTATION_ISOTROPIC = 'isotropic'
REPRESENTATION_ANGLE = 'angle'
_REPRESENTATIONS = [
_REPRESENTATIONS = {
REPRESENTATION_ISOTROPIC,
REPRESENTATION_ANGLE
]
}

# Supported scattering angular distribution representations
_SCATTER_TYPES = [
_SCATTER_TYPES = {
SCATTER_TABULAR,
SCATTER_LEGENDRE,
SCATTER_HISTOGRAM
]

# List of MGXS indexing schemes
_XS_SHAPES = ["[G][G'][Order]", "[G]", "[G']", "[G][G']", "[DG]", "[DG][G]",
"[DG][G']", "[DG][G][G']"]
}

# Number of mu points for conversion between scattering formats
_NMU = 257
Expand Down
2 changes: 1 addition & 1 deletion openmc/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._xml import clean_indentation, get_elem_tuple, reorder_attributes, get_text
from .mixin import IDManagerMixin

_BASES = ['xy', 'xz', 'yz']
_BASES = {'xy', 'xz', 'yz'}

_SVG_COLORS = {
'aliceblue': (240, 248, 255),
Expand Down
8 changes: 4 additions & 4 deletions openmc/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import openmc.data

# Supported keywords for continuous-energy cross section plotting
PLOT_TYPES = ['total', 'scatter', 'elastic', 'inelastic', 'fission',
PLOT_TYPES = {'total', 'scatter', 'elastic', 'inelastic', 'fission',
'absorption', 'capture', 'nu-fission', 'nu-scatter', 'unity',
'slowing-down power', 'damage']
'slowing-down power', 'damage'}

# Supported keywords for multi-group cross section plotting
PLOT_TYPES_MGXS = ['total', 'absorption', 'scatter', 'fission',
PLOT_TYPES_MGXS = {'total', 'absorption', 'scatter', 'fission',
'kappa-fission', 'nu-fission', 'prompt-nu-fission',
'deleyed-nu-fission', 'chi', 'chi-prompt', 'chi-delayed',
'inverse-velocity', 'beta', 'decay-rate', 'unity']
'inverse-velocity', 'beta', 'decay-rate', 'unity'}
# Create a dictionary which can be used to convert PLOT_TYPES_MGXS to the
# openmc.XSdata attribute name needed to access the data
_PLOT_MGXS_ATTR = {line: line.replace(' ', '_').replace('-', '_')
Expand Down
2 changes: 1 addition & 1 deletion openmc/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import openmc.checkvalue as cv


_SCALAR_BRACKETED_METHODS = ['brentq', 'brenth', 'ridder', 'bisect']
_SCALAR_BRACKETED_METHODS = {'brentq', 'brenth', 'ridder', 'bisect'}


def _search_keff(guess, target, model_builder, model_args, print_iterations,
Expand Down
2 changes: 1 addition & 1 deletion openmc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RunMode(Enum):
PARTICLE_RESTART = 'particle restart'


_RES_SCAT_METHODS = ['dbrc', 'rvs']
_RES_SCAT_METHODS = {'dbrc', 'rvs'}


class Settings:
Expand Down
4 changes: 2 additions & 2 deletions openmc/stats/univariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
from .._xml import get_text
from ..mixin import EqualityMixin

_INTERPOLATION_SCHEMES = [
_INTERPOLATION_SCHEMES = {
'histogram',
'linear-linear',
'linear-log',
'log-linear',
'log-log'
]
}


class Univariate(EqualityMixin, ABC):
Expand Down
4 changes: 2 additions & 2 deletions openmc/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from .bounding_box import BoundingBox


_BOUNDARY_TYPES = ['transmission', 'vacuum', 'reflective', 'periodic', 'white']
_ALBEDO_BOUNDARIES = ['reflective', 'periodic', 'white']
_BOUNDARY_TYPES = {'transmission', 'vacuum', 'reflective', 'periodic', 'white'}
_ALBEDO_BOUNDARIES = {'reflective', 'periodic', 'white'}

_WARNING_UPPER = """\
"{}(...) accepts an argument named '{}', not '{}'. Future versions of OpenMC \
Expand Down

0 comments on commit 073c5c3

Please sign in to comment.