test_gridspec.py 960 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import matplotlib.gridspec as gridspec
  2. import pytest
  3. def test_equal():
  4. gs = gridspec.GridSpec(2, 1)
  5. assert gs[0, 0] == gs[0, 0]
  6. assert gs[:, 0] == gs[:, 0]
  7. def test_width_ratios():
  8. """
  9. Addresses issue #5835.
  10. See at https://github.com/matplotlib/matplotlib/issues/5835.
  11. """
  12. with pytest.raises(ValueError):
  13. gridspec.GridSpec(1, 1, width_ratios=[2, 1, 3])
  14. def test_height_ratios():
  15. """
  16. Addresses issue #5835.
  17. See at https://github.com/matplotlib/matplotlib/issues/5835.
  18. """
  19. with pytest.raises(ValueError):
  20. gridspec.GridSpec(1, 1, height_ratios=[2, 1, 3])
  21. def test_repr():
  22. ss = gridspec.GridSpec(3, 3)[2, 1:3]
  23. assert repr(ss) == "GridSpec(3, 3)[2:3, 1:3]"
  24. ss = gridspec.GridSpec(2, 2,
  25. height_ratios=(3, 1),
  26. width_ratios=(1, 3))
  27. assert repr(ss) == \
  28. "GridSpec(2, 2, height_ratios=(3, 1), width_ratios=(1, 3))"