Test that stem() correctly identifies x and y values.
()
| 4978 | |
| 4979 | |
| 4980 | def test_stem_args(): |
| 4981 | """Test that stem() correctly identifies x and y values.""" |
| 4982 | def _assert_equal(stem_container, expected): |
| 4983 | x, y = map(list, stem_container.markerline.get_data()) |
| 4984 | assert x == expected[0] |
| 4985 | assert y == expected[1] |
| 4986 | |
| 4987 | fig, ax = plt.subplots() |
| 4988 | |
| 4989 | x = [1, 3, 5] |
| 4990 | y = [9, 8, 7] |
| 4991 | |
| 4992 | # Test the call signatures |
| 4993 | _assert_equal(ax.stem(y), expected=([0, 1, 2], y)) |
| 4994 | _assert_equal(ax.stem(x, y), expected=(x, y)) |
| 4995 | _assert_equal(ax.stem(x, y, linefmt='r--'), expected=(x, y)) |
| 4996 | _assert_equal(ax.stem(x, y, 'r--'), expected=(x, y)) |
| 4997 | _assert_equal(ax.stem(x, y, linefmt='r--', basefmt='b--'), expected=(x, y)) |
| 4998 | _assert_equal(ax.stem(y, linefmt='r--'), expected=([0, 1, 2], y)) |
| 4999 | _assert_equal(ax.stem(y, 'r--'), expected=([0, 1, 2], y)) |
| 5000 | |
| 5001 | with pytest.raises(ValueError): |
| 5002 | ax.stem([[y]]) |
| 5003 | with pytest.raises(ValueError): |
| 5004 | ax.stem([[x]], y) |
| 5005 | |
| 5006 | |
| 5007 | def test_stem_markerfmt(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…