diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 97625b8d..3f039325 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,7 +78,7 @@ repos: types: [file, python] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.8.6" + rev: "v0.9.1" hooks: - id: ruff types: [file, python] diff --git a/noxfile.py b/noxfile.py index 1b77a7d5..f04ee7b4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -81,9 +81,7 @@ def _write_iris_config(session: nox.sessions.Session) -> None: [Resources] test_data_dir = {test_data_dir} [System] -udunits2_path = { - os.path.join(session.virtualenv.location,'lib', 'libudunits2.so') -} +udunits2_path = {os.path.join(session.virtualenv.location, "lib", "libudunits2.so")} """ print("Iris config\n-----------") diff --git a/src/iris_grib/__init__.py b/src/iris_grib/__init__.py index 7e50015b..e65f5e14 100644 --- a/src/iris_grib/__init__.py +++ b/src/iris_grib/__init__.py @@ -49,7 +49,7 @@ "rjtd": "Tokyo, Japan Meteorological Agency", "55": "San Francisco", "kwbc": ( - "US National Weather Service, National Centres for " "Environmental Prediction" + "US National Weather Service, National Centres for Environmental Prediction" ), } @@ -612,7 +612,7 @@ def _get_verification_date(self): # for all the days included in the P2 period. The units of P2 # are given by the contents of octet 18 and Table 4. raise TranslationError( - "unhandled grib1 timeRangeIndicator " "= 51 (avg of avgs)" + "unhandled grib1 timeRangeIndicator = 51 (avg of avgs)" ) elif time_range_indicator == 113: # Average of N forecasts (or initialized analyses); each @@ -661,7 +661,7 @@ def _get_verification_date(self): time_diff = P1 else: raise TranslationError( - "unhandled grib1 timeRangeIndicator " "= %i" % time_range_indicator + "unhandled grib1 timeRangeIndicator = %i" % time_range_indicator ) # Get the timeunit interval. diff --git a/src/iris_grib/_grib1_load_rules.py b/src/iris_grib/_grib1_load_rules.py index d5f6bed2..6ef233ee 100644 --- a/src/iris_grib/_grib1_load_rules.py +++ b/src/iris_grib/_grib1_load_rules.py @@ -157,7 +157,7 @@ def grib1_convert(grib): (grib.table2Version == 1) and (grib.indicatorOfParameter >= 128) ): long_name = ( - f"UNKNOWN LOCAL PARAM {grib.indicatorOfParameter}" f".{grib.table2Version}" + f"UNKNOWN LOCAL PARAM {grib.indicatorOfParameter}.{grib.table2Version}" ) units = "???" diff --git a/src/iris_grib/_load_convert.py b/src/iris_grib/_load_convert.py index 8f31650d..3d908a58 100644 --- a/src/iris_grib/_load_convert.py +++ b/src/iris_grib/_load_convert.py @@ -222,7 +222,7 @@ def _hindcast_fix(forecast_time): original_forecast_time = forecast_time forecast_time = -(uft - 2 * HIGHBIT) if options.warn_on_unsupported: - msg = "Re-interpreting large grib forecastTime " "from {} to {}.".format( + msg = "Re-interpreting large grib forecastTime from {} to {}.".format( original_forecast_time, forecast_time ) warnings.warn(msg, HindcastOverflowWarning) @@ -521,7 +521,7 @@ def grid_definition_template_0_and_1(section, metadata, y_name, x_name, cs): section["numberOfOctectsForNumberOfPoints"] != 0 or section["interpretationOfNumberOfPoints"] != 0 ): - msg = "Grid definition section 3 contains unsupported " "quasi-regular grid" + msg = "Grid definition section 3 contains unsupported quasi-regular grid" raise TranslationError(msg) scan = scanning_mode(section["scanningMode"]) @@ -1259,7 +1259,7 @@ def grid_definition_template_90(section, metadata): # diameters rely on the satellite being over the equator. if sub_satellite_lat != 0: raise TranslationError( - "Unsupported non-zero latitude for " "space-view perspective." + "Unsupported non-zero latitude for space-view perspective." ) sub_satellite_lon = ( section["longitudeOfSubSatellitePoint"] * _GRID_ACCURACY_IN_DEGREES @@ -2018,13 +2018,9 @@ def generating_process(section, include_forecast_process=True): if options.warn_on_unsupported: # Reference Code Table 4.3. warnings.warn("Unable to translate type of generating process.") - warnings.warn( - "Unable to translate background generating " "process identifier." - ) + warnings.warn("Unable to translate background generating process identifier.") if include_forecast_process: - warnings.warn( - "Unable to translate forecast generating " "process identifier." - ) + warnings.warn("Unable to translate forecast generating process identifier.") def data_cutoff(hoursAfterDataCutoff, minutesAfterDataCutoff): @@ -2043,7 +2039,7 @@ def data_cutoff(hoursAfterDataCutoff, minutesAfterDataCutoff): if hoursAfterDataCutoff != _MDI or minutesAfterDataCutoff != _MDI: if options.warn_on_unsupported: warnings.warn( - 'Unable to translate "hours and/or minutes ' 'after data cutoff".' + 'Unable to translate "hours and/or minutes after data cutoff".' ) @@ -2060,8 +2056,7 @@ def statistical_method_name(section): else: # This should *never* happen, as only called by pdt 8 and 15. msg = ( - "Internal error: can't get statistical method for unsupported " - "pdt : 4.{:d}." + "Internal error: can't get statistical method for unsupported pdt : 4.{:d}." ) raise ValueError(msg.format(section_number)) statistic_code = section[stat_keyname] @@ -2117,7 +2112,7 @@ def statistical_cell_method(section): # is all we currently support. # The exact interpretation of this is still unclear so we also accept # a missing value. - msg = "grib statistic time-increment type [{}] " "is not supported.".format( + msg = "grib statistic time-increment type [{}] is not supported.".format( increment_typecode ) raise TranslationError(msg) @@ -2337,17 +2332,11 @@ def product_definition_template_9(section, metadata, frt_coord): # Type is "above upper level". threshold_value = section["scaledValueOfUpperLimit"] if threshold_value == _MDI: - msg = ( - "Product definition section 4 has missing " - "scaled value of upper limit" - ) + msg = "Product definition section 4 has missing scaled value of upper limit" raise TranslationError(msg) threshold_scaling = section["scaleFactorOfUpperLimit"] if threshold_scaling == _MDI: - msg = ( - "Product definition section 4 has missing " - "scale factor of upper limit" - ) + msg = "Product definition section 4 has missing scale factor of upper limit" raise TranslationError(msg) # Encode threshold information. threshold = unscale(threshold_value, threshold_scaling) @@ -2668,7 +2657,7 @@ def product_definition_section(section, metadata, discipline, tablesVersion, rt_ elif template == 40: product_definition_template_40(section, metadata, rt_coord) else: - msg = "Product definition template [{}] is not " "supported".format(template) + msg = "Product definition template [{}] is not supported".format(template) raise TranslationError(msg) # Translate GRIB2 phenomenon to CF phenomenon. @@ -2722,7 +2711,7 @@ def data_representation_section(section): supported_templates = grid_point_templates + spectral_templates if template not in supported_templates: - msg = "Data Representation Section Template [{}] is not " "supported".format( + msg = "Data Representation Section Template [{}] is not supported".format( template ) raise TranslationError(msg) @@ -2757,7 +2746,7 @@ def bitmap_section(section): bitMapIndicator = section["bitMapIndicator"] if bitMapIndicator not in [_BITMAP_CODE_NONE, _BITMAP_CODE_PRESENT]: - msg = "Bitmap Section 6 contains unsupported " "bitmap indicator [{}]".format( + msg = "Bitmap Section 6 contains unsupported bitmap indicator [{}]".format( bitMapIndicator ) raise TranslationError(msg) diff --git a/src/iris_grib/_save_rules.py b/src/iris_grib/_save_rules.py index f8b5b067..47af1e28 100644 --- a/src/iris_grib/_save_rules.py +++ b/src/iris_grib/_save_rules.py @@ -219,13 +219,13 @@ def dx_dy(x_coord, y_coord, grib): eccodes.codes_set(grib, "iDirectionIncrement", round(1e6 * float(abs(x_step)))) else: raise ValueError( - "X coordinate must be in degrees, not {}" ".".format(x_coord.units) + "X coordinate must be in degrees, not {}.".format(x_coord.units) ) if y_coord.units == "degrees": eccodes.codes_set(grib, "jDirectionIncrement", round(1e6 * float(abs(y_step)))) else: raise ValueError( - "Y coordinate must be in degrees, not {}" ".".format(y_coord.units) + "Y coordinate must be in degrees, not {}.".format(y_coord.units) ) @@ -525,7 +525,7 @@ def grid_definition_template_12(cube, grib): x_step = step(x_cm, atol=1) y_step = step(y_cm, atol=1) except ValueError: - msg = "Irregular coordinates not supported for Transverse " "Mercator." + msg = "Irregular coordinates not supported for Transverse Mercator." raise TranslationError(msg) eccodes.codes_set(grib, "Di", abs(x_step)) eccodes.codes_set(grib, "Dj", abs(y_step)) @@ -747,7 +747,7 @@ def grid_definition_template_140(cube, grib): x_step = step(x_mm, atol=1) y_step = step(y_mm, atol=1) except ValueError: - msg = "Irregular coordinates not supported for Lambert " "Azimuthal Equal Area." + msg = "Irregular coordinates not supported for Lambert Azimuthal Equal Area." raise TranslationError(msg) eccodes.codes_set(grib, "Dx", abs(x_step)) eccodes.codes_set(grib, "Dy", abs(y_step)) @@ -934,12 +934,12 @@ def _non_missing_forecast_period(cube): else: if not fp_coord.has_bounds(): raise TranslationError( - "bounds on 'time' coordinate requires bounds on" " 'forecast_period'." + "bounds on 'time' coordinate requires bounds on 'forecast_period'." ) fp = fp_coord.bounds[0][0] if fp - int(fp): - warnings.warn("forecast_period encoding problem: " "scaling required.") + warnings.warn("forecast_period encoding problem: scaling required.") fp = int(fp) return rt, rt_meaning, fp, grib_time_code @@ -973,7 +973,7 @@ def _missing_forecast_period(cube): fp = t - frt integer_fp = int(fp) if integer_fp != fp: - msg = "Truncating floating point forecast period {} to " "integer value {}" + msg = "Truncating floating point forecast period {} to integer value {}" warnings.warn(msg.format(fp, integer_fp)) fp = integer_fp fp_meaning = 1 # Hours @@ -1168,7 +1168,7 @@ def set_fixed_surfaces(cube, grib, full3d_cube=None): n_levels = np.max(model_levels) max_valid_nlevels = 9999 if n_levels > max_valid_nlevels: - msg = "model_level_number values are > {} : " "maximum value = {}." + msg = "model_level_number values are > {} : maximum value = {}." raise ValueError(msg.format(max_valid_nlevels, n_levels)) # In sample data we have seen, there seems to be an extra missing data # value *before* each set of n-levels coefficients. @@ -1226,7 +1226,7 @@ def set_time_range(time_coord, grib): time_range_in_hours = end_hours - start_hours integer_hours = int(time_range_in_hours) if integer_hours != time_range_in_hours: - msg = "Truncating floating point lengthOfTimeRange {} to " "integer value {}" + msg = "Truncating floating point lengthOfTimeRange {} to integer value {}" warnings.warn(msg.format(time_range_in_hours, integer_hours)) eccodes.codes_set(grib, "lengthOfTimeRange", integer_hours) @@ -1580,9 +1580,7 @@ def _product_definition_template_8_10_and_11(cube, grib, full3d_cube=None): if "time" in cell_method.coord_names ] if not time_cell_methods: - raise ValueError( - "Expected a cell method with a coordinate name " "of 'time'" - ) + raise ValueError("Expected a cell method with a coordinate name of 'time'") if len(time_cell_methods) > 1: raise ValueError("Cannot handle multiple 'time' cell methods") (cell_method,) = time_cell_methods diff --git a/src/iris_grib/grib_phenom_translation/__init__.py b/src/iris_grib/grib_phenom_translation/__init__.py index 1fcb5e60..d32bcaca 100644 --- a/src/iris_grib/grib_phenom_translation/__init__.py +++ b/src/iris_grib/grib_phenom_translation/__init__.py @@ -56,8 +56,9 @@ def __getitem__(self, key): def __setitem__(self, key, value): if key in self and self[key] is not value: raise KeyError( - "Attempted to set dict[{}] = {}, " - "but this is already set to {}.".format(key, value, self[key]) + "Attempted to set dict[{}] = {}, but this is already set to {}.".format( + key, value, self[key] + ) ) self._super.__setitem__(key, value) @@ -106,7 +107,7 @@ def _make_grib1_cf_entry( if standard_name is not None: if standard_name not in iris.std_names.STD_NAMES: warnings.warn( - "{} is not a recognised CF standard name " "(skipping).".format( + "{} is not a recognised CF standard name (skipping).".format( standard_name ) ) @@ -156,8 +157,9 @@ def _make_grib1_cf_entry( ) if len(extra_dimcoord.points) != 1: raise ValueError( - "Implied dimension has {} points, " - "currently can only handle 1.".format(len(extra_dimcoord.points)) + "Implied dimension has {} points, currently can only handle 1.".format( + len(extra_dimcoord.points) + ) ) association_entry = _make_grib1_cf_entry( table2_version=int(grib1data.t2version), @@ -211,7 +213,7 @@ def _make_grib2_cf_entry( if standard_name is not None: if standard_name not in iris.std_names.STD_NAMES: warnings.warn( - "{} is not a recognised CF standard name " "(skipping).".format( + "{} is not a recognised CF standard name (skipping).".format( standard_name ) ) @@ -273,7 +275,7 @@ def _make_cf_grib2_entry( long_name = None if standard_name not in iris.std_names.STD_NAMES: warnings.warn( - "{} is not a recognised CF standard name " "(skipping).".format( + "{} is not a recognised CF standard name (skipping).".format( standard_name ) ) diff --git a/src/iris_grib/grib_phenom_translation/_gribcode.py b/src/iris_grib/grib_phenom_translation/_gribcode.py index 5cd92676..78d007cd 100644 --- a/src/iris_grib/grib_phenom_translation/_gribcode.py +++ b/src/iris_grib/grib_phenom_translation/_gribcode.py @@ -14,7 +14,7 @@ def _invalid_edition(edition): - msg = f"Invalid grib edition, {edition!r}, for GRIBcode : " "can only be 1 or 2." + msg = f"Invalid grib edition, {edition!r}, for GRIBcode : can only be 1 or 2." raise ValueError(msg) @@ -135,9 +135,7 @@ def __init__(self, **kwargs): setattr(self, key, value) def _broken_repr(self): - result = ( - f"<{self.__class__.__name__} with invalid content: " f"{self.__dict__}>" - ) + result = f"<{self.__class__.__name__} with invalid content: {self.__dict__}>" return result def __str__(self): diff --git a/src/iris_grib/message.py b/src/iris_grib/message.py index 9adcc3db..1c03add1 100644 --- a/src/iris_grib/message.py +++ b/src/iris_grib/message.py @@ -157,7 +157,7 @@ def data(self): template = grid_section["gridDefinitionTemplateNumber"] if reduced and template not in (40,): raise TranslationError( - "Grid definition Section 3 contains " "unsupported quasi-regular grid." + "Grid definition Section 3 contains unsupported quasi-regular grid." ) if template in _SUPPORTED_GRID_DEFINITIONS: @@ -265,10 +265,8 @@ def _bitmap(self, bitmap_section): elif bitMapIndicator == 255: bitmap = None else: - msg = ( - "Bitmap Section 6 contains unsupported " "bitmap indicator [{}]".format( - bitMapIndicator - ) + msg = "Bitmap Section 6 contains unsupported bitmap indicator [{}]".format( + bitMapIndicator ) raise TranslationError(msg) return bitmap @@ -490,7 +488,7 @@ def __setitem__(self, key, value): self._cache[key] = value else: raise KeyError( - "{!r} cannot be redefined in " "section {}".format(key, self._number) + "{!r} cannot be redefined in section {}".format(key, self._number) ) def _get_key_value(self, key): diff --git a/src/iris_grib/tests/integration/round_trip/test_grid_definition_section.py b/src/iris_grib/tests/integration/round_trip/test_grid_definition_section.py index 77e5668e..0b885bff 100644 --- a/src/iris_grib/tests/integration/round_trip/test_grid_definition_section.py +++ b/src/iris_grib/tests/integration/round_trip/test_grid_definition_section.py @@ -107,7 +107,7 @@ def test_save_load(self): self.assertEqual( co_load.shape, co_orig.shape, - 'Shape of re-loaded "{}" coord is {} ' "instead of {}".format( + 'Shape of re-loaded "{}" coord is {} instead of {}'.format( coord_name, co_load.shape, co_orig.shape ), ) diff --git a/src/iris_grib/tests/test_license_headers.py b/src/iris_grib/tests/test_license_headers.py index 7779bc2b..61c086c1 100644 --- a/src/iris_grib/tests/test_license_headers.py +++ b/src/iris_grib/tests/test_license_headers.py @@ -100,9 +100,7 @@ def test_license_headers(self): last_change_by_fname = self.last_change_by_fname() except ValueError: # Caught the case where this is not a git repo. - return self.skipTest( - "Iris-grib installation did not look like a " "git repo." - ) + return self.skipTest("Iris-grib installation did not look like a git repo.") failed = False for fname, last_change in sorted(last_change_by_fname.items()): diff --git a/src/iris_grib/tests/unit/grib1_load_rules/test_grib1_load_translations.py b/src/iris_grib/tests/unit/grib1_load_rules/test_grib1_load_translations.py index caf876ee..78c1bcff 100644 --- a/src/iris_grib/tests/unit/grib1_load_rules/test_grib1_load_translations.py +++ b/src/iris_grib/tests/unit/grib1_load_rules/test_grib1_load_translations.py @@ -296,7 +296,7 @@ def test_warn_unknown_pdts(self): with self.assertRaises(iris.exceptions.TranslationError) as t_err: _ = next(cube_generator) self.assertEqual( - "Product definition template [5]" " is not supported", + "Product definition template [5] is not supported", str(t_err.exception), ) diff --git a/src/iris_grib/tests/unit/grib_phenom_translation/test_grib_phenom_translation.py b/src/iris_grib/tests/unit/grib_phenom_translation/test_grib_phenom_translation.py index d16c7f7a..a8fafb8b 100644 --- a/src/iris_grib/tests/unit/grib_phenom_translation/test_grib_phenom_translation.py +++ b/src/iris_grib/tests/unit/grib_phenom_translation/test_grib_phenom_translation.py @@ -345,10 +345,10 @@ def check__repr__(self, edition): result = repr(GRIBCode(edition, 17, 3, 123)) if edition == 1: expected = ( - "GRIBCode(edition=1, table_version=17, " "centre_number=3, number=123)" + "GRIBCode(edition=1, table_version=17, centre_number=3, number=123)" ) elif edition == 2: - expected = "GRIBCode(edition=2, discipline=17, " "category=3, number=123)" + expected = "GRIBCode(edition=2, discipline=17, category=3, number=123)" self.assertEqual(result, expected) def test__repr__grib1(self): diff --git a/src/iris_grib/tests/unit/load_convert/test_product_definition_template_0.py b/src/iris_grib/tests/unit/load_convert/test_product_definition_template_0.py index 9b317ff8..a53bd015 100644 --- a/src/iris_grib/tests/unit/load_convert/test_product_definition_template_0.py +++ b/src/iris_grib/tests/unit/load_convert/test_product_definition_template_0.py @@ -93,8 +93,8 @@ def test_generating_process_warnings(self): warn_msgs = [call[1][0] for call in warn.mock_calls] expected = [ "Unable to translate type of generating process.", - "Unable to translate background generating process " "identifier.", - "Unable to translate forecast generating process " "identifier.", + "Unable to translate background generating process identifier.", + "Unable to translate forecast generating process identifier.", ] self.assertEqual(warn_msgs, expected) finally: diff --git a/src/iris_grib/tests/unit/save_rules/test__product_definition_template_8_10_and_11.py b/src/iris_grib/tests/unit/save_rules/test__product_definition_template_8_10_and_11.py index fd6b0ba4..2d903226 100644 --- a/src/iris_grib/tests/unit/save_rules/test__product_definition_template_8_10_and_11.py +++ b/src/iris_grib/tests/unit/save_rules/test__product_definition_template_8_10_and_11.py @@ -70,7 +70,7 @@ def test_cell_method_coord_name_fail(self, mock_set): cell_method = CellMethod(method="mean", coords=["season"]) cube.add_cell_method(cell_method) with self.assertRaisesRegex( - ValueError, "Expected a cell method with a coordinate " "name of 'time'" + ValueError, "Expected a cell method with a coordinate name of 'time'" ): _product_definition_template_8_10_and_11(cube, mock.sentinel.grib) @@ -102,7 +102,7 @@ def test_no_bounds(self, mock_set): ) self.cube.add_aux_coord(coord) with self.assertRaisesRegex( - ValueError, "Expected time coordinate with two bounds, " "got 0 bounds" + ValueError, "Expected time coordinate with two bounds, got 0 bounds" ): _product_definition_template_8_10_and_11(self.cube, mock.sentinel.grib) @@ -117,7 +117,7 @@ def test_more_than_two_bounds(self, mock_set): ) self.cube.add_aux_coord(coord) with self.assertRaisesRegex( - ValueError, "Expected time coordinate with two bounds, " "got 3 bounds" + ValueError, "Expected time coordinate with two bounds, got 3 bounds" ): _product_definition_template_8_10_and_11(self.cube, mock.sentinel.grib) diff --git a/src/iris_grib/tests/unit/save_rules/test_data_section.py b/src/iris_grib/tests/unit/save_rules/test_data_section.py index 81f073e5..5493ca4e 100644 --- a/src/iris_grib/tests/unit/save_rules/test_data_section.py +++ b/src/iris_grib/tests/unit/save_rules/test_data_section.py @@ -51,7 +51,7 @@ def assertBitmapRange(self, grib_api, min_data, max_data): self.assertEqual(key, "missingValue") self.assertTrue( fill_value < min_data or fill_value > max_data, - "Fill value {} is not outside data range " "{} to {}.".format( + "Fill value {} is not outside data range {} to {}.".format( fill_value, min_data, max_data ), ) diff --git a/src/iris_grib/tests/unit/save_rules/test_product_definition_template_10.py b/src/iris_grib/tests/unit/save_rules/test_product_definition_template_10.py index 64cc01a9..230a1d73 100644 --- a/src/iris_grib/tests/unit/save_rules/test_product_definition_template_10.py +++ b/src/iris_grib/tests/unit/save_rules/test_product_definition_template_10.py @@ -52,9 +52,7 @@ def test_multiple_percentile_value(self, mock_set): cube = self.cube percentile_coord = DimCoord([5, 10, 15], long_name="percentile_over_time") cube.add_aux_coord(percentile_coord, 0) - err_msg = ( - "A cube 'percentile_over_time' coordinate with one point " "is required" - ) + err_msg = "A cube 'percentile_over_time' coordinate with one point is required" with self.assertRaisesRegex(ValueError, err_msg): product_definition_template_10(cube, mock.sentinel.grib) diff --git a/src/iris_grib/tests/unit/save_rules/test_product_definition_template_15.py b/src/iris_grib/tests/unit/save_rules/test_product_definition_template_15.py index 458d03bf..814562b8 100644 --- a/src/iris_grib/tests/unit/save_rules/test_product_definition_template_15.py +++ b/src/iris_grib/tests/unit/save_rules/test_product_definition_template_15.py @@ -56,7 +56,7 @@ def test_cell_method(self, mock_set): @mock.patch.object(eccodes, "codes_set") def test_bilinear_interpolation(self, mock_set): cube_1 = self.cube - cube_1.attributes = dict(spatial_processing_type="Bilinear " "interpolation") + cube_1.attributes = dict(spatial_processing_type="Bilinear interpolation") # If the cube has a bilinear interpolation attribute, spatial # processing code should be 1 and number of points used should be 4. @@ -70,7 +70,7 @@ def test_bilinear_interpolation(self, mock_set): @mock.patch.object(eccodes, "codes_set") def test_bicubic_interpolation(self, mock_set): cube_2 = self.cube - cube_2.attributes = dict(spatial_processing_type="Bicubic " "interpolation") + cube_2.attributes = dict(spatial_processing_type="Bicubic interpolation") # If the cube has a bicubic interpolation attribute, spatial # processing code should be 2 and number of points used should be 4. @@ -85,7 +85,7 @@ def test_bicubic_interpolation(self, mock_set): def test_nearest_neighbour_interpolation(self, mock_set): cube_3 = self.cube cube_3.attributes = dict( - spatial_processing_type="Nearest neighbour " "interpolation" + spatial_processing_type="Nearest neighbour interpolation" ) # If the cube has a nearest neighbour interpolation attribute, spatial @@ -100,7 +100,7 @@ def test_nearest_neighbour_interpolation(self, mock_set): @mock.patch.object(eccodes, "codes_set") def test_budget_interpolation(self, mock_set): cube_4 = self.cube - cube_4.attributes = dict(spatial_processing_type="Budget " "interpolation") + cube_4.attributes = dict(spatial_processing_type="Budget interpolation") # If the cube has a budget interpolation attribute, spatial # processing code should be 4 and number of points used should be 4. @@ -114,7 +114,7 @@ def test_budget_interpolation(self, mock_set): @mock.patch.object(eccodes, "codes_set") def test_spectral_interpolation(self, mock_set): cube_5 = self.cube - cube_5.attributes = dict(spatial_processing_type="Spectral " "interpolation") + cube_5.attributes = dict(spatial_processing_type="Spectral interpolation") # If the cube has a spectral interpolation attribute, spatial # processing code should be 5 and number of points used should be 4. @@ -129,7 +129,7 @@ def test_spectral_interpolation(self, mock_set): def test_neighbour_budget_interpolation(self, mock_set): cube_6 = self.cube cube_6.attributes = dict( - spatial_processing_type="Neighbour-budget " "interpolation" + spatial_processing_type="Neighbour-budget interpolation" ) # If the cube has a neighbour-budget interpolation attribute, spatial diff --git a/src/iris_grib/tests/unit/save_rules/test_set_time_increment.py b/src/iris_grib/tests/unit/save_rules/test_set_time_increment.py index 6f44d88d..643855ae 100644 --- a/src/iris_grib/tests/unit/save_rules/test_set_time_increment.py +++ b/src/iris_grib/tests/unit/save_rules/test_set_time_increment.py @@ -81,7 +81,7 @@ def test_fractional_hours(self, mock_set): with mock.patch("warnings.warn") as warn: set_time_increment(cell_method, mock.sentinel.grib) warn.assert_called_once_with( - "Truncating floating point timeIncrement " "25.9 to integer value 25" + "Truncating floating point timeIncrement 25.9 to integer value 25" ) mock_set.assert_any_call( mock.sentinel.grib, "indicatorOfUnitForTimeIncrement", 1 diff --git a/src/iris_grib/tests/unit/save_rules/test_set_time_range.py b/src/iris_grib/tests/unit/save_rules/test_set_time_range.py index d2f1dacb..8ba5bfff 100644 --- a/src/iris_grib/tests/unit/save_rules/test_set_time_range.py +++ b/src/iris_grib/tests/unit/save_rules/test_set_time_range.py @@ -30,14 +30,14 @@ def setUp(self): def test_no_bounds(self): with self.assertRaisesRegex( - ValueError, "Expected time coordinate " "with two bounds, got 0 bounds" + ValueError, "Expected time coordinate with two bounds, got 0 bounds" ): set_time_range(self.coord, mock.sentinel.grib) def test_three_bounds(self): self.coord.bounds = [0, 1, 2] with self.assertRaisesRegex( - ValueError, "Expected time coordinate " "with two bounds, got 3 bounds" + ValueError, "Expected time coordinate with two bounds, got 3 bounds" ): set_time_range(self.coord, mock.sentinel.grib) @@ -49,7 +49,7 @@ def test_non_scalar(self): units=Unit("hours since epoch", calendar="standard"), ) with self.assertRaisesRegex( - ValueError, "Expected length one time " "coordinate, got 2 points" + ValueError, "Expected length one time coordinate, got 2 points" ): set_time_range(coord, mock.sentinel.grib)