a6971c768d
To reduce complexity, and make it easier to add more images and tests, the images in the `test-data` repository should be merged with the main repository. Furthermore, we can remove a lot of the subprocess work in the image_testing.py file, as we no longer need to have it interact with git. The images are not the same. Images were regenerated with Qt6, and now have proper big and little endian handling thanks to @pijyoi Second commit is a slightly modified variant of 2e135ab282d6007b34a3854921be54d0e9efb241 authored by @pijyoi it is to convert qimages to RGBA8888 for testing. Image files were regenerated images for the big/little handling Fixed issue with bogus test from test_NonUniformImage and generated a new image
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
import pytest
|
|
import pyqtgraph as pg
|
|
from pyqtgraph.exporters import MatplotlibExporter
|
|
pytest.importorskip("matplotlib")
|
|
|
|
app = pg.mkQApp()
|
|
|
|
skip_qt6 = pytest.mark.skipif(
|
|
pg.QT_LIB in ["PySide6", "PyQt6"],
|
|
reason= (
|
|
"Matplotlib has no Qt6 support yet, "
|
|
"see https://github.com/matplotlib/matplotlib/pull/19255"
|
|
)
|
|
)
|
|
|
|
|
|
@skip_qt6
|
|
def test_MatplotlibExporter():
|
|
plt = pg.plot()
|
|
|
|
# curve item
|
|
plt.plot([0, 1, 2], [0, 1, 2])
|
|
# scatter item
|
|
plt.plot([0, 1, 2], [1, 2, 3], pen=None, symbolBrush='r')
|
|
# curve + scatter
|
|
plt.plot([0, 1, 2], [2, 3, 4], pen='k', symbolBrush='r')
|
|
|
|
exp = MatplotlibExporter(plt.getPlotItem())
|
|
exp.export()
|
|
|
|
@skip_qt6
|
|
def test_MatplotlibExporter_nonplotitem():
|
|
# attempting to export something other than a PlotItem raises an exception
|
|
plt = pg.plot()
|
|
plt.plot([0, 1, 2], [2, 3, 4])
|
|
exp = MatplotlibExporter(plt.getPlotItem().getViewBox())
|
|
with pytest.raises(Exception):
|
|
exp.export()
|
|
|
|
@skip_qt6
|
|
@pytest.mark.parametrize('scale', [1e10, 1e-9])
|
|
def test_MatplotlibExporter_siscale(scale):
|
|
# coarse test to verify that plot data is scaled before export when
|
|
# autoSIPrefix is in effect (so mpl doesn't add its own multiplier label)
|
|
plt = pg.plot([0, 1, 2], [(i+1)*scale for i in range(3)])
|
|
# set the label so autoSIPrefix works
|
|
plt.setLabel('left', 'magnitude')
|
|
exp = MatplotlibExporter(plt.getPlotItem())
|
|
exp.export()
|
|
|
|
mpw = MatplotlibExporter.windows[-1]
|
|
fig = mpw.getFigure()
|
|
ymin, ymax = fig.axes[0].get_ylim()
|
|
|
|
if scale < 1:
|
|
assert ymax > scale
|
|
else:
|
|
assert ymax < scale
|