mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
corrected multiline f strings
This commit is contained in:
parent
747094be1a
commit
2453b04b62
12 changed files with 58 additions and 59 deletions
|
|
@ -659,8 +659,8 @@ class AggregateFilter:
|
|||
"""
|
||||
|
||||
if filter_bin not in self.bins:
|
||||
msg = f'Unable to get the bin index for AggregateFilter since ' \
|
||||
'"{filter_bin}" is not one of the bins'
|
||||
msg = ('Unable to get the bin index for AggregateFilter since '
|
||||
f'"{filter_bin}" is not one of the bins')
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
return self.bins.index(filter_bin)
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ class Cell(IDManagerMixin):
|
|||
elif not isinstance(fill, (openmc.Material, openmc.Lattice,
|
||||
openmc.UniverseBase)):
|
||||
msg = (f'Unable to set Cell ID="{self._id}" to use a '
|
||||
'non-Material or Universe fill "{fill}"')
|
||||
f'non-Material or Universe fill "{fill}"')
|
||||
raise ValueError(msg)
|
||||
self._fill = fill
|
||||
|
||||
|
|
@ -408,8 +408,8 @@ class Cell(IDManagerMixin):
|
|||
nuclides[name] = (nuclide, density)
|
||||
else:
|
||||
raise RuntimeError(
|
||||
f'Volume information is needed to calculate microscopic '
|
||||
'cross sections for cell {self.id}. This can be done by '
|
||||
'Volume information is needed to calculate microscopic '
|
||||
f'cross sections for cell {self.id}. This can be done by '
|
||||
'running a stochastic volume calculation via the '
|
||||
'openmc.VolumeCalculation object')
|
||||
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=F
|
|||
[t.__name__ for t in expected_type]))
|
||||
else:
|
||||
msg = (f'Unable to set "{name}" to "{value}" which is not of type "'
|
||||
'{expected_type.__name__}"')
|
||||
f'{expected_type.__name__}"')
|
||||
raise TypeError(msg)
|
||||
|
||||
if expected_iter_type:
|
||||
if isinstance(value, np.ndarray):
|
||||
if not issubclass(value.dtype.type, expected_iter_type):
|
||||
msg = (f'Unable to set "{name}" to "{value}" since each item '
|
||||
'must be of type "{expected_iter_type.__name__}"')
|
||||
f'must be of type "{expected_iter_type.__name__}"')
|
||||
raise TypeError(msg)
|
||||
else:
|
||||
return
|
||||
|
|
@ -54,7 +54,7 @@ def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=F
|
|||
expected_iter_type]))
|
||||
else:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since each '
|
||||
'item must be of type "{expected_iter_type.__name__}"')
|
||||
f'item must be of type "{expected_iter_type.__name__}"')
|
||||
raise TypeError(msg)
|
||||
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ def check_iterable_type(name, value, expected_type, min_depth=1, max_depth=1):
|
|||
# Is this deep enough?
|
||||
if len(tree) < min_depth:
|
||||
msg = (f'Error setting "{name}": The item at {ind_str} does not '
|
||||
'meet the minimum depth of {min_depth}')
|
||||
f'meet the minimum depth of {min_depth}')
|
||||
raise TypeError(msg)
|
||||
|
||||
# This item is okay. Move on to the next item.
|
||||
|
|
@ -122,15 +122,15 @@ def check_iterable_type(name, value, expected_type, min_depth=1, max_depth=1):
|
|||
# But first, have we exceeded the max depth?
|
||||
if len(tree) > max_depth:
|
||||
msg = (f'Error setting {name}: Found an iterable at '
|
||||
'{ind_str}, items in that iterable exceed the '
|
||||
'maximum depth of {max_depth}')
|
||||
f'{ind_str}, items in that iterable exceed the '
|
||||
f'maximum depth of {max_depth}')
|
||||
raise TypeError(msg)
|
||||
|
||||
else:
|
||||
# This item is completely unexpected.
|
||||
msg = (f'Error setting {name}: Items must be of type '
|
||||
'"{expected_type.__name__}", but item at {ind_str} is '
|
||||
'of type "{type(current_item).__name__}"')
|
||||
f'"{expected_type.__name__}", but item at {ind_str} is '
|
||||
f'of type "{type(current_item).__name__}"')
|
||||
raise TypeError(msg)
|
||||
|
||||
|
||||
|
|
@ -154,15 +154,15 @@ def check_length(name, value, length_min, length_max=None):
|
|||
if length_max is None:
|
||||
if len(value) < length_min:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since it must be at '
|
||||
'least of length "{length_min}"')
|
||||
f'least of length "{length_min}"')
|
||||
raise ValueError(msg)
|
||||
elif not length_min <= len(value) <= length_max:
|
||||
if length_min == length_max:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since it must be of '
|
||||
'length "{length_min}"')
|
||||
f'length "{length_min}"')
|
||||
else:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since it must have '
|
||||
'length between "{length_min}" and "{length_max}"')
|
||||
f'length between "{length_min}" and "{length_max}"')
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ def check_value(name, value, accepted_values):
|
|||
|
||||
if value not in accepted_values:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since it is not in '
|
||||
'"{accepted_values}"')
|
||||
f'"{accepted_values}"')
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
|
|
@ -205,12 +205,12 @@ def check_less_than(name, value, maximum, equality=False):
|
|||
if equality:
|
||||
if value > maximum:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since it is greater '
|
||||
'than "{maximum}"')
|
||||
f'than "{maximum}"')
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
if value >= maximum:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since it is greater '
|
||||
'than or equal to "{maximum}"')
|
||||
f'than or equal to "{maximum}"')
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
|
|
@ -233,12 +233,12 @@ def check_greater_than(name, value, minimum, equality=False):
|
|||
if equality:
|
||||
if value < minimum:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since it is less than '
|
||||
'"{minimum}"')
|
||||
f'"{minimum}"')
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
if value <= minimum:
|
||||
msg = (f'Unable to set "{name}" to "{value}" since it is less than '
|
||||
'or equal to "{minimum}"')
|
||||
f'or equal to "{minimum}"')
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ class CMFDMesh:
|
|||
def _display_mesh_warning(self, mesh_type, variable_label):
|
||||
if self._mesh_type != mesh_type:
|
||||
warn_msg = (f'Setting {variable_label} if mesh type is not set to '
|
||||
'{mesh_type} will have no effect')
|
||||
f'{mesh_type} will have no effect')
|
||||
warnings.warn(warn_msg, RuntimeWarning)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -203,8 +203,8 @@ class Element(str):
|
|||
|
||||
# Check that the element is Uranium
|
||||
if self.name != 'U':
|
||||
msg = (f'Enrichment procedure for Uranium was requested, '
|
||||
'but the isotope is {self} not U')
|
||||
msg = ('Enrichment procedure for Uranium was requested, '
|
||||
f'but the isotope is {self} not U')
|
||||
raise ValueError(msg)
|
||||
|
||||
# Check that enrichment_type is not 'ao'
|
||||
|
|
|
|||
|
|
@ -325,8 +325,8 @@ class Filter(IDManagerMixin, metaclass=FilterMeta):
|
|||
"""
|
||||
|
||||
if filter_bin not in self.bins:
|
||||
msg = (f'Unable to get the bin index for Filter since '
|
||||
'"{filter_bin}" is not one of the bins')
|
||||
msg = ('Unable to get the bin index for Filter since '
|
||||
f'"{filter_bin}" is not one of the bins')
|
||||
raise ValueError(msg)
|
||||
|
||||
if isinstance(self.bins, np.ndarray):
|
||||
|
|
@ -1271,8 +1271,8 @@ class EnergyFilter(RealFilter):
|
|||
if min_delta < 1E-3:
|
||||
return deltas.argmin()
|
||||
else:
|
||||
msg = (f'Unable to get the bin index for Filter since '
|
||||
'"{filter_bin}" is not one of the bins')
|
||||
msg = ('Unable to get the bin index for Filter since '
|
||||
f'"{filter_bin}" is not one of the bins')
|
||||
raise ValueError(msg)
|
||||
|
||||
def check_bins(self, bins):
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class Nuclide(str):
|
|||
if name.endswith('m'):
|
||||
name = name[:-1] + '_m1'
|
||||
|
||||
msg = (f'OpenMC nuclides follow the GND naming convention. '
|
||||
'Nuclide "{orig_name}" is being renamed as "{name}".')
|
||||
msg = ('OpenMC nuclides follow the GND naming convention. '
|
||||
f'Nuclide "{orig_name}" is being renamed as "{name}".')
|
||||
warnings.warn(msg)
|
||||
|
||||
return super().__new__(cls, name)
|
||||
|
|
|
|||
|
|
@ -193,8 +193,8 @@ def get_openmoc_surface(openmc_surface):
|
|||
openmoc_surface = openmoc.ZCylinder(x0, y0, R, surface_id, name)
|
||||
|
||||
else:
|
||||
msg = (f'Unable to create an OpenMOC Surface from an OpenMC Surface of '
|
||||
'type "{type(openmc_surface)}" since it is not a compatible '
|
||||
msg = ('Unable to create an OpenMOC Surface from an OpenMC Surface of '
|
||||
f'type "{type(openmc_surface)}" since it is not a compatible '
|
||||
'Surface type in OpenMOC')
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -494,8 +494,8 @@ class Plot(IDManagerMixin):
|
|||
upper_right = upper_right[np.array(pick_index)]
|
||||
|
||||
if np.any(np.isinf((lower_left, upper_right))):
|
||||
raise ValueError(f'The geometry does not appear to be bounded '
|
||||
'in the {basis} plane.')
|
||||
raise ValueError('The geometry does not appear to be bounded '
|
||||
f'in the {basis} plane.')
|
||||
|
||||
plot = cls()
|
||||
plot.origin = np.insert((lower_left + upper_right)/2,
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ class Tally(IDManagerMixin):
|
|||
for f in filters:
|
||||
if f in visited_filters:
|
||||
msg = (f'Unable to add a duplicate filter "{f}" to Tally '
|
||||
'ID="{self.id}" since duplicate filters are not '
|
||||
f'ID="{self.id}" since duplicate filters are not '
|
||||
'supported in the OpenMC Python API')
|
||||
raise ValueError(msg)
|
||||
visited_filters.add(f)
|
||||
|
|
@ -353,7 +353,7 @@ class Tally(IDManagerMixin):
|
|||
for nuc in nuclides:
|
||||
if nuc in visited_nuclides:
|
||||
msg = (f'Unable to add a duplicate nuclide "{nuc}" to Tally ID='
|
||||
'"{self.id}" since duplicate nuclides are not supported '
|
||||
f'"{self.id}" since duplicate nuclides are not supported '
|
||||
'in the OpenMC Python API')
|
||||
raise ValueError(msg)
|
||||
visited_nuclides.add(nuc)
|
||||
|
|
@ -370,7 +370,7 @@ class Tally(IDManagerMixin):
|
|||
# If the score is already in the Tally, raise an error
|
||||
if score in visited_scores:
|
||||
msg = (f'Unable to add a duplicate score "{score}" to Tally '
|
||||
'ID="{self.id}" since duplicate scores are not '
|
||||
f'ID="{self.id}" since duplicate scores are not '
|
||||
'supported in the OpenMC Python API')
|
||||
raise ValueError(msg)
|
||||
visited_scores.add(score)
|
||||
|
|
@ -468,7 +468,7 @@ class Tally(IDManagerMixin):
|
|||
|
||||
if score not in self.scores:
|
||||
msg = f'Unable to remove score "{score}" from Tally ' \
|
||||
'ID="{self.id}" since the Tally does not contain this score'
|
||||
f'ID="{self.id}" since the Tally does not contain this score'
|
||||
raise ValueError(msg)
|
||||
|
||||
self._scores.remove(score)
|
||||
|
|
@ -485,7 +485,7 @@ class Tally(IDManagerMixin):
|
|||
|
||||
if old_filter not in self.filters:
|
||||
msg = f'Unable to remove filter "{old_filter}" from Tally ' \
|
||||
'ID="{self.id}" since the Tally does not contain this filter'
|
||||
f'ID="{self.id}" since the Tally does not contain this filter'
|
||||
raise ValueError(msg)
|
||||
|
||||
self._filters.remove(old_filter)
|
||||
|
|
@ -502,7 +502,7 @@ class Tally(IDManagerMixin):
|
|||
|
||||
if nuclide not in self.nuclides:
|
||||
msg = f'Unable to remove nuclide "{nuclide}" from Tally ' \
|
||||
'ID="{self.id}" since the Tally does not contain this nuclide'
|
||||
f'ID="{self.id}" since the Tally does not contain this nuclide'
|
||||
raise ValueError(msg)
|
||||
|
||||
self._nuclides.remove(nuclide)
|
||||
|
|
@ -922,7 +922,7 @@ class Tally(IDManagerMixin):
|
|||
|
||||
# If we did not find the Filter, throw an Exception
|
||||
msg = f'Unable to find filter type "{filter_type}" in Tally ' \
|
||||
'ID="{self.id}"'
|
||||
f'ID="{self.id}"'
|
||||
raise ValueError(msg)
|
||||
|
||||
def get_nuclide_index(self, nuclide):
|
||||
|
|
@ -1122,7 +1122,7 @@ class Tally(IDManagerMixin):
|
|||
for score in scores:
|
||||
if not isinstance(score, (str, openmc.CrossScore)):
|
||||
msg = f'Unable to get score indices for score "{score}" in ' \
|
||||
'ID="{self.id}" since it is not a string or CrossScore ' \
|
||||
f'ID="{self.id}" since it is not a string or CrossScore ' \
|
||||
'Tally'
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -1219,7 +1219,7 @@ class Tally(IDManagerMixin):
|
|||
data = self.sum_sq[indices]
|
||||
else:
|
||||
msg = f'Unable to return results from Tally ID="{value}" since ' \
|
||||
'the requested value "{self.id}" is not \'mean\', ' \
|
||||
f'the requested value "{self.id}" is not \'mean\', ' \
|
||||
'\'std_dev\', \'rel_err\', \'sum\', or \'sum_sq\''
|
||||
raise LookupError(msg)
|
||||
|
||||
|
|
@ -1487,7 +1487,7 @@ class Tally(IDManagerMixin):
|
|||
# Check that results have been read
|
||||
if not other.derived and other.sum is None:
|
||||
msg = f'Unable to use tally arithmetic with Tally ' \
|
||||
'ID="{other.id}" since it does not contain any results.'
|
||||
f'ID="{other.id}" since it does not contain any results.'
|
||||
raise ValueError(msg)
|
||||
|
||||
new_tally = Tally()
|
||||
|
|
@ -1797,11 +1797,11 @@ class Tally(IDManagerMixin):
|
|||
return
|
||||
elif filter1 not in self.filters:
|
||||
msg = f'Unable to swap "{filter1.type}" filter1 in Tally ' \
|
||||
'ID="{self.id}" since it does not contain such a filter'
|
||||
f'ID="{self.id}" since it does not contain such a filter'
|
||||
raise ValueError(msg)
|
||||
elif filter2 not in self.filters:
|
||||
msg = f'Unable to swap "{filter2.type}" filter2 in Tally ' \
|
||||
'ID="{self.id}" since it does not contain such a filter'
|
||||
f'ID="{self.id}" since it does not contain such a filter'
|
||||
raise ValueError(msg)
|
||||
|
||||
# Construct lists of tuples for the bins in each of the two filters
|
||||
|
|
@ -1891,12 +1891,11 @@ class Tally(IDManagerMixin):
|
|||
raise ValueError(msg)
|
||||
elif nuclide1 not in self.nuclides:
|
||||
msg = f'Unable to swap nuclide1 "{nuclide1.name}" in Tally ' \
|
||||
'ID="{self.id}" since it does not contain such a nuclide'
|
||||
f'ID="{self.id}" since it does not contain such a nuclide'
|
||||
raise ValueError(msg)
|
||||
elif nuclide2 not in self.nuclides:
|
||||
msg = 'Unable to swap "{}" nuclide2 in Tally ID="{}" since it ' \
|
||||
'does not contain such a nuclide'\
|
||||
.format(nuclide2.name, self.id)
|
||||
msg = f'Unable to swap "{nuclide2.name}" nuclide2 in Tally ' \
|
||||
f'ID="{self.id}" since it does not contain such a nuclide'
|
||||
raise ValueError(msg)
|
||||
|
||||
# Swap the nuclides in the Tally
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ class Universe(UniverseBase):
|
|||
|
||||
if not isinstance(cell, openmc.Cell):
|
||||
msg = f'Unable to add a Cell to Universe ID="{self._id}" since ' \
|
||||
'"{cell}" is not a Cell'
|
||||
f'"{cell}" is not a Cell'
|
||||
raise TypeError(msg)
|
||||
|
||||
cell_id = cell.id
|
||||
|
|
@ -422,7 +422,7 @@ class Universe(UniverseBase):
|
|||
|
||||
if not isinstance(cells, Iterable):
|
||||
msg = f'Unable to add Cells to Universe ID="{self._id}" since ' \
|
||||
'"{cells}" is not iterable'
|
||||
f'"{cells}" is not iterable'
|
||||
raise TypeError(msg)
|
||||
|
||||
for cell in cells:
|
||||
|
|
@ -440,7 +440,7 @@ class Universe(UniverseBase):
|
|||
|
||||
if not isinstance(cell, openmc.Cell):
|
||||
msg = f'Unable to remove a Cell from Universe ID="{self._id}" ' \
|
||||
'since "{cell}" is not a Cell'
|
||||
f'since "{cell}" is not a Cell'
|
||||
raise TypeError(msg)
|
||||
|
||||
# If the Cell is in the Universe's list of Cells, delete it
|
||||
|
|
@ -491,8 +491,8 @@ class Universe(UniverseBase):
|
|||
nuclides[name] = (nuclide, density)
|
||||
else:
|
||||
raise RuntimeError(
|
||||
f'Volume information is needed to calculate microscopic cross '
|
||||
'sections for universe {self.id}. This can be done by running '
|
||||
'Volume information is needed to calculate microscopic cross '
|
||||
f'sections for universe {self.id}. This can be done by running '
|
||||
'a stochastic volume calculation via the '
|
||||
'openmc.VolumeCalculation object')
|
||||
|
||||
|
|
|
|||
|
|
@ -101,10 +101,10 @@ class VolumeCalculation:
|
|||
continue
|
||||
if (np.any(np.asarray(lower_left) > ll) or
|
||||
np.any(np.asarray(upper_right) < ur)):
|
||||
warnings.warn(
|
||||
f"Specified bounding box is smaller than computed "
|
||||
"bounding box for cell {c.id}. Volume calculation "
|
||||
"may be incorrect!")
|
||||
msg = ('Specified bounding box is smaller than '
|
||||
f'computed bounding box for cell {c.id}. Volume '
|
||||
'calculation may be incorrect!')
|
||||
warnings.warn(msg)
|
||||
|
||||
self.lower_left = lower_left
|
||||
self.upper_right = upper_right
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue