autom8qc.qaqc.flatline

FlatLineTest

Class

class autom8qc.qaqc.flatline.FlatLineTest(stuck_points, atol=1e-06)

Bases: autom8qc.qaqc.base.QAQCTest

This class implements a test that identifies repeated occurrence of one value in a time series. Each instance of the class requires the parameter stuck_points that defines the number of stuck points. Optional, you can set the parameter atol that allows you to define an absolute tolerance.

Important

The test ignores the time-index and considers only the values

Parameters
  • NAME (str) – Name of the test

  • DESCRIPTION (str) – Description of the test

  • CATEGORY (str) – Category of the test

  • SUPPORTED_STRUCTURES (tuple or BaseStructure) – Supported data structures

  • parameters (ParameterList) – Supported parameters

Supported parameters:
  • stuck_points (int): Number of stuck points

  • atol (float): Absolute tolerance (default: 1e-6)

SUPPORTED_STRUCTURES

alias of autom8qc.core.structures.Series

perform(data)

Performs the test and returns the probabilities.

Raises

InvalidType – If structure of the given data is not supported

Parameters

data (BaseStructure, pd.Series, pd.DataFrame) – Data points

Returns

Probabilities (1=Valid, 0=Invalid)

Return type

pd.Series

static supported_parameters()

Returns the supported parameters.

Returns

Supported parameters

Return type

ParameterList

Example

# Generate sample data
import numpy as np
import pandas as pd
np.random.seed(42)
mu, sigma = 50, 3
values = np.random.normal(mu, sigma, 500)
values[100:140] = 48
values[250:] += 3
values[400:435] = 55
index = pd.date_range(start="1/1/2021", periods=500, freq="min")
series = pd.Series(values, index=index)

# Perform test and plot the results
from autom8qc.qaqc.flatline import FlatLineTest
test = FlatLineTest(stuck_points=30)
test.plot(series=series, series_name="Example")

Visualization

../_images/FlatLineTest.svg