Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
# Don't commit to master branch.
- id: no-commit-to-branch
- repo: https://github.com/psf/black
rev: '19.10b0'
rev: '20.8b1'
hooks:
- id: black
# Force black to run on whole repo, using settings from pyproject.toml
Expand Down
4 changes: 3 additions & 1 deletion docs/iris/gallery_code/general/plot_custom_file_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ def main():
# draw contour levels for the data (the top level is just a catch-all)
levels = (0.0002, 0.002, 0.004, 1e10)
cs = iplt.contourf(
cube, levels=levels, colors=("#80ffff", "#939598", "#e00404"),
cube,
levels=levels,
colors=("#80ffff", "#939598", "#e00404"),
)

# draw a black outline at the lowest contour to highlight affected areas
Expand Down
7 changes: 6 additions & 1 deletion lib/iris/_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ def name(self):
return self.defn.name()


class _OtherMetaData(namedtuple("OtherMetaData", ["defn", "dims"],)):
class _OtherMetaData(
namedtuple(
"OtherMetaData",
["defn", "dims"],
)
):
"""
Container for the metadata that defines a cell measure or ancillary
variable.
Expand Down
6 changes: 4 additions & 2 deletions lib/iris/analysis/_area_weighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ def __init__(self, src_grid_cube, target_grid_cube, mdtol=1):
self._mdtol = mdtol

# Store regridding information
_regrid_info = eregrid._regrid_area_weighted_rectilinear_src_and_grid__prepare(
src_grid_cube, target_grid_cube
_regrid_info = (
eregrid._regrid_area_weighted_rectilinear_src_and_grid__prepare(
src_grid_cube, target_grid_cube
)
)
(
src_x,
Expand Down
12 changes: 8 additions & 4 deletions lib/iris/analysis/_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,15 @@ def __call__(self, src):
for slice_cube in src.slices(sx):
if self._regrid_info is None:
# Calculate the basic regrid info just once.
self._regrid_info = _regrid_weighted_curvilinear_to_rectilinear__prepare(
slice_cube, self.weights, self._target_cube
self._regrid_info = (
_regrid_weighted_curvilinear_to_rectilinear__prepare(
slice_cube, self.weights, self._target_cube
)
)
slice_result = (
_regrid_weighted_curvilinear_to_rectilinear__perform(
slice_cube, self._regrid_info
)
slice_result = _regrid_weighted_curvilinear_to_rectilinear__perform(
slice_cube, self._regrid_info
)
result_slices.append(slice_result)
result = result_slices.merge_cube()
Expand Down
12 changes: 8 additions & 4 deletions lib/iris/analysis/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,14 @@ def curl(i_cube, j_cube, k_cube=None):
# (d/dtheta (i_cube * sin(lat)) - d_j_cube_dphi)
# phi_cmpt = 1/r * ( d/dr (r * j_cube) - d_k_cube_dtheta)
# theta_cmpt = 1/r * ( 1/cos(lat) * d_k_cube_dphi - d/dr (r * i_cube)
if y_coord.name() not in [
"latitude",
"grid_latitude",
] or x_coord.name() not in ["longitude", "grid_longitude"]:
if (
y_coord.name()
not in [
"latitude",
"grid_latitude",
]
or x_coord.name() not in ["longitude", "grid_longitude"]
):
raise ValueError(
"Expecting latitude as the y coord and "
"longitude as the x coord for spherical curl."
Expand Down
6 changes: 4 additions & 2 deletions lib/iris/common/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
)

_CategoryItems = namedtuple(
"CategoryItems", ["items_dim", "items_aux", "items_scalar"],
"CategoryItems",
["items_dim", "items_aux", "items_scalar"],
)

_DimCoverage = namedtuple(
Expand All @@ -50,7 +51,8 @@
_PreparedFactory = namedtuple("PreparedFactory", ["container", "dependencies"])

_PreparedItem = namedtuple(
"PreparedItem", ["metadata", "points", "bounds", "dims", "container"],
"PreparedItem",
["metadata", "points", "bounds", "dims", "container"],
)

_PreparedMetadata = namedtuple("PreparedMetadata", ["combined", "src", "tgt"])
Expand Down
12 changes: 8 additions & 4 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -3647,8 +3647,8 @@ def __eq__(self, other):

# having checked the metadata, now check the coordinates
if result:
coord_compares = iris.analysis._dimensional_metadata_comparison(
self, other
coord_compares = (
iris.analysis._dimensional_metadata_comparison(self, other)
)
# if there are any coordinates which are not equal
result = not (
Expand All @@ -3658,7 +3658,9 @@ def __eq__(self, other):

if result:
cm_compares = iris.analysis._dimensional_metadata_comparison(
self, other, object_get=Cube.cell_measures,
self,
other,
object_get=Cube.cell_measures,
)
# if there are any cell measures which are not equal
result = not (
Expand All @@ -3668,7 +3670,9 @@ def __eq__(self, other):

if result:
av_compares = iris.analysis._dimensional_metadata_comparison(
self, other, object_get=Cube.ancillary_variables,
self,
other,
object_get=Cube.ancillary_variables,
)
# if there are any ancillary variables which are not equal
result = not (
Expand Down
149 changes: 133 additions & 16 deletions lib/iris/fileformats/_ff.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,140 @@
("model_version", (12,)),
("obs_file_type", (14,)),
("last_fieldop_type", (15,)),
("first_validity_time", (21, 22, 23, 24, 25, 26, 27,)),
("last_validity_time", (28, 29, 30, 31, 32, 33, 34,)),
("misc_validity_time", (35, 36, 37, 38, 39, 40, 41,)),
("integer_constants", (100, 101,)),
("real_constants", (105, 106,)),
("level_dependent_constants", (110, 111, 112,)),
("row_dependent_constants", (115, 116, 117,)),
("column_dependent_constants", (120, 121, 122,)),
("fields_of_constants", (125, 126, 127,)),
("extra_constants", (130, 131,)),
("temp_historyfile", (135, 136,)),
("compressed_field_index1", (140, 141,)),
("compressed_field_index2", (142, 143,)),
("compressed_field_index3", (144, 145,)),
("lookup_table", (150, 151, 152,)),
(
"first_validity_time",
(
21,
22,
23,
24,
25,
26,
27,
),
),
(
"last_validity_time",
(
28,
29,
30,
31,
32,
33,
34,
),
),
(
"misc_validity_time",
(
35,
36,
37,
38,
39,
40,
41,
),
),
(
"integer_constants",
(
100,
101,
),
),
(
"real_constants",
(
105,
106,
),
),
(
"level_dependent_constants",
(
110,
111,
112,
),
),
(
"row_dependent_constants",
(
115,
116,
117,
),
),
(
"column_dependent_constants",
(
120,
121,
122,
),
),
(
"fields_of_constants",
(
125,
126,
127,
),
),
(
"extra_constants",
(
130,
131,
),
),
(
"temp_historyfile",
(
135,
136,
),
),
(
"compressed_field_index1",
(
140,
141,
),
),
(
"compressed_field_index2",
(
142,
143,
),
),
(
"compressed_field_index3",
(
144,
145,
),
),
(
"lookup_table",
(
150,
151,
152,
),
),
("total_prognostic_fields", (153,)),
("data", (160, 161, 162,)),
(
"data",
(
160,
161,
162,
),
),
Comment on lines +45 to +178
Copy link
Contributor

@trexfeathers trexfeathers Sep 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, right...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost wondering if it's a bug in black? Would anyone really choose this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjlittle will likely be able to explain all once he pushes the fixing commit. He does know what's wrong

]

# Offset value to convert from UM_FIXED_LENGTH_HEADER positions to
Expand Down
7 changes: 6 additions & 1 deletion lib/iris/fileformats/cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
# NetCDF variable attributes handled by the netCDF4 module and
# therefore automatically classed as "used" attributes.
_CF_ATTRS_IGNORE = set(
["_FillValue", "add_offset", "missing_value", "scale_factor",]
[
"_FillValue",
"add_offset",
"missing_value",
"scale_factor",
]
)

#: Supported dimensionless vertical coordinate reference surface/phemomenon
Expand Down
4 changes: 3 additions & 1 deletion lib/iris/fileformats/name_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ def _generate_cubes(
circular = False
if coord.name == "flight_level":
icoord = DimCoord(
points=pts, units=coord_units, long_name=long_name,
points=pts,
units=coord_units,
long_name=long_name,
)
else:
icoord = DimCoord(
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ def write(
`chunksizes` and `endian` keywords are silently ignored for netCDF
3 files that do not use HDF5.

"""
"""
if unlimited_dimensions is None:
unlimited_dimensions = []

Expand Down
13 changes: 10 additions & 3 deletions lib/iris/fileformats/nimrod_load_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ def coord_system(field, handle_metadata_errors):
"Plotting and reprojection may be impaired."
)
coord_sys = iris.coord_systems.TransverseMercator(
*crs_args, iris.coord_systems.GeogCS(**ellipsoid),
*crs_args,
iris.coord_systems.GeogCS(**ellipsoid),
)
elif field.horizontal_grid_type == 1:
coord_sys = iris.coord_systems.GeogCS(**ellipsoid)
Expand Down Expand Up @@ -456,7 +457,10 @@ def horizontal_grid(cube, field, handle_metadata_errors):
dtype=np.float32,
)
x_coord = DimCoord(
points, standard_name=x_coord_name, units=units_name, coord_system=crs,
points,
standard_name=x_coord_name,
units=units_name,
coord_system=crs,
)
cube.add_dim_coord(x_coord, 1)
points = np.linspace(
Expand All @@ -467,7 +471,10 @@ def horizontal_grid(cube, field, handle_metadata_errors):
dtype=np.float32,
)
y_coord = DimCoord(
points, standard_name=y_coord_name, units=units_name, coord_system=crs,
points,
standard_name=y_coord_name,
units=units_name,
coord_system=crs,
)
cube.add_dim_coord(y_coord, 0)

Expand Down
Loading