Debian Codegraph @

mplexporter/tests/test_utils.py

raw symbols SCIP
1 from numpy.testing import assert_allclose, assert_equal
2 from . import plt
3 from .. import utils
4
5
6 def test_path_data():
7 circle = plt.Circle((0, 0), 1)
8 vertices, codes = utils.SVG_path(circle.get_path())
9
10 assert_allclose(vertices.shape, (25, 2))
11 assert_equal(codes, ['M', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'Z'])
12
13
14 def test_linestyle():
15 linestyles = {'solid': 'none', '-': 'none',
16 'dashed': '6,6', '--': '6,6',
17 'dotted': '2,2', ':': '2,2',
18 'dashdot': '4,4,2,4', '-.': '4,4,2,4',
19 '': None, 'None': None}
20
21 for ls, result in linestyles.items():
22 line, = plt.plot([1, 2, 3], linestyle=ls)
23 assert_equal(utils.get_dasharray(line), result)
24
25
26 def test_axis_w_fixed_formatter():
27 positions, labels = [0, 1, 10], ['A','B','C']
28
29 plt.xticks(positions, labels)
30 props = utils.get_axis_properties(plt.gca().xaxis)
31
32 assert_equal(props['tickvalues'], positions)
33 assert_equal(props['tickformat'], labels)
34