Skip to content

Commit d051cbf

Browse files
authored
apply black 23.1 (#64)
1 parent 99eb2f6 commit d051cbf

13 files changed

+5
-92
lines changed

docs/example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def plot_map_mpu():
5656

5757

5858
if __name__ == "__main__":
59-
6059
opt = {"dpi": 200, "facecolor": "0.9", "transparent": False}
6160

6261
plot_map_no_mpu()

mplotutils/_colorbar.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def colorbar(
208208

209209

210210
def _get_cbax(f):
211-
212211
# when using f.add_axes(rect) with the same rect twice
213212
# it is the same axes, so we have to change rect
214213
# slightly each time this func is called
@@ -280,7 +279,6 @@ def _resize_colorbar_vert(
280279

281280
# inner function is called by event handler
282281
def inner(event=None):
283-
284282
pos1 = ax1.get_position()
285283

286284
# determine total height of all axes
@@ -375,7 +373,6 @@ def _resize_colorbar_horz(
375373
cbax.set_box_aspect(aspect)
376374

377375
def inner(event=None):
378-
379376
posn1 = ax1.get_position()
380377

381378
if ax2 is None:
@@ -409,7 +406,6 @@ def inner(event=None):
409406

410407

411408
def _parse_shift_shrink(shift, shrink):
412-
413409
if shift == "symmetric":
414410
if shrink is None:
415411
shrink = 0
@@ -438,7 +434,6 @@ def _parse_shift_shrink(shift, shrink):
438434

439435

440436
def _parse_size_aspect_pad(size, aspect, pad, orientation):
441-
442437
if (size is not None) and (aspect is not None):
443438
raise ValueError("Can only pass one of 'aspect' and 'size'")
444439

mplotutils/_deprecate.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def _deprecate_positional_args(version):
6767
"""
6868

6969
def _decorator(func):
70-
7170
signature = inspect.signature(func)
7271

7372
pos_or_kw_args = []
@@ -84,11 +83,9 @@ def _decorator(func):
8483

8584
@wraps(func)
8685
def inner(*args, **kwargs):
87-
8886
name = func.__name__
8987
n_extra_args = len(args) - len(pos_or_kw_args)
9088
if n_extra_args > 0:
91-
9289
extra_args = ", ".join(kwonly_args[:n_extra_args])
9390

9491
warnings.warn(

mplotutils/cartopy_utils.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ def cyclic_dataarray(obj, coord="lon"):
132132

133133
@_deprecate_positional_args("0.3")
134134
def ylabel_map(s, *, labelpad=None, size=None, weight=None, y=0.5, ax=None, **kwargs):
135-
"""
136-
add ylabel to cartopy plot
135+
"""add ylabel to cartopy plot
137136
138137
Parameters
139138
----------
@@ -198,8 +197,7 @@ def ylabel_map(s, *, labelpad=None, size=None, weight=None, y=0.5, ax=None, **kw
198197

199198
@_deprecate_positional_args("0.3")
200199
def xlabel_map(s, *, labelpad=None, size=None, weight=None, x=0.5, ax=None, **kwargs):
201-
"""
202-
add xlabel to cartopy plot
200+
"""add xlabel to cartopy plot
203201
204202
Parameters
205203
----------
@@ -275,9 +273,7 @@ def yticklabels(
275273
bbox_props=dict(ec="none", fc="none"),
276274
**kwargs,
277275
):
278-
279-
"""
280-
draw yticklabels on map plots - may or may not work
276+
"""draw yticklabels on map plots - may or may not work
281277
282278
Parameters
283279
----------
@@ -342,7 +338,6 @@ def yticklabels(
342338

343339
# loop through points
344340
for y in y_label_points:
345-
346341
msg = LATITUDE_FORMATTER(y)
347342

348343
x = _determine_intersection(boundary_pc, [lonmin, y], [lonmax, y])
@@ -379,9 +374,7 @@ def xticklabels(
379374
bbox_props=dict(ec="none", fc="none"),
380375
**kwargs,
381376
):
382-
383-
"""
384-
draw xticklabels on map plots - may or may not work
377+
"""draw xticklabels on map plots - may or may not work
385378
386379
Parameters
387380
----------
@@ -442,7 +435,6 @@ def xticklabels(
442435

443436
# loop through points
444437
for x in x_label_points:
445-
446438
msg = LONGITUDE_FORMATTER(x)
447439

448440
y = _determine_intersection(boundary_pc, [x, -90], [x, 90])
@@ -478,7 +470,6 @@ def _get_boundary_platecarree(ax):
478470

479471

480472
def _determine_intersection(polygon, xy1, xy2):
481-
482473
p1 = shapely.geometry.Point(xy1)
483474
p2 = shapely.geometry.Point(xy2)
484475
ls = shapely.geometry.LineString([p1, p2])

mplotutils/colormaps.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def _color_palette(cmap, n_colors):
8181

8282

8383
def _get_label_attr(labelpad, size, weight):
84-
8584
if labelpad is None:
8685
labelpad = mpl.rcParams["axes.labelpad"]
8786

mplotutils/tests/test_colorbar.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@
99

1010

1111
def assert_position(cbar, expected):
12-
1312
pos = cbar.ax.get_position()
1413
result = [pos.x0, pos.y0, pos.width, pos.height]
1514

1615
np.testing.assert_allclose(result, expected, atol=1e-08)
1716

1817

1918
def assert_aspect(cbar, expected):
20-
2119
assert cbar.ax.get_box_aspect() == expected
2220
# the aspect is given in pixel space (i.e. the size of the figure matters)
2321
np.testing.assert_allclose(cbar.ax.bbox.height / cbar.ax.bbox.width, expected)
2422

2523

2624
def test_parse_shift_shrink():
27-
2825
# test code for _parse_shift_shrink
2926
assert _parse_shift_shrink("symmetric", None) == (0.0, 0.0)
3027

@@ -84,9 +81,7 @@ def test_parse_size_aspect_pad():
8481

8582
@pytest.mark.parametrize("orientation", ["vertical", "horizontal"])
8683
def test_colorbar_deprecate_positional(orientation):
87-
8884
with subplots_context(1, 2) as (f, axs):
89-
9085
h = axs[0].pcolormesh([[0, 1]])
9186

9287
with pytest.warns(
@@ -96,7 +91,6 @@ def test_colorbar_deprecate_positional(orientation):
9691

9792

9893
def test_colorbar_different_figures():
99-
10094
with figure_context() as f1, figure_context() as f2:
10195
ax1 = f1.subplots()
10296
ax2 = f2.subplots()
@@ -108,7 +102,6 @@ def test_colorbar_different_figures():
108102

109103

110104
def test_colorbar_ax_and_ax2_error():
111-
112105
with figure_context() as f:
113106
ax1, ax2, ax3 = f.subplots(3, 1)
114107
h = ax1.pcolormesh([[0, 1]])
@@ -118,7 +111,6 @@ def test_colorbar_ax_and_ax2_error():
118111

119112

120113
def create_figure_subplots(nrows=1, ncols=1, orientation="vertical"):
121-
122114
f = plt.gcf()
123115

124116
axs = f.subplots(nrows=nrows, ncols=ncols, squeeze=False)
@@ -143,23 +135,19 @@ def create_figure_subplots(nrows=1, ncols=1, orientation="vertical"):
143135

144136

145137
def colorbar_one_ax_vertical(**kwargs):
146-
147138
h, ax = create_figure_subplots()
148139
cbar = mpu.colorbar(h, ax, **kwargs)
149140
return cbar
150141

151142

152143
def colorbar_one_ax_horizontal(**kwargs):
153-
154144
h, ax = create_figure_subplots(orientation="horizontal")
155145
cbar = mpu.colorbar(h, ax, orientation="horizontal", **kwargs)
156146
return cbar
157147

158148

159149
def test_colorbar_vertical_aspect():
160-
161150
with figure_context(figsize=(5, 5)):
162-
163151
# test pad=0, aspect=5
164152
cbar = colorbar_one_ax_vertical(aspect=5, pad=0)
165153

@@ -170,23 +158,20 @@ def test_colorbar_vertical_aspect():
170158
assert_aspect(cbar, 5)
171159

172160
with figure_context(figsize=(4, 2)):
173-
174161
cbar = colorbar_one_ax_vertical(aspect=20, pad=0)
175162

176163
expected = [0.8, 0.0, 0.025, 1]
177164
assert_position(cbar, expected)
178165
assert_aspect(cbar, 20)
179166

180167
with figure_context(figsize=(2, 4)):
181-
182168
cbar = colorbar_one_ax_vertical(aspect=20, pad=0)
183169

184170
expected = [0.8, 0.0, 0.1, 1]
185171
assert_position(cbar, expected)
186172
assert_aspect(cbar, 20)
187173

188174
with figure_context(figsize=(5, 5)):
189-
190175
# test pad=0, aspect=default (=20)
191176
cbar = colorbar_one_ax_vertical(pad=0)
192177

@@ -196,9 +181,7 @@ def test_colorbar_vertical_aspect():
196181

197182

198183
def test_colorbar_vertical_size():
199-
200184
with figure_context() as f:
201-
202185
# test pad=0, size=0.2
203186
cbar = colorbar_one_ax_vertical(size=0.2, pad=0)
204187

@@ -213,7 +196,6 @@ def test_colorbar_vertical_size():
213196
assert_position(cbar, expected)
214197

215198
with figure_context():
216-
217199
# pad=0.05, size=0.1
218200

219201
cbar = colorbar_one_ax_vertical(size=0.1, pad=0.05)
@@ -222,7 +204,6 @@ def test_colorbar_vertical_size():
222204
assert_position(cbar, expected)
223205

224206
with figure_context():
225-
226207
# shift='symmetric', shrink=0.1
227208
# --> colorbar is 10 % smaller, and centered
228209

@@ -251,9 +232,7 @@ def test_colorbar_vertical_size():
251232

252233

253234
def test_colorbar_horizontal_aspect():
254-
255235
with figure_context(figsize=(5, 5)):
256-
257236
# test pad=0, aspect=5
258237
cbar = colorbar_one_ax_horizontal(aspect=5, pad=0)
259238

@@ -262,7 +241,6 @@ def test_colorbar_horizontal_aspect():
262241
assert_aspect(cbar, 1 / 5)
263242

264243
with figure_context(figsize=(4, 2)):
265-
266244
# test pad=0, aspect=5
267245
cbar = colorbar_one_ax_horizontal(aspect=20, pad=0)
268246

@@ -271,7 +249,6 @@ def test_colorbar_horizontal_aspect():
271249
assert_aspect(cbar, 1 / 20)
272250

273251
with figure_context(figsize=(2, 4)):
274-
275252
# test pad=0, aspect=5
276253
cbar = colorbar_one_ax_horizontal(aspect=20, pad=0)
277254

@@ -292,7 +269,6 @@ def test_colorbar_horizontal_aspect():
292269

293270

294271
def test_colorbar_horizontal_size():
295-
296272
with figure_context() as f:
297273
# test pad=0, size=0.2
298274
cbar = colorbar_one_ax_horizontal(size=0.2, pad=0)
@@ -344,7 +320,6 @@ def test_colorbar_horizontal_size():
344320

345321

346322
def test_colorbar_vertical_two_axes():
347-
348323
# use two horizontal axes
349324
with figure_context():
350325
h, axs = create_figure_subplots(1, 2)
@@ -393,7 +368,6 @@ def test_colorbar_vertical_two_axes():
393368

394369

395370
def test_colorbar_horizontal_two_axes():
396-
397371
# use two horizontal axes
398372
with figure_context():
399373
h, axs = create_figure_subplots(2, 1, orientation="horizontal")
@@ -457,9 +431,7 @@ def test_colorbar_horizontal_two_axes():
457431

458432

459433
def test_colorbar_errors():
460-
461434
with subplots_context() as (f, ax):
462-
463435
h = ax.pcolormesh([[0, 1]])
464436

465437
with pytest.raises(
@@ -478,9 +450,7 @@ def test_colorbar_errors():
478450

479451

480452
def test_get_cbax():
481-
482453
with subplots_context() as (f, ax):
483-
484454
cbax = _get_cbax(f)
485455

486456
assert isinstance(cbax, plt.Axes)

0 commit comments

Comments
 (0)