MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_stem_args

Function test_stem_args

lib/matplotlib/tests/test_axes.py:4980–5004  ·  view source on GitHub ↗

Test that stem() correctly identifies x and y values.

()

Source from the content-addressed store, hash-verified

4978
4979
4980def 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
5007def test_stem_markerfmt():

Callers

nothing calls this directly

Calls 3

_assert_equalFunction · 0.85
subplotsMethod · 0.45
stemMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…