def test_update(self, qtbot, mocker):
        psdwfx = PsdWaterfallPlotWidget()
        psdwfy = PsdWaterfallPlotWidget()
        psd1dx = Psd1dPlotWidget()
        psd1dy = Psd1dPlotWidget()
        qtbot.addWidget(psdwfx)
        qtbot.addWidget(psdwfy)
        qtbot.addWidget(psd1dx)
        qtbot.addWidget(psd1dy)

        pfc = PlotPsdController(psdwfx, psdwfy, psd1dx, psd1dy)
        pfc.setup(self.arraySize, self.timeScale)

        np.random.seed(3000)
        psdDataX = np.random.random(7)
        psdDataY = np.random.random(7)
        freqs = np.random.random(7)

        mockPsdWaterfallXPlotUpdatePlot = mocker.patch.object(
            pfc.psdWaterfallXPlot, 'updatePlot')
        mockPsdWaterfallYPlotUpdatePlot = mocker.patch.object(
            pfc.psdWaterfallYPlot, 'updatePlot')
        mockPsd1dXPlotUpdatePlot = mocker.patch.object(pfc.psd1dXPlot,
                                                       'updatePlot')
        mockPsd1dYPlotUpdatePlot = mocker.patch.object(pfc.psd1dYPlot,
                                                       'updatePlot')

        pfc.update(psdDataX, psdDataY, freqs)

        assert mockPsdWaterfallXPlotUpdatePlot.call_count == 1
        assert mockPsdWaterfallYPlotUpdatePlot.call_count == 1
        assert mockPsd1dXPlotUpdatePlot.call_count == 1
        assert mockPsd1dYPlotUpdatePlot.call_count == 1
    def test_setPlotConfiguration(self, qtbot, mocker):
        psdwfx = PsdWaterfallPlotWidget()
        psdwfy = PsdWaterfallPlotWidget()
        psd1dx = Psd1dPlotWidget()
        psd1dy = Psd1dPlotWidget()
        qtbot.addWidget(psdwfx)
        qtbot.addWidget(psdwfy)
        qtbot.addWidget(psd1dx)
        qtbot.addWidget(psd1dy)

        pfc = PlotPsdController(psdwfx, psdwfy, psd1dx, psd1dy)
        pfc.setup(self.arraySize, self.timeScale)

        mockPsdXWaterfallSetConfig = mocker.patch.object(
            pfc.psdWaterfallXPlot, 'setConfiguration')
        mockPsdYWaterfallSetConfig = mocker.patch.object(
            pfc.psdWaterfallYPlot, 'setConfiguration')
        mockPsdX1dSetConfig = mocker.patch.object(pfc.psd1dXPlot,
                                                  'setConfiguration')
        mockPsdY1dSetConfig = mocker.patch.object(pfc.psd1dYPlot,
                                                  'setConfiguration')

        pfc.setPlotConfiguration(self.truthConfig)

        assert mockPsdXWaterfallSetConfig.call_count == 1
        assert mockPsdYWaterfallSetConfig.call_count == 1
        assert mockPsdX1dSetConfig.call_count == 1
        assert mockPsdY1dSetConfig.call_count == 1
    def test_handleAcquireRoiStateChange(self, qtbot, mocker):
        psdwfx = PsdWaterfallPlotWidget()
        psdwfy = PsdWaterfallPlotWidget()
        psd1dx = Psd1dPlotWidget()
        psd1dy = Psd1dPlotWidget()
        qtbot.addWidget(psdwfx)
        qtbot.addWidget(psdwfy)
        qtbot.addWidget(psd1dx)
        qtbot.addWidget(psd1dy)

        pfc = PlotPsdController(psdwfx, psdwfy, psd1dx, psd1dy)
        pfc.setup(self.arraySize, self.timeScale)

        mockPsdXWaterfallClearPlot = mocker.patch.object(
            pfc.psdWaterfallXPlot, 'clearPlot')
        mockPsdYWaterfallClearPlot = mocker.patch.object(
            pfc.psdWaterfallYPlot, 'clearPlot')
        mockPsdX1dClearPlot = mocker.patch.object(pfc.psd1dXPlot, 'clearPlot')
        mockPsdY1dClearPlot = mocker.patch.object(pfc.psd1dYPlot, 'clearPlot')

        pfc.handleAcquireRoiStateChange(Qt.Unchecked)

        assert mockPsdXWaterfallClearPlot.call_count == 1
        assert mockPsdYWaterfallClearPlot.call_count == 1
        assert mockPsdX1dClearPlot.call_count == 1
        assert mockPsdY1dClearPlot.call_count == 1
Ejemplo n.º 4
0
 def test_parametersAfterSetup(self, qtbot):
     pwpw = PsdWaterfallPlotWidget()
     qtbot.addWidget(pwpw)
     arraySize = 5
     pwpw.setup(arraySize, self.timeScale, 'X')
     assert pwpw.arraySize == arraySize
     assert pwpw.timeScale == self.timeScale
    def test_badFftData(self, qtbot, mocker):
        psdwfx = PsdWaterfallPlotWidget()
        psdwfy = PsdWaterfallPlotWidget()
        psd1dx = Psd1dPlotWidget()
        psd1dy = Psd1dPlotWidget()
        qtbot.addWidget(psdwfx)
        qtbot.addWidget(psdwfy)
        qtbot.addWidget(psd1dx)
        qtbot.addWidget(psd1dy)

        pfc = PlotPsdController(psdwfx, psdwfy, psd1dx, psd1dy)
        pfc.setup(self.arraySize, self.timeScale)

        mockPsdXPlotUpdatePlot = mocker.patch.object(pfc.psdWaterfallXPlot,
                                                     'updatePlot')
        mockPsdYPlotUpdatePlot = mocker.patch.object(pfc.psdWaterfallYPlot,
                                                     'updatePlot')
        mockPsd1dXPlotUpdatePlot = mocker.patch.object(pfc.psd1dXPlot,
                                                       'updatePlot')
        mockPsd1dYPlotUpdatePlot = mocker.patch.object(pfc.psd1dYPlot,
                                                       'updatePlot')
        pfc.update(None, None, None)

        assert mockPsdXPlotUpdatePlot.call_count == 0
        assert mockPsdYPlotUpdatePlot.call_count == 0
        assert mockPsd1dXPlotUpdatePlot.call_count == 0
        assert mockPsd1dYPlotUpdatePlot.call_count == 0
Ejemplo n.º 6
0
 def test_getConfiguration(self, qtbot):
     self.pwpw1 = PsdWaterfallPlotWidget()
     qtbot.addWidget(self.pwpw1)
     arraySize = 5
     self.pwpw1.setup(arraySize, self.timeScale, 'X')
     truthNumBins = 5
     truthColorMap = 'viridis'
     numBins, colorMap = self.pwpw1.getConfiguration()
     assert numBins == truthNumBins
     assert colorMap == truthColorMap
    def test_parametersAfterContruction(self, qtbot):
        psdwfx = PsdWaterfallPlotWidget()
        psdwfy = PsdWaterfallPlotWidget()
        psd1dx = Psd1dPlotWidget()
        psd1dy = Psd1dPlotWidget()
        qtbot.addWidget(psdwfx)
        qtbot.addWidget(psdwfy)
        qtbot.addWidget(psd1dx)
        qtbot.addWidget(psd1dy)

        pfc = PlotPsdController(psdwfx, psdwfy, psd1dx, psd1dy)
        assert pfc.psdWaterfallXPlot is not None
        assert pfc.psdWaterfallYPlot is not None
        assert pfc.psd1dXPlot is not None
        assert pfc.psd1dYPlot is not None
    def test_getPlotConfiguration(self, qtbot):
        psdwfx = PsdWaterfallPlotWidget()
        psdwfy = PsdWaterfallPlotWidget()
        psd1dx = Psd1dPlotWidget()
        psd1dy = Psd1dPlotWidget()
        qtbot.addWidget(psdwfx)
        qtbot.addWidget(psdwfy)
        qtbot.addWidget(psd1dx)
        qtbot.addWidget(psd1dy)

        pfc = PlotPsdController(psdwfx, psdwfy, psd1dx, psd1dy)
        pfc.setup(self.arraySize, self.timeScale)

        currentConfig = pfc.getPlotConfiguration()
        assert currentConfig == self.truthConfig
    def test_parametersAfterSetup(self, qtbot, mocker):
        psdwfx = PsdWaterfallPlotWidget()
        psdwfy = PsdWaterfallPlotWidget()
        psd1dx = Psd1dPlotWidget()
        psd1dy = Psd1dPlotWidget()
        qtbot.addWidget(psdwfx)
        qtbot.addWidget(psdwfy)
        qtbot.addWidget(psd1dx)
        qtbot.addWidget(psd1dy)

        pfc = PlotPsdController(psdwfx, psdwfy, psd1dx, psd1dy)
        mockSetup1dXPlot = mocker.patch.object(pfc.psd1dXPlot, 'setup')
        mockSetup1dYPlot = mocker.patch.object(pfc.psd1dYPlot, 'setup')
        pfc.setup(self.arraySize, self.timeScale)
        assert pfc.psdWaterfallXPlot.arraySize == self.arraySize
        assert pfc.psdWaterfallYPlot.arraySize == self.arraySize
        assert mockSetup1dXPlot.call_count == 1
        assert mockSetup1dYPlot.call_count == 1
Ejemplo n.º 10
0
 def test_parametersAfterConstruction(self, qtbot):
     pwpw = PsdWaterfallPlotWidget()
     qtbot.addWidget(pwpw)
     assert pwpw.image is not None
     assert pwpw.data is None
     assert pwpw.arraySize is None
     assert pwpw.boundingRect is None
     assert pwpw.timeScale is None
     assert pwpw.colorMap == 'viridis'
    def test_updateTimeScale(self, qtbot, mocker):
        psdwfx = PsdWaterfallPlotWidget()
        psdwfy = PsdWaterfallPlotWidget()
        psd1dx = Psd1dPlotWidget()
        psd1dy = Psd1dPlotWidget()
        qtbot.addWidget(psdwfx)
        qtbot.addWidget(psdwfy)
        qtbot.addWidget(psd1dx)
        qtbot.addWidget(psd1dy)

        pfc = PlotPsdController(psdwfx, psdwfy, psd1dx, psd1dy)
        pfc.setup(self.arraySize, self.timeScale)

        mockPsdXPlotSetTimeScale = mocker.patch.object(pfc.psdWaterfallXPlot,
                                                       'setTimeScale')
        mockPsdYPlotSetTimeScale = mocker.patch.object(pfc.psdWaterfallYPlot,
                                                       'setTimeScale')
        pfc.updateTimeScale(100)

        assert mockPsdXPlotSetTimeScale.call_count == 1
        assert mockPsdYPlotSetTimeScale.call_count == 1
Ejemplo n.º 12
0
    def test_updateTimeScale(self, qtbot, mocker):
        self.pwpw1 = PsdWaterfallPlotWidget()
        qtbot.addWidget(self.pwpw1)
        mockSetImage = mocker.patch.object(self.pwpw1.image, 'setImage')
        mockSetImage.side_effect = self.setImage
        arraySize = 3
        self.pwpw1.setup(arraySize, self.timeScale, 'X')

        self.pwpw1.updatePlot(self.p1, self.p3)
        newTimeScale = 20
        self.pwpw1.setTimeScale(newTimeScale)
        assert self.pwpw1.timeScale == newTimeScale
        assert self.pwpw1.boundingRect is None
        assert self.pwpw1.data is None

        self.pwpw1.updatePlot(self.p2, self.p3)
        rectCoords = self.pwpw1.boundingRect.getCoords()
        assert rectCoords[0] == 0
        assert rectCoords[1] == 0
        assert rectCoords[2] == 1.2
        assert rectCoords[3] == 60
Ejemplo n.º 13
0
 def test_clearPlot(self, qtbot, mocker):
     pwpw2 = PsdWaterfallPlotWidget()
     qtbot.addWidget(pwpw2)
     arraySize = 5
     mockImageClear = mocker.patch.object(pwpw2.image, 'clear')
     pwpw2.setup(arraySize, self.timeScale, 'X')
     pwpw2.clearPlot()
     assert pwpw2.data is None
     assert pwpw2.boundingRect is None
     assert mockImageClear.call_count == 1
Ejemplo n.º 14
0
 def test_setConfiguration(self, qtbot):
     pwpw2 = PsdWaterfallPlotWidget()
     qtbot.addWidget(pwpw2)
     arraySize = 5
     pwpw2.setup(arraySize, self.timeScale, 'X')
     truthConfig = PsdPlotConfig()
     truthConfig.numWaterfallBins = 10
     truthConfig.waterfallColorMap = 'plasma'
     pwpw2.setConfiguration(truthConfig)
     assert pwpw2.arraySize == truthConfig.numWaterfallBins
     assert pwpw2.data is None
     assert pwpw2.boundingRect is None
     assert pwpw2.colorMap == truthConfig.waterfallColorMap
Ejemplo n.º 15
0
 def setup_class(cls):
     cls.pwpw1 = PsdWaterfallPlotWidget()
     cls.timeScale = 10
     cls.p1 = np.arange(5, dtype=float) + 1
     cls.p2 = np.arange(5, 10, dtype=float) + 1
     cls.p3 = np.linspace(0.2, 1.2, 5)
Ejemplo n.º 16
0
class TestPsdWaterfallPlotWidget:
    def setImage(*args):
        # args[0] is test class instance
        # args[1] is argument to ImageItem::setImage call
        args[0].pwpw1.image.image = args[1]

    def setup_class(cls):
        cls.pwpw1 = PsdWaterfallPlotWidget()
        cls.timeScale = 10
        cls.p1 = np.arange(5, dtype=float) + 1
        cls.p2 = np.arange(5, 10, dtype=float) + 1
        cls.p3 = np.linspace(0.2, 1.2, 5)

    def test_parametersAfterConstruction(self, qtbot):
        pwpw = PsdWaterfallPlotWidget()
        qtbot.addWidget(pwpw)
        assert pwpw.image is not None
        assert pwpw.data is None
        assert pwpw.arraySize is None
        assert pwpw.boundingRect is None
        assert pwpw.timeScale is None
        assert pwpw.colorMap == 'viridis'

    def test_parametersAfterSetup(self, qtbot):
        pwpw = PsdWaterfallPlotWidget()
        qtbot.addWidget(pwpw)
        arraySize = 5
        pwpw.setup(arraySize, self.timeScale, 'X')
        assert pwpw.arraySize == arraySize
        assert pwpw.timeScale == self.timeScale

    def test_parametersAfterUpdatePlot(self, qtbot, mocker):
        qtbot.addWidget(self.pwpw1)
        mockSetImage = mocker.patch.object(self.pwpw1.image, 'setImage')
        mockSetImage.side_effect = self.setImage
        arraySize = 3
        self.pwpw1.setup(arraySize, self.timeScale, 'X')

        self.pwpw1.updatePlot(self.p1, self.p3)
        assert self.pwpw1.data.shape == (arraySize, self.p1.size)
        assert (self.pwpw1.data[0, ...] == np.log(self.p1)).all()
        assert mockSetImage.call_count == 1
        rectCoords = self.pwpw1.boundingRect.getCoords()
        assert rectCoords[0] == 0
        assert rectCoords[1] == 0
        assert rectCoords[2] == 1.2
        assert rectCoords[3] == 30

        self.pwpw1.updatePlot(self.p2, self.p3)
        assert (self.pwpw1.data[0, ...] == np.log(self.p2)).all()
        assert (self.pwpw1.data[1, ...] == np.log(self.p1)).all()
        assert mockSetImage.call_count == 2

    def test_updateTimeScale(self, qtbot, mocker):
        self.pwpw1 = PsdWaterfallPlotWidget()
        qtbot.addWidget(self.pwpw1)
        mockSetImage = mocker.patch.object(self.pwpw1.image, 'setImage')
        mockSetImage.side_effect = self.setImage
        arraySize = 3
        self.pwpw1.setup(arraySize, self.timeScale, 'X')

        self.pwpw1.updatePlot(self.p1, self.p3)
        newTimeScale = 20
        self.pwpw1.setTimeScale(newTimeScale)
        assert self.pwpw1.timeScale == newTimeScale
        assert self.pwpw1.boundingRect is None
        assert self.pwpw1.data is None

        self.pwpw1.updatePlot(self.p2, self.p3)
        rectCoords = self.pwpw1.boundingRect.getCoords()
        assert rectCoords[0] == 0
        assert rectCoords[1] == 0
        assert rectCoords[2] == 1.2
        assert rectCoords[3] == 60

    def test_getConfiguration(self, qtbot):
        self.pwpw1 = PsdWaterfallPlotWidget()
        qtbot.addWidget(self.pwpw1)
        arraySize = 5
        self.pwpw1.setup(arraySize, self.timeScale, 'X')
        truthNumBins = 5
        truthColorMap = 'viridis'
        numBins, colorMap = self.pwpw1.getConfiguration()
        assert numBins == truthNumBins
        assert colorMap == truthColorMap

    def test_setConfiguration(self, qtbot):
        pwpw2 = PsdWaterfallPlotWidget()
        qtbot.addWidget(pwpw2)
        arraySize = 5
        pwpw2.setup(arraySize, self.timeScale, 'X')
        truthConfig = PsdPlotConfig()
        truthConfig.numWaterfallBins = 10
        truthConfig.waterfallColorMap = 'plasma'
        pwpw2.setConfiguration(truthConfig)
        assert pwpw2.arraySize == truthConfig.numWaterfallBins
        assert pwpw2.data is None
        assert pwpw2.boundingRect is None
        assert pwpw2.colorMap == truthConfig.waterfallColorMap

    def test_clearPlot(self, qtbot, mocker):
        pwpw2 = PsdWaterfallPlotWidget()
        qtbot.addWidget(pwpw2)
        arraySize = 5
        mockImageClear = mocker.patch.object(pwpw2.image, 'clear')
        pwpw2.setup(arraySize, self.timeScale, 'X')
        pwpw2.clearPlot()
        assert pwpw2.data is None
        assert pwpw2.boundingRect is None
        assert mockImageClear.call_count == 1