Skip to content

Commit b08cfa6

Browse files
[pre-commit.ci] pre-commit autoupdate (#5150)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 22.12.0 → 23.1.0](psf/black@22.12.0...23.1.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7da248c commit b08cfa6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+49
-97
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
- id: no-commit-to-branch
3030

3131
- repo: https://github.com/psf/black
32-
rev: 22.12.0
32+
rev: 23.1.0
3333
hooks:
3434
- id: black
3535
pass_filenames: false

docs/gallery_code/general/plot_lineplot_with_legend.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def main():
2424
)
2525

2626
for cube in temperature.slices("longitude"):
27-
2827
# Create a string label to identify this cube (i.e. latitude: value).
2928
cube_label = "latitude: %s" % cube.coord("latitude").points[0]
3029

docs/gallery_code/general/plot_projections_and_annotations.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727

2828
def make_plot(projection_name, projection_crs):
29-
3029
# Create a matplotlib Figure.
3130
plt.figure()
3231

docs/gallery_code/general/plot_zonal_means.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
def main():
19-
2019
# Loads air_temp.pp and "collapses" longitude into a single, average value.
2120
fname = iris.sample_data_path("air_temp.pp")
2221
temperature = iris.load_cube(fname)

docs/gallery_code/meteorology/plot_lagged_ensemble.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def main():
8686

8787
# Iterate over all possible latitude longitude slices.
8888
for cube in last_timestep.slices(["latitude", "longitude"]):
89-
9089
# Get the ensemble member number from the ensemble coordinate.
9190
ens_member = cube.coord("realization").points[0]
9291

docs/src/userguide/plotting_examples/1d_with_legend.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
temperature = temperature[5:9, :]
1414

1515
for cube in temperature.slices("longitude"):
16-
1716
# Create a string label to identify this cube (i.e. latitude: value)
1817
cube_label = "latitude: %s" % cube.coord("latitude").points[0]
1918

lib/iris/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ def __init__(self, datum_support=False, pandas_ndim=False):
175175
self.__dict__["pandas_ndim"] = pandas_ndim
176176

177177
def __repr__(self):
178-
179178
# msg = ('Future(example_future_flag={})')
180179
# return msg.format(self.example_future_flag)
181180
msg = "Future(datum_support={}, pandas_ndim={})"

lib/iris/_merge.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,7 @@ def _define_space(self, space, positions, indexes, function_matrix):
14181418
participates in a functional relationship.
14191419
14201420
"""
1421+
14211422
# Heuristic reordering of coordinate defintion indexes into
14221423
# preferred dimension order.
14231424
def axis_and_name(name):

lib/iris/analysis/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ def _dimensional_metadata_comparison(*cubes, object_get=None):
296296
# for coordinate groups
297297
for cube, coords in zip(cubes, all_coords):
298298
for coord in coords:
299-
300299
# if this coordinate has already been processed, then continue on
301300
# to the next one
302301
if id(coord) in processed_coords:

lib/iris/analysis/_area_weighted.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ def _calculate_regrid_area_weighted_weights(
853853
cached_x_bounds = []
854854
cached_x_indices = []
855855
max_x_indices = 0
856-
for (x_0, x_1) in grid_x_bounds:
856+
for x_0, x_1 in grid_x_bounds:
857857
if grid_x_decreasing:
858858
x_0, x_1 = x_1, x_0
859859
x_bounds, x_indices = _cropped_bounds(src_x_bounds, x_0, x_1)

lib/iris/analysis/_interpolation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def _account_for_circular(self, points, data):
268268
"""
269269
from iris.analysis.cartography import wrap_lons
270270

271-
for (circular, modulus, index, dim, offset) in self._circulars:
271+
for circular, modulus, index, dim, offset in self._circulars:
272272
if modulus:
273273
# Map all the requested values into the range of the source
274274
# data (centred over the centre of the source data to allow

lib/iris/analysis/_scipy_interpolate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def compute_interp_weights(self, xi, method=None):
225225
prepared = (xi_shape, method) + self._find_indices(xi.T)
226226

227227
if method == "linear":
228-
229228
xi_shape, method, indices, norm_distances, out_of_bounds = prepared
230229

231230
# Allocate arrays for describing the sparse matrix.

lib/iris/analysis/calculus.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,6 @@ def curl(i_cube, j_cube, k_cube=None):
594594
horiz_cs, (iris.coord_systems.GeogCS, iris.coord_systems.RotatedGeogCS)
595595
)
596596
if not spherical_coords:
597-
598597
# TODO Implement some mechanism for conforming to a common grid
599598
dj_dx = _curl_differentiate(j_cube, x_coord)
600599
prototype_diff = dj_dx

lib/iris/analysis/trajectory.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def __init__(self, waypoints, sample_count=10):
8585
cur_seg = segments[cur_seg_i]
8686
len_accum = cur_seg.length
8787
for p in range(self.sample_count):
88-
8988
# calculate the sample position along our total length
9089
sample_at_len = p * sample_step
9190

lib/iris/common/metadata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,7 @@ def _combine_lenient(self, other):
969969
A list of combined metadata member values.
970970
971971
"""
972+
972973
# Perform "strict" combination for "coord_system" and "climatological".
973974
def func(field):
974975
left = getattr(self, field)
@@ -1024,6 +1025,7 @@ def _difference_lenient(self, other):
10241025
A list of difference metadata member values.
10251026
10261027
"""
1028+
10271029
# Perform "strict" difference for "coord_system" and "climatological".
10281030
def func(field):
10291031
left = getattr(self, field)

lib/iris/coord_categorisation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def vectorised_fn(*args):
9090
# coordinates only
9191
#
9292

93+
9394
# Private "helper" function
9495
def _pt_date(coord, time):
9596
"""

lib/iris/coord_systems.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ def datum(self, value):
478478

479479
@classmethod
480480
def from_datum(cls, datum, longitude_of_prime_meridian=None):
481-
482481
crs = super().__new__(cls)
483482

484483
crs._semi_major_axis = None
@@ -949,7 +948,6 @@ def __init__(
949948
false_northing=None,
950949
ellipsoid=None,
951950
):
952-
953951
"""
954952
Constructs a Geostationary coord system.
955953

lib/iris/coords.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2846,7 +2846,6 @@ def _new_bounds_requirements(self, bounds):
28462846
n_bounds = bounds.shape[-1]
28472847
n_points = bounds.shape[0]
28482848
if n_points > 1:
2849-
28502849
directions = set()
28512850
for b_index in range(n_bounds):
28522851
monotonic, direction = iris.util.monotonic(

lib/iris/cube.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2688,7 +2688,6 @@ def subset(self, coord):
26882688
coord_to_extract in self.aux_coords
26892689
and len(coord_to_extract.points) == 1
26902690
):
2691-
26922691
# Default to returning None
26932692
result = None
26942693

lib/iris/experimental/ugrid/mesh.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,9 +3127,7 @@ def _construct_access_arrays(self):
31273127
flat_inds_safe = al.where(missing_inds, 0, flat_inds_nomask)
31283128
# Here's the core indexing operation.
31293129
# The comma applies all inds-array values to the *first* dimension.
3130-
bounds = node_points[
3131-
flat_inds_safe,
3132-
]
3130+
bounds = node_points[flat_inds_safe,]
31333131
# Fix 'missing' locations, and restore the proper shape.
31343132
bounds = al.ma.masked_array(bounds, missing_inds)
31353133
bounds = bounds.reshape(indices.shape)

lib/iris/experimental/ugrid/metadata.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def _combine_lenient(self, other):
5353
A list of combined metadata member values.
5454
5555
"""
56+
5657
# Perform "strict" combination for "cf_role", "start_index", "location_axis".
5758
def func(field):
5859
left = getattr(self, field)
@@ -113,6 +114,7 @@ def _difference_lenient(self, other):
113114
A list of difference metadata member values.
114115
115116
"""
117+
116118
# Perform "strict" difference for "cf_role", "start_index", "location_axis".
117119
def func(field):
118120
left = getattr(self, field)
@@ -233,6 +235,7 @@ def _difference_lenient(self, other):
233235
A list of difference metadata member values.
234236
235237
"""
238+
236239
# Perform "strict" difference for "topology_dimension",
237240
# "node_dimension", "edge_dimension" and "face_dimension".
238241
def func(field):
@@ -297,6 +300,7 @@ def _combine_lenient(self, other):
297300
A list of combined metadata member values.
298301
299302
"""
303+
300304
# It is actually "strict" : return None except where members are equal.
301305
def func(field):
302306
left = getattr(self, field)
@@ -352,6 +356,7 @@ def _difference_lenient(self, other):
352356
A list of different metadata member values.
353357
354358
"""
359+
355360
# Perform "strict" difference for location / axis.
356361
def func(field):
357362
left = getattr(self, field)

lib/iris/fileformats/abf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ def load_cubes(filespecs, callback=None):
219219

220220
for filespec in filespecs:
221221
for filename in glob.glob(filespec):
222-
223222
field = ABFField(filename)
224223
cube = field.to_cube()
225224

lib/iris/fileformats/name_loaders.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,6 @@ def load_NAMEIII_version2(filename):
994994
# using the next() method. This will come in handy as we wish to
995995
# progress through the file line by line.
996996
with open(filename, "r") as file_handle:
997-
998997
# define a dictionary to hold the header metadata about this file
999998
header = read_header(file_handle)
1000999

@@ -1005,7 +1004,6 @@ def load_NAMEIII_version2(filename):
10051004
column_headings = {}
10061005
datacol1 = header["Number of preliminary cols"]
10071006
for line in file_handle:
1008-
10091007
data = [col.strip() for col in line.split(",")][:-1]
10101008

10111009
# If first column is not zero we have reached the end

lib/iris/fileformats/pp.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ def __getstate__(self):
625625
def __setstate__(self, state):
626626
# Because we have __slots__, this is needed to support Pickle.load()
627627
# (Use setattr, as there is no object dictionary.)
628-
for (key, value) in state:
628+
for key, value in state:
629629
setattr(self, key, value)
630630

631631
def __eq__(self, other):
@@ -2029,10 +2029,8 @@ def pp_filter(field):
20292029
res = True
20302030
if field.stash not in _STASH_ALLOW:
20312031
if pp_constraints.get("stash"):
2032-
20332032
res = False
20342033
for call_func in pp_constraints["stash"]:
2035-
20362034
if call_func(str(field.stash)):
20372035
res = True
20382036
break

lib/iris/fileformats/pp_load_rules.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,6 @@ def date2year(t_in):
756756
)
757757
)
758758
):
759-
760759
coords_and_dims.append(
761760
_new_coord_and_dims(
762761
do_vector,

lib/iris/fileformats/rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def _load_pairs_from_fields_and_filenames(
394394
yield (cube, field)
395395

396396
regrid_cache = {}
397-
for (cube, factories, field) in results_needing_reference:
397+
for cube, factories, field in results_needing_reference:
398398
_resolve_factory_references(
399399
cube, factories, concrete_reference_targets, regrid_cache
400400
)

lib/iris/fileformats/um/_fast_load_structured_fields.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def element_arrays_and_dims(self):
133133

134134
def _field_vector_element_arrays(self):
135135
"""Define the field components used in the structure analysis."""
136+
136137
# Define functions to make t1 and t2 values as date-time tuples.
137138
# These depend on header version (PPField2 has no seconds values).
138139
def t1_fn(fld):

lib/iris/quickplot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def _title(cube_or_coord, with_units):
4545
or units.is_no_unit()
4646
or units == cf_units.Unit("1")
4747
):
48-
4948
if _use_symbol(units):
5049
units = units.symbol
5150
elif units.is_time_reference():

lib/iris/tests/graphics/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ def check_graphic(test_id: str, results_dir: Union[str, Path]) -> None:
187187
try:
188188

189189
def _create_missing(phash: str) -> None:
190-
191190
output_path = test_output_dir / (test_id + ".png")
192191

193192
print(f"Creating image file: {output_path}")
@@ -214,7 +213,6 @@ def _create_missing(phash: str) -> None:
214213
phash = get_phash(buffer)
215214

216215
if test_id in repo:
217-
218216
expected = hex_to_hash(repo[test_id])
219217

220218
# Calculate hamming distance vector for the result hash.

lib/iris/tests/integration/test_Datums.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def setUp(self):
2323
self.start_crs = ccrs.OSGB(False)
2424

2525
def test_transform_points_datum(self):
26-
2726
# Iris version
2827
wgs84 = GeogCS.from_datum("WGS84")
2928
iris_cs = LambertConformal(

lib/iris/tests/test_cdm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ def test_similar_coord(self):
349349
)
350350

351351
def test_cube_summary_cell_methods(self):
352-
353352
cube = self.cube_2d.copy()
354353

355354
# Create a list of values used to create cell methods

lib/iris/tests/test_cf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ def test_destructor(self):
276276
didn't exist because opening the dataset had failed.
277277
"""
278278
with self.temp_filename(suffix=".nc") as fn:
279-
280279
with open(fn, "wb+") as fh:
281-
282280
fh.write(
283281
b"\x89HDF\r\n\x1a\nBroken file with correct signature"
284282
)

lib/iris/tests/test_io_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_format_picker(self):
126126
]
127127

128128
# test that each filespec is identified as the expected format
129-
for (expected_format_name, file_spec) in test_specs:
129+
for expected_format_name, file_spec in test_specs:
130130
test_path = tests.get_data_path(file_spec)
131131
with open(test_path, "rb") as test_file:
132132
a = iff.FORMAT_AGENT.get_spec(test_path, test_file)

lib/iris/tests/test_merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def setUp(self):
190190
)
191191

192192
def test__ndarray_ndarray(self):
193-
for (lazy0, lazy1) in self.lazy_combos:
193+
for lazy0, lazy1 in self.lazy_combos:
194194
cubes = iris.cube.CubeList()
195195
cubes.append(self._make_cube(0, dtype=self.dtype, lazy=lazy0))
196196
cubes.append(self._make_cube(1, dtype=self.dtype, lazy=lazy1))

lib/iris/tests/test_netcdf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,7 @@ def test_deferred_loading(self):
313313
cube[((0, 8, 4, 2, 14, 12),)][((0, 2, 4, 1),)],
314314
("netcdf", "netcdf_deferred_tuple_1.cml"),
315315
)
316-
subcube = cube[((0, 8, 4, 2, 14, 12),)][((0, 2, 4, 1),)][
317-
(1, 3),
318-
]
316+
subcube = cube[((0, 8, 4, 2, 14, 12),)][((0, 2, 4, 1),)][(1, 3),]
319317
self.assertCML(subcube, ("netcdf", "netcdf_deferred_tuple_2.cml"))
320318

321319
# Consecutive mixture on same dimension.
@@ -1417,7 +1415,6 @@ def test_process_flags(self):
14171415
}
14181416

14191417
for bits, descriptions in multiple_map.items():
1420-
14211418
ll_cube = stock.lat_lon_cube()
14221419
ll_cube.attributes["ukmo__process_flags"] = descriptions
14231420

lib/iris/tests/test_nimrod.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def test_huge_field_load(self):
8080
@tests.skip_data
8181
def test_load_kwarg(self):
8282
"""Tests that the handle_metadata_errors kwarg is effective by setting it to
83-
False with a file with known incomplete meta-data (missing ellipsoid)."""
83+
False with a file with known incomplete meta-data (missing ellipsoid).
84+
"""
8485
datafile = "u1096_ng_ek00_pressure_2km"
8586
with self.assertRaisesRegex(
8687
TranslationError,

0 commit comments

Comments
 (0)