is_constant¶
- typhoon.test.signals.is_constant(signal, at_value, during=None, strictness=1, report_plot=None)¶
Checks if signal is always inside defined range.
- Parameters:
signal (pandas.Series) – Signal to be tested for.
at_value (tuple/list or number) – Band inside with signal should always be. Can be passed as a tuple/list with two elements for a range, or as a single value for an exact value.
during (tuple) – Time period (as a range) to be considered for analysis.
strictness (float) – Number between 0.0 and 1.0 that determines percentage of time signal should be inside the defined range for test to pass.
report_plot (dict) –
Dictionary which overrides default allure report plot attachment behaviour. It also overrides behaviour specified for whole test run with command line arguments
--analysis-plot-type
and--analysis-plot-on-fail-only
. Dictionary has two keys to be specified:type
: specifies which kind of allure plot should be used. Valid values:static
- only matplotlib plot attached as .png picture is attachedinteractive
- only interactive html plot created with bokeh library is attached. Advantage of this plot it has options to zoom in/zoom out. Disadvantage is that it consumes significantly more memory.none
- none of the plots will be attachedall
- all plots will be added. Currently supported ones are matplotlib plot(static) and bokeh plot(interactive)
when
: specifies when to add plots that are specified with previous key to report. Available options:always
- always adds specified plotson-fail
- adds plots only if comparison of reference and measured signal fails. This is good way to decrease size of allure plots.
Note
If
report_plot
argument is not provided, and command line arguments--analysis-plot-type
andanalysis-plot-on-fail-only
are not specified, default behaviour is static plot, attached always. If command line arguments are specified, they define new default behaviour for whole test run.
- Returns:
result – Result of the analysis.
- Return type:
AnalysisResult
Examples
>>> val = 220 >>> tol = val * 0.01 >>> result = is_constant(capture["Va_rms"], at_value=(val-tol, val+tol)) >>> assert result == True, result.msg
or
>>> from typhoon.test.ranges import around >>> result = is_constant(capture["Va_rms"], at_value=around(val, tol_p=0.01)) >>> assert result == True, result.msg
A more compact and readable function is obteined using assertion helpers:
>>> assert_is_constant(capture["Va_rms"], at_value=around(val, tol_p=0.01))
See also
typhoon.test.signals.AnalysisResult
,typhoon.test.signals.assert_is_constant