From 073c5c359bffa69ea003dd6feb8280646f738dba Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 19 Jun 2024 15:48:34 +0100 Subject: [PATCH] sets used instead of lists when membership testing (#3021) --- openmc/arithmetic.py | 4 ++-- openmc/data/photon.py | 4 ++-- openmc/mgxs_library.py | 12 ++++-------- openmc/plots.py | 2 +- openmc/plotter.py | 8 ++++---- openmc/search.py | 2 +- openmc/settings.py | 2 +- openmc/stats/univariate.py | 4 ++-- openmc/surface.py | 4 ++-- 9 files changed, 19 insertions(+), 23 deletions(-) diff --git a/openmc/arithmetic.py b/openmc/arithmetic.py index 4520553dafc..821014e36df 100644 --- a/openmc/arithmetic.py +++ b/openmc/arithmetic.py @@ -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: diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 0d0419f0724..25ded24cbe3 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -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'), diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index d1b96289081..3381c3abb6e 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -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 diff --git a/openmc/plots.py b/openmc/plots.py index 02a44449bed..0d9dca30e79 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -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), diff --git a/openmc/plotter.py b/openmc/plotter.py index aa3825f5e1a..8a9a331d804 100644 --- a/openmc/plotter.py +++ b/openmc/plotter.py @@ -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('-', '_') diff --git a/openmc/search.py b/openmc/search.py index 7e2c5a1a19d..01c1b2fe9a6 100644 --- a/openmc/search.py +++ b/openmc/search.py @@ -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, diff --git a/openmc/settings.py b/openmc/settings.py index 9565c2b7863..43f763a194d 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -26,7 +26,7 @@ class RunMode(Enum): PARTICLE_RESTART = 'particle restart' -_RES_SCAT_METHODS = ['dbrc', 'rvs'] +_RES_SCAT_METHODS = {'dbrc', 'rvs'} class Settings: diff --git a/openmc/stats/univariate.py b/openmc/stats/univariate.py index f44bce67cee..4069c5a9e11 100644 --- a/openmc/stats/univariate.py +++ b/openmc/stats/univariate.py @@ -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): diff --git a/openmc/surface.py b/openmc/surface.py index 806331024e2..0fa2ae43949 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -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 \