Skip to content

Commit

Permalink
reformat string concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed Dec 13, 2023
1 parent f869a39 commit 4ea13d5
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 36 deletions.
4 changes: 2 additions & 2 deletions lib/iris/analysis/_area_weighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _get_xy_coords(cube):
]
if len(x_coords) != 1:
raise ValueError(
"Cube {!r} must contain a single 1D x " "coordinate.".format(
"Cube {!r} must contain a single 1D x coordinate.".format(
cube.name()
)
)
Expand All @@ -191,7 +191,7 @@ def _get_xy_coords(cube):
]
if len(y_coords) != 1:
raise ValueError(
"Cube {!r} must contain a single 1D y " "coordinate.".format(
"Cube {!r} must contain a single 1D y coordinate.".format(
cube.name()
)
)
Expand Down
4 changes: 2 additions & 2 deletions lib/iris/analysis/_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_xy_coords(cube, dim_coords=False):
x_coords = cube.coords(axis="x", dim_coords=dim_coords)
if len(x_coords) != 1 or x_coords[0].ndim != 1:
raise ValueError(
"Cube {!r} must contain a single 1D x " "coordinate.".format(
"Cube {!r} must contain a single 1D x coordinate.".format(
cube.name()
)
)
Expand All @@ -148,7 +148,7 @@ def get_xy_coords(cube, dim_coords=False):
y_coords = cube.coords(axis="y", dim_coords=dim_coords)
if len(y_coords) != 1 or y_coords[0].ndim != 1:
raise ValueError(
"Cube {!r} must contain a single 1D y " "coordinate.".format(
"Cube {!r} must contain a single 1D y coordinate.".format(
cube.name()
)
)
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def _get_horizontal_coord(cube, axis):
coords = cube.coords(axis=axis, dim_coords=False)
if len(coords) != 1:
raise ValueError(
"Cube {!r} must contain a single 1D {} " "coordinate.".format(
"Cube {!r} must contain a single 1D {} coordinate.".format(
cube.name(), axis
)
)
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/cartography.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def cosine_latitude_weights(cube):
lat = lat_coords[0]
except IndexError:
raise ValueError(
"Cannot get latitude " "coordinate from cube {!r}.".format(
"Cannot get latitude coordinate from cube {!r}.".format(
cube.name()
)
)
Expand Down
4 changes: 2 additions & 2 deletions lib/iris/coord_categorisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def _validate_seasons(seasons):
]
if not_present:
raise ValueError(
"some months do not appear in any season: " "{!s}".format(
"some months do not appear in any season: {!s}".format(
", ".join(not_present)
)
)
Expand All @@ -265,7 +265,7 @@ def _validate_seasons(seasons):
]
if multi_present:
raise ValueError(
"some months appear in more than one season: " "{!s}".format(
"some months appear in more than one season: {!s}".format(
", ".join(multi_present)
)
)
Expand Down
14 changes: 7 additions & 7 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def _extract_and_merge(
for constraint in constraints:
constraint_cubes = constraint_groups[constraint]
if strict and len(constraint_cubes) != 1:
msg = "Got %s cubes for constraint %r, " "expecting 1." % (
msg = "Got %s cubes for constraint %r, expecting 1." % (
len(constraint_cubes),
constraint,
)
Expand Down Expand Up @@ -617,7 +617,7 @@ def concatenate_cube(
msgs = []
msgs.append("An unexpected problem prevented concatenation.")
msgs.append(
"Expected only a single cube, " "found {}.".format(
"Expected only a single cube, found {}.".format(
n_res_cubes
)
)
Expand Down Expand Up @@ -1790,7 +1790,7 @@ def _add_unique_dim_coord(self, dim_coord, data_dim):
if isinstance(data_dim, Container):
if len(data_dim) != 1:
raise iris.exceptions.CannotAddError(
"The supplied data dimension must be a" " single number."
"The supplied data dimension must be a single number."
)
data_dim = int(list(data_dim)[0])
else:
Expand Down Expand Up @@ -2273,7 +2273,7 @@ def extract_coord(coord_or_factory):
elif isinstance(coord_or_factory, iris.coords.Coord):
coord = coord_or_factory
else:
msg = "Expected Coord or AuxCoordFactory, got " "{!r}.".format(
msg = "Expected Coord or AuxCoordFactory, got {!r}.".format(
type(coord_or_factory)
)
raise ValueError(msg)
Expand Down Expand Up @@ -3669,7 +3669,7 @@ def slices(self, ref_to_slice, ordered=True):
dim = int(ref)
except ValueError:
raise ValueError(
"{} Incompatible type {} for " "slicing".format(
"{} Incompatible type {} for slicing".format(
ref, type(ref)
)
)
Expand Down Expand Up @@ -3955,7 +3955,7 @@ def copy(self, data=None):
def __copy__(self):
"""Shallow copying is disallowed for Cubes."""
raise copy.Error(
"Cube shallow-copy not allowed. Use deepcopy() or " "Cube.copy()"
"Cube shallow-copy not allowed. Use deepcopy() or Cube.copy()"
)

def __deepcopy__(self, memo):
Expand Down Expand Up @@ -5028,7 +5028,7 @@ class ClassDict(MutableMapping):
def __init__(self, superclass):
if not isinstance(superclass, type):
raise TypeError(
"The superclass must be a Python type or new " "style class."
"The superclass must be a Python type or new style class."
)
self._superclass = superclass
self._basic_map = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/iris/fileformats/abf.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, filename):
basename = os.path.basename(filename)
if len(basename) != 24:
raise ValueError(
"ABFField expects a filename of 24 characters: " "{}".format(
"ABFField expects a filename of 24 characters: {}".format(
basename
)
)
Expand Down Expand Up @@ -168,7 +168,7 @@ def to_cube(self):
end = calendar.monthrange(self.year, self.month)[1]
else:
raise iris.exceptions.TranslationError(
"Unknown period: " "{}".format(self.period)
"Unknown period: {}".format(self.period)
)

start = datetime.date(year=self.year, month=self.month, day=start)
Expand Down
4 changes: 1 addition & 3 deletions lib/iris/fileformats/netcdf/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,7 @@ def coord_from_term(term):
if cf_var_name == name:
return coord
warnings.warn(
"Unable to find coordinate for variable " "{!r}".format(
name
),
"Unable to find coordinate for variable {!r}".format(name),
category=iris.exceptions.IrisFactoryCoordNotFoundWarning,
)

Expand Down
4 changes: 2 additions & 2 deletions lib/iris/fileformats/nimrod.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _read_header(self, infile):
trailing_length = struct.unpack(">L", infile.read(4))[0]
if trailing_length != leading_length:
raise TranslationError(
"Expected header trailing_length of {}, " "got {}.".format(
"Expected header trailing_length of {}, got {}.".format(
leading_length, trailing_length
)
)
Expand Down Expand Up @@ -266,7 +266,7 @@ def _read_data(self, infile):
numpy_dtype = np.int32
else:
raise TranslationError(
"Undefined datum length " "%d" % self.datum_type
"Undefined datum length %d" % self.datum_type
)
# 2:byte
elif self.datum_type == 2:
Expand Down
4 changes: 2 additions & 2 deletions lib/iris/fileformats/nimrod_load_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def horizontal_grid(cube, field, handle_metadata_errors):
y_coord_name = "latitude"
else:
raise TranslationError(
"Horizontal grid type {} not " "implemented".format(
"Horizontal grid type {} not implemented".format(
field.horizontal_grid_type
)
)
Expand Down Expand Up @@ -595,7 +595,7 @@ def vertical_coord(cube, field):
return

warnings.warn(
"Vertical coord {!r} not yet handled" "".format(
"Vertical coord {!r} not yet handled".format(
field.vertical_coord_type
),
category=TranslationWarning,
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ def fetch_valid_values_array():
# Check whether this field uses a land or a sea mask.
if field.lbpack.n3 not in (1, 2):
raise ValueError(
"Unsupported mask compression : " "lbpack.n3 = {}.".format(
"Unsupported mask compression : lbpack.n3 = {}.".format(
field.lbpack.n3
)
)
Expand Down
10 changes: 4 additions & 6 deletions lib/iris/fileformats/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ def aux_factory(cube, aux_factory_class):
]
if not aux_factories:
raise ValueError(
"Cube does not have an aux factory of " "type {!r}.".format(
"Cube does not have an aux factory of type {!r}.".format(
aux_factory_class
)
)
elif len(aux_factories) > 1:
raise ValueError(
"Cube has more than one aux factory of " "type {!r}.".format(
"Cube has more than one aux factory of type {!r}.".format(
aux_factory_class
)
)
Expand Down Expand Up @@ -175,13 +175,11 @@ def _dereference_args(factory, reference_targets, regrid_cache, cube):
args.append(new_coord)
else:
raise _ReferenceError(
"Unable to regrid reference for" " {!r}".format(
arg.name
)
"Unable to regrid reference for {!r}".format(arg.name)
)
else:
raise _ReferenceError(
"The source data contains no " "field(s) for {!r}.".format(
"The source data contains no field(s) for {!r}.".format(
arg.name
)
)
Expand Down
6 changes: 2 additions & 4 deletions lib/iris/quickplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ def _label(cube, mode, result=None, ndims=2, coords=None, axes=None):
axes.set_xlabel(_title(plot_defn.coords[0], with_units=True))
axes.set_ylabel(_title(cube, with_units=True))
else:
msg = (
"Unexpected number of dimensions ({}) given to " "_label.".format(
ndims
)
msg = "Unexpected number of dimensions ({}) given to _label.".format(
ndims
)
raise ValueError(msg)

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/unit/fileformats/pp/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def check_cube_name_units_yields_lbfc(self, name, units, lbfc_expected):
self.assertEqual(
lbfc_produced,
lbfc_expected,
"Lbfc for ({!r} / {!r}) should be {:d}, " "got {:d}".format(
"Lbfc for ({!r} / {!r}) should be {:d}, got {:d}".format(
name, units, lbfc_expected, lbfc_produced
),
)
Expand Down

0 comments on commit 4ea13d5

Please sign in to comment.