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

Function test_numpy_facade

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

Source from the content-addressed store, hash-verified

83@image_comparison(['plot_pint.png'], style='mpl20',
84 tol=0 if platform.machine() == 'x86_64' else 0.03)
85def test_numpy_facade(quantity_converter):
86 # use former defaults to match existing baseline image
87 plt.rcParams['axes.formatter.limits'] = -7, 7
88
89 # Register the class
90 munits.registry[Quantity] = quantity_converter
91
92 # Simple test
93 y = Quantity(np.linspace(0, 30), 'miles')
94 x = Quantity(np.linspace(0, 5), 'hours')
95
96 fig, ax = plt.subplots()
97 fig.subplots_adjust(left=0.15) # Make space for label
98 ax.plot(x, y, 'tab:blue')
99 ax.axhline(Quantity(26400, 'feet'), color='tab:red')
100 ax.axvline(Quantity(120, 'minutes'), color='tab:green')
101 ax.yaxis.set_units('inches')
102 ax.xaxis.set_units('seconds')
103
104 assert quantity_converter.convert.called
105 assert quantity_converter.axisinfo.called
106 assert quantity_converter.default_units.called
107
108
109# Tests gh-8908

Callers

nothing calls this directly

Calls 7

QuantityClass · 0.85
subplots_adjustMethod · 0.80
axhlineMethod · 0.80
axvlineMethod · 0.80
set_unitsMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…