Completed
Push — master ( 8b3414...5729ab )
by Ryan
01:13
created

test_scattertext_patheffect_empty()   A

Complexity

Conditions 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
1
# Copyright (c) 2008-2016 MetPy Developers.
2
# Distributed under the terms of the BSD 3-Clause License.
3
# SPDX-License-Identifier: BSD-3-Clause
4
5
from tempfile import TemporaryFile
6
7
import matplotlib.patheffects as mpatheffects
8
import numpy as np
9
10
from metpy.testing import make_figure
11
12
# Needed to trigger scattertext monkey-patching
13
import metpy.plots  # noqa: F401
14
15
16
# Avoiding an image-based test here since that would involve text, which can be tricky
17
# to handle robustly
18
def test_scattertext_patheffect_empty():
19
    'Test scattertext with empty strings and PathEffects (Issue #245)'
20
    strings = ['abc', '', 'def']
21
    x, y = np.arange(6).reshape(2, 3)
22
    fig = make_figure()
23
    ax = fig.add_subplot(1, 1, 1)
24
    ax.scattertext(x, y, strings, color='white',
25
                   path_effects=[mpatheffects.withStroke(linewidth=1, foreground='black')])
26
27
    # Need to trigger a render
28
    with TemporaryFile('wb') as fobj:
29
        fig.savefig(fobj)
30