|
| 1 | +import warnings |
| 2 | + |
1 | 3 | from matplotlib.testing.decorators import image_comparison, cleanup
|
2 | 4 | import matplotlib.pyplot as plt
|
3 | 5 | import numpy as np
|
@@ -147,6 +149,30 @@ def test_valid_input_forms():
|
147 | 149 | assert True
|
148 | 150 |
|
149 | 151 |
|
| 152 | +@cleanup |
| 153 | +def test_cycle_reset(): |
| 154 | + fig, ax = plt.subplots() |
| 155 | + |
| 156 | + # Can't really test a reset because only a cycle object is stored |
| 157 | + # but we can test the first item of the cycle. |
| 158 | + prop = next(ax._get_lines.prop_cycler) |
| 159 | + ax.set_prop_cycle(linewidth=[10, 9, 4]) |
| 160 | + assert prop != next(ax._get_lines.prop_cycler) |
| 161 | + ax.set_prop_cycle(None) |
| 162 | + got = next(ax._get_lines.prop_cycler) |
| 163 | + assert prop == got, "expected %s, got %s" % (prop, got) |
| 164 | + |
| 165 | + fig, ax = plt.subplots() |
| 166 | + # Need to double-check the old set/get_color_cycle(), too |
| 167 | + with warnings.catch_warnings(): |
| 168 | + prop = next(ax._get_lines.prop_cycler) |
| 169 | + ax.set_color_cycle(['c', 'm', 'y', 'k']) |
| 170 | + assert prop != next(ax._get_lines.prop_cycler) |
| 171 | + ax.set_color_cycle(None) |
| 172 | + got = next(ax._get_lines.prop_cycler) |
| 173 | + assert prop == got, "expected %s, got %s" % (prop, got) |
| 174 | + |
| 175 | + |
150 | 176 | @cleanup
|
151 | 177 | def test_invalid_input_forms():
|
152 | 178 | fig, ax = plt.subplots()
|
|
0 commit comments