(quantity_converter)
| 83 | @image_comparison(['plot_pint.png'], style='mpl20', |
| 84 | tol=0 if platform.machine() == 'x86_64' else 0.03) |
| 85 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…