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

Function test_explicit_converter

lib/matplotlib/tests/test_units.py:241–271  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

239
240
241def test_explicit_converter():
242 d1 = {"a": 1, "b": 2}
243 str_cat_converter = StrCategoryConverter()
244 str_cat_converter_2 = StrCategoryConverter()
245 date_converter = DateConverter()
246
247 # Explicit is set
248 fig1, ax1 = plt.subplots()
249 ax1.xaxis.set_converter(str_cat_converter)
250 assert ax1.xaxis.get_converter() == str_cat_converter
251 # Explicit not overridden by implicit
252 ax1.plot(d1.keys(), d1.values())
253 assert ax1.xaxis.get_converter() == str_cat_converter
254 # No error when called twice with equivalent input
255 ax1.xaxis.set_converter(str_cat_converter)
256 # Error when explicit called twice
257 with pytest.raises(RuntimeError):
258 ax1.xaxis.set_converter(str_cat_converter_2)
259
260 fig2, ax2 = plt.subplots()
261 ax2.plot(d1.keys(), d1.values())
262
263 # No error when equivalent type is used
264 ax2.xaxis.set_converter(str_cat_converter)
265
266 fig3, ax3 = plt.subplots()
267 ax3.plot(d1.keys(), d1.values())
268
269 # Warn when implicit overridden
270 with pytest.warns():
271 ax3.xaxis.set_converter(date_converter)
272
273
274def test_empty_default_limits(quantity_converter):

Callers

nothing calls this directly

Calls 7

DateConverterClass · 0.90
set_converterMethod · 0.80
valuesMethod · 0.80
subplotsMethod · 0.45
get_converterMethod · 0.45
plotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…