Commit 9a3393d3 authored by Valentin Valls's avatar Valentin Valls

Add coverage for derivative function

parent d8933038
......@@ -4,6 +4,7 @@ import numpy
from silx.gui import qt
from bliss.flint.model import plot_state_model
from bliss.flint.model import plot_item_model
from bliss.flint.model import scan_model
class CurveMock(qt.QObject, plot_item_model.CurveMixIn):
......@@ -81,3 +82,18 @@ def test_max_incremental_compute_2():
assert result.max_location_x == 20
assert result.max_location_y == 500
assert result.min_y_value == -10
def test_derivative_compute():
"""Compute the derivative function"""
scan = scan_model.Scan()
yy = [0] * 5 + list(range(10)) + list(reversed(range(10))) + [0] * 5
yy = numpy.cumsum(yy)
xx = numpy.arange(len(yy)) * 10
item = plot_state_model.DerivativeItem()
curveItem = CurveMock(xx=xx, yy=yy)
item.setSource(curveItem)
result = item.compute(scan)
assert result is not None
assert len(item.xArray(scan)) == len(xx) - 5 * 2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment