Skip to content

Commit 05805e4

Browse files
black
1 parent 89a6f65 commit 05805e4

File tree

105 files changed

+5882
-3309
lines changed

Some content is hidden

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

105 files changed

+5882
-3309
lines changed

demo/rose-config-edit/demo_meta/app/04-transform/meta/lib/python/macros/null.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class NullTransformer(metomi.rose.macro.MacroBase):
1111

1212
REPORTS_INFO = [
1313
(None, None, None, "Warning for null section, null option"),
14-
("made", "up", None, "Warning for non-data & non-metadata setting")]
14+
("made", "up", None, "Warning for non-data & non-metadata setting"),
15+
]
1516

1617
def transform(self, config, meta_config):
1718
"""Report null or made-up setting changes."""

demo/rose-config-edit/demo_meta/app/05-validate/meta/lib/python/macros/fib.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@ def validate(self, config, meta_config, starts_at_zero=False):
2929
if all([w.isdigit() for w in elems]) and len(elems) > 1:
3030
int_elems = [int(w) for w in elems]
3131
if len(int_elems) >= 2 and int_elems[:2] != seq:
32-
self.add_report(section, option, value,
33-
self.BAD_SEQUENCE)
32+
self.add_report(section, option, value, self.BAD_SEQUENCE)
3433
else:
3534
for i, element in enumerate(int_elems):
3635
if i < 2:
3736
continue
3837
if element != int_elems[i - 1] + int_elems[i - 2]:
39-
self.add_report(section, option, value,
40-
self.BAD_SEQUENCE)
38+
self.add_report(
39+
section, option, value, self.BAD_SEQUENCE
40+
)
4141
break
4242
else:
43-
self.add_report(section, option, value,
44-
self.BAD_SEQUENCE)
43+
self.add_report(section, option, value, self.BAD_SEQUENCE)
4544
return self.reports

demo/rose-config-edit/demo_meta/app/05-validate/meta/lib/python/macros/null.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class NullChecker(metomi.rose.macro.MacroBase):
1111

1212
REPORTS_INFO = [
1313
(None, None, None, "Warning for null section, null option"),
14-
("made", "up", None, "Warning for non-data & non-metadata setting")]
14+
("made", "up", None, "Warning for non-data & non-metadata setting"),
15+
]
1516

1617
def validate(self, config, meta_config):
1718
"""Validate meaningless settings."""

demo/rose-config-edit/demo_meta/app/05-validate/meta/lib/python/macros/url.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ def validate(self, config, meta_config):
2424
if "URL" not in option:
2525
continue
2626
value = config.get([section, option]).value
27-
if (not value.isdigit() and " " not in value and
28-
"," not in value):
27+
if (
28+
not value.isdigit()
29+
and " " not in value
30+
and "," not in value
31+
):
2932
try:
3033
connection = http.client.HTTPConnection(value, 80)
3134
connection.request("HEAD", "")

etc/tutorial/cylc-forecasting-suite/lib/python/mecator.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
R_0 = 6356752.3
88

99

10-
def get_offset(bbox, scale=(1., 1.)):
10+
def get_offset(bbox, scale=(1.0, 1.0)):
1111
"""Define an offset from the origin using the provided bbox.
1212
1313
Args:
@@ -28,13 +28,14 @@ def get_scale(bbox, width):
2828
width: The width of the projection.
2929
3030
"""
31-
scale = width * (180. / abs(bbox['lng2'] - bbox['lng1']))
31+
scale = width * (180.0 / abs(bbox['lng2'] - bbox['lng1']))
3232
return (
3333
(math.pi * R_0) / scale,
34-
(math.pi * R_0 * 2.) / scale)
34+
(math.pi * R_0 * 2.0) / scale,
35+
)
3536

3637

37-
def coord_to_pos(lng, lat, offset=(0., 0.), scale=(1., 1.)):
38+
def coord_to_pos(lng, lat, offset=(0.0, 0.0), scale=(1.0, 1.0)):
3839
"""Convert a lng, lat coord to an x, y position in a mecator projection.
3940
4041
proj equivalent:
@@ -46,15 +47,15 @@ def coord_to_pos(lng, lat, offset=(0., 0.), scale=(1., 1.)):
4647
lng = math.radians(lng)
4748
lat = math.radians(lat)
4849
pos_x = R_0 * lng
49-
pos_y = R_0 * math.log(math.tan((math.pi / 4.) + (lat / 2.)))
50+
pos_y = R_0 * math.log(math.tan((math.pi / 4.0) + (lat / 2.0)))
5051
pos_x /= scale[0]
5152
pos_y /= scale[1]
5253
pos_x -= offset[0]
5354
pos_y -= offset[1]
5455
return pos_x, pos_y
5556

5657

57-
def pos_to_coord(pos_x, pos_y, offset=(0., 0.), scale=(1., 1.)):
58+
def pos_to_coord(pos_x, pos_y, offset=(0.0, 0.0), scale=(1.0, 1.0)):
5859
"""Convert an x, y coordinate in a mecator projection to a lng, lat coord.
5960
6061
proj equivalent:
@@ -68,5 +69,5 @@ def pos_to_coord(pos_x, pos_y, offset=(0., 0.), scale=(1., 1.)):
6869
pos_x *= scale[0]
6970
pos_y *= scale[1]
7071
lng = pos_x / R_0
71-
lat = 2 * math.atan(math.exp(pos_y / R_0)) - (math.pi / 2.)
72+
lat = 2 * math.atan(math.exp(pos_y / R_0)) - (math.pi / 2.0)
7273
return math.degrees(lng), math.degrees(lat)

etc/tutorial/cylc-forecasting-suite/lib/python/util.py

+44-31
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import jinja2
1010

11-
R_0 = 6371. # Radius of the Earth (km).
11+
R_0 = 6371.0 # Radius of the Earth (km).
1212

1313

1414
def frange(start, stop, step):
@@ -59,11 +59,12 @@ def field_to_csv(field, x_range, y_range, filename):
5959
"""
6060
with open(filename, 'w+') as csv_file:
6161
for itt_y in y_range:
62-
csv_file.write(', '.join('%.2f' % field(x, itt_y) for
63-
x in x_range) + '\n')
62+
csv_file.write(
63+
', '.join('%.2f' % field(x, itt_y) for x in x_range) + '\n'
64+
)
6465

6566

66-
def generate_matrix(dim_x, dim_y, value=0.):
67+
def generate_matrix(dim_x, dim_y, value=0.0):
6768
"""Generates a 2D list with the desired dimensions.
6869
6970
Args:
@@ -102,12 +103,15 @@ def great_arc_distance(coordinate_1, coordinate_2):
102103
lng_2 = math.radians(lng_2)
103104
lat_2 = math.radians(lat_2)
104105
return (
105-
2 * R_0 * math.asin(
106+
2
107+
* R_0
108+
* math.asin(
106109
math.sqrt(
107-
(math.sin((lat_2 - lat_1) / 2.) ** 2) + (
108-
math.cos(lat_1) *
109-
math.cos(lat_2) *
110-
(math.sin((lng_2 - lng_1) / 2.) ** 2)
110+
(math.sin((lat_2 - lat_1) / 2.0) ** 2)
111+
+ (
112+
math.cos(lat_1)
113+
* math.cos(lat_2)
114+
* (math.sin((lng_2 - lng_1) / 2.0) ** 2)
111115
)
112116
)
113117
)
@@ -132,6 +136,7 @@ def interpolate_grid(points, dim_x, dim_y, d_x, d_y, spline_order=0):
132136
data.
133137
134138
"""
139+
135140
def spline_0(pos_x, pos_y, z_val):
136141
"""Zeroth order beta spline (i.e. nearest point)."""
137142
return [(int(round(pos_x)), int(round(pos_y)), z_val)] # [(x, y, z)]
@@ -147,18 +152,19 @@ def spline_1(pos_x, pos_y, z_val):
147152
(x_0, y_0, (x_0 + d_x - pos_x) * (y_0 + d_y - pos_y) * z_val),
148153
(x_1, y_0, (pos_x - x_0) * (y_0 + d_y - pos_y) * z_val),
149154
(x_0, y_1, (x_0 + d_x - pos_x) * (pos_y - y_0) * z_val),
150-
(x_1, y_1, (pos_x - x_0) * (pos_y - y_0) * z_val)
155+
(x_1, y_1, (pos_x - x_0) * (pos_y - y_0) * z_val),
151156
]
152157

153158
if spline_order == 0:
154159
spline = spline_0
155160
elif spline_order == 1:
156161
spline = spline_1
157162
else:
158-
raise ValueError('Invalid spline order "%d" must be in (0, 1).' %
159-
spline_order)
163+
raise ValueError(
164+
'Invalid spline order "%d" must be in (0, 1).' % spline_order
165+
)
160166

161-
grid = generate_matrix(dim_x, dim_y, 0.)
167+
grid = generate_matrix(dim_x, dim_y, 0.0)
162168

163169
for x_val, y_val, z_val in points:
164170
x_coord = x_val / d_x
@@ -176,6 +182,7 @@ def spline_1(pos_x, pos_y, z_val):
176182
def plot_vector_grid(filename, x_grid, y_grid):
177183
try:
178184
import matplotlib
185+
179186
matplotlib.use('Agg')
180187
import matplotlib.pyplot as plt
181188
except ImportError:
@@ -192,13 +199,15 @@ def plot_vector_grid(filename, x_grid, y_grid):
192199
y_coords.append(itt_y)
193200
z_coords.append((
194201
x_grid[itt_y][itt_x],
195-
y_grid[itt_y][itt_x]
202+
y_grid[itt_y][itt_x],
196203
))
197204

198-
plt.quiver(x_coords,
199-
y_coords,
200-
[x[0] for x in z_coords],
201-
[y[1] for y in z_coords])
205+
plt.quiver(
206+
x_coords,
207+
y_coords,
208+
[x[0] for x in z_coords],
209+
[y[1] for y in z_coords],
210+
)
202211
fig.savefig(filename)
203212

204213

@@ -208,7 +217,8 @@ def get_grid_coordinates(lng, lat, domain, resolution):
208217
length_y = int(abs(domain['lat2'] - domain['lat1']) // resolution)
209218
return (
210219
int((abs(lng - domain['lng1'])) // resolution),
211-
length_y - int((abs(lat - domain['lat1'])) // resolution))
220+
length_y - int((abs(lat - domain['lat1'])) // resolution),
221+
)
212222

213223

214224
class SurfaceFitter:
@@ -233,11 +243,11 @@ def __init__(self, x_points, y_points, z_points, kind='linear'):
233243
self.points = list(zip(x_points, y_points, z_points))
234244

235245
if kind == 'linear':
236-
self.power = 1.
246+
self.power = 1.0
237247
elif kind == 'quadratic':
238-
self.power = 2.
248+
self.power = 2.0
239249
elif kind == 'cubic':
240-
self.power = 3.
250+
self.power = 3.0
241251
else:
242252
raise ValueError('"%s" is not a valid interpolation method' % kind)
243253

@@ -254,7 +264,7 @@ def __call__(self, grid_x, grid_y):
254264
z_val = z_point
255265
break
256266
else:
257-
weight = 1. / ((math.sqrt(d_x ** 2 + d_y ** 2)) ** self.power)
267+
weight = 1.0 / ((math.sqrt(d_x ** 2 + d_y ** 2)) ** self.power)
258268
sum_weight += weight
259269
sum_value += weight * z_point
260270

@@ -270,17 +280,20 @@ def parse_domain(domain):
270280
'lng1': bbox[0],
271281
'lat1': bbox[1],
272282
'lng2': bbox[2],
273-
'lat2': bbox[3]
283+
'lat2': bbox[3],
274284
}
275285

276286

277287
def generate_html_map(filename, template_file, data, domain, resolution):
278288
with open(template_file, 'r') as template:
279289
with open(filename, 'w+') as html_file:
280-
html_file.write(jinja2.Template(template.read()).render(
281-
resolution=resolution,
282-
lng1=domain['lng1'],
283-
lng2=domain['lng2'],
284-
lat1=domain['lat1'],
285-
lat2=domain['lat2'],
286-
data=data))
290+
html_file.write(
291+
jinja2.Template(template.read()).render(
292+
resolution=resolution,
293+
lng1=domain['lng1'],
294+
lng2=domain['lng2'],
295+
lat1=domain['lat1'],
296+
lat2=domain['lat2'],
297+
data=data,
298+
)
299+
)

etc/tutorial/widget/meta/lib/python/widget/username.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from functools import partial
1111

1212
import pygtk
13+
1314
pygtk.require('2.0')
1415
# flake8: noqa: E402
1516
import gtk
@@ -31,10 +32,8 @@ def __init__(self, value, metadata, set_value, hook, arg_str=None):
3132
self.entry.connect_after("key-release-event", self._setter)
3233
self.entry.connect_after("button-release-event", self._setter)
3334
self.entry.show()
34-
self.pack_start(self.entry, expand=True, fill=True,
35-
padding=0)
36-
self.entry.connect('focus-in-event',
37-
hook.trigger_scroll)
35+
self.pack_start(self.entry, expand=True, fill=True, padding=0)
36+
self.entry.connect('focus-in-event', hook.trigger_scroll)
3837
self.grab_focus = partial(hook.get_focus, self.entry)
3938

4039
def _setter(self, *args):

metomi/rose/__init__.py

+38-10
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
CONFIG_DELIMITER = "="
2525

2626
# Filenames and directory names
27-
CONFIG_NAMES = ["rose-app.conf", "rose-meta.conf",
28-
"rose-suite.conf", "rose-suite.info"]
27+
CONFIG_NAMES = [
28+
"rose-app.conf",
29+
"rose-meta.conf",
30+
"rose-suite.conf",
31+
"rose-suite.info",
32+
]
2933
GLOB_CONFIG_FILE = "rose*.conf"
3034
META_CONFIG_NAME = "rose-meta.conf"
3135
CONFIG_META_DIR = "meta"
@@ -48,11 +52,24 @@
4852
CONFIG_OPT_META_TYPE = "meta"
4953
CONFIG_OPT_OWNER = "owner"
5054
CONFIG_OPT_PROJECT = "project"
51-
INFO_CONFIG_DEFAULT_META_IDS = ["=access-list", "=description", "=owner",
52-
"=project", "=sub-project", "=title",
53-
"=type"]
54-
SUB_CONFIG_DEFAULT_META_IDS = ["=file-install-root", "=meta", "=mode",
55-
"=opts", "command", "file:", "poll"]
55+
INFO_CONFIG_DEFAULT_META_IDS = [
56+
"=access-list",
57+
"=description",
58+
"=owner",
59+
"=project",
60+
"=sub-project",
61+
"=title",
62+
"=type",
63+
]
64+
SUB_CONFIG_DEFAULT_META_IDS = [
65+
"=file-install-root",
66+
"=meta",
67+
"=mode",
68+
"=opts",
69+
"command",
70+
"file:",
71+
"poll",
72+
]
5673
CONFIG_SETTING_INDEX_DEFAULT = "1"
5774

5875

@@ -92,9 +109,20 @@
92109

93110
# Allowed type settings (that actually do something)
94111
# "meta" and "file" are for internal use.
95-
TYPE_VALUES = ["boolean", "character", "integer",
96-
"logical", "quoted", "raw", "real",
97-
"meta", "file", "python_list", "python_boolean", "spaced_list"]
112+
TYPE_VALUES = [
113+
"boolean",
114+
"character",
115+
"integer",
116+
"logical",
117+
"quoted",
118+
"raw",
119+
"real",
120+
"meta",
121+
"file",
122+
"python_list",
123+
"python_boolean",
124+
"spaced_list",
125+
]
98126

99127
# Preferred Fortran logical and environment boolean syntax
100128
TYPE_BOOLEAN_VALUE_FALSE = "false"

0 commit comments

Comments
 (0)