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

Function test_empty_default_limits

lib/matplotlib/tests/test_units.py:274–312  ·  view source on GitHub ↗
(quantity_converter)

Source from the content-addressed store, hash-verified

272
273
274def test_empty_default_limits(quantity_converter):
275 munits.registry[Quantity] = quantity_converter
276 fig, ax1 = plt.subplots()
277 ax1.xaxis.update_units(Quantity([10], "miles"))
278 fig.draw_without_rendering()
279 assert ax1.get_xlim() == (0, 100)
280 ax1.yaxis.update_units(Quantity([10], "miles"))
281 fig.draw_without_rendering()
282 assert ax1.get_ylim() == (0, 100)
283
284 fig, ax = plt.subplots()
285 ax.axhline(30)
286 ax.plot(Quantity(np.arange(0, 3), "miles"),
287 Quantity(np.arange(0, 6, 2), "feet"))
288 fig.draw_without_rendering()
289 assert ax.get_xlim() == (0, 2)
290 assert ax.get_ylim() == (0, 30)
291
292 fig, ax = plt.subplots()
293 ax.axvline(30)
294 ax.plot(Quantity(np.arange(0, 3), "miles"),
295 Quantity(np.arange(0, 6, 2), "feet"))
296 fig.draw_without_rendering()
297 assert ax.get_xlim() == (0, 30)
298 assert ax.get_ylim() == (0, 4)
299
300 fig, ax = plt.subplots()
301 ax.xaxis.update_units(Quantity([10], "miles"))
302 ax.axhline(30)
303 fig.draw_without_rendering()
304 assert ax.get_xlim() == (0, 100)
305 assert ax.get_ylim() == (28.5, 31.5)
306
307 fig, ax = plt.subplots()
308 ax.yaxis.update_units(Quantity([10], "miles"))
309 ax.axvline(30)
310 fig.draw_without_rendering()
311 assert ax.get_ylim() == (0, 100)
312 assert ax.get_xlim() == (28.5, 31.5)
313
314
315# test array-like objects...

Callers

nothing calls this directly

Calls 9

QuantityClass · 0.85
update_unitsMethod · 0.80
axhlineMethod · 0.80
axvlineMethod · 0.80
subplotsMethod · 0.45
get_xlimMethod · 0.45
get_ylimMethod · 0.45
plotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…