Base Components
Note
In object-oriented programming, the open–closed principle states software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. Such an entity can allow its behaviour to be extended without modifying its source code.
The base components are dedicated to performing one specific task and don’t know anything about the context. They save the metadata and implements only one method. This approach ensures that they are flexible and can easily adapt. All components inherit from the abstract base class BaseComponent since they share the same properties (DRY). Moreover, the inherited components are abstract as well (Open-Closed) and can be customized.
BaseComponent
Note
Don’t repeat yourself (DRY, or sometimes do not repeat yourself) is a principle of software development aimed at reducing repetition of software patterns, replacing it with abstractions or using data normalization to avoid redundancy.
- class autom8qc.core.components.BaseComponent
Bases:
abc.ABC
Abstract base class that defines the attributes for the base components. Each component has to provide its information (Name, Description, Supported parameters). The class provides the method check_metadata to check if the instance’s metadata is valid. Since all base components share the same attributes (NAME, DESCRIPTION, parameters), they have to inherit from this class. So you don’t have to implement the methods to check the metadata several times (DRY).
See also
autom8qc.core.parameters.ParameterList
- Parameters
NAME (str) – Name of the component
DESCRIPTION (str) – Description of the component
parameters (ParameterList) – Supported parameters (default: None)
- autom8qc.core.components.BaseComponent.check_metadata(self)
Checks if the defined metadata (NAME, DESCRIPTION, parameters) of the component is valid. If anything isn’t correctly defined, the method will raise an error for it.
Important
If you inherit from this class, make sure that call this method at the end of the constructor to validate the metadata of the instance.
- Raises
EmptyString – If NAME is not set or empty
InvalidType – If NAME is not a string
EmptyString – If DESCRIPTION is not set or empty
InvalidType – If DESCRIPTION is not a string
InvalidType – If parameters isn’t a ParameterList
InvalidValue – If an item in parameters is not a Parameter
- Returns
None
- Return type
None
QAQCTest
- class autom8qc.qaqc.base.QAQCTest
Bases:
autom8qc.core.components.BaseComponent
This class defines the interface for each QA/QC test. Each test has to provide its information (NAME, DESCRIPTION, CATEGORY, parameters and SUPPORTED_STRUCTURES). Moreover, each test has to implement the abstract method perform which expects an instance of the class BaseStructure and returns a probability (between 0 and 1) for each data point.
See also
autom8qc.core.components.BaseComponent
autom8qc.core.parameters.ParameterList
autom8qc.core.structures.BaseStructure
Warning
If you inherit from this class, make sure that you call the super constructor and implement the abstract method perform.
- 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 (e.g., Series)
parameters (ParameterList) – Supported parameters (default: None)
- autom8qc.qaqc.base.QAQCTest.perform(self, data)
Performs the test and returns the probabilities.
Warning
Make sure that you don’t override data points of the data. For effiency reasons the data won’t be copied.
Important
Use the method get_data to access the data. The method checks if the given data is supported by the test. Moreover, it ensures that your test supports instances of the class BaseStructure and the dtype of the BaseStructure. For example, if your test supports Series, you can pass the types pd.Series and autom8qc.core.structures.Series.
- Raises
NotImplementedError – This is an abstract method
- Parameters
data (BaseStructure, pd.Series, pd.DataFrame) – Data points
- Returns
Probabilities (1=Valid, 0=Invalid)
- Return type
pd.Series
Example: autom8qc.qaqc.flatline.FlatLineTest
BaseMapper
- class autom8qc.mappers.base.BaseMapper
Bases:
autom8qc.core.components.BaseComponent
Abstract base class that defines the interface for mappers. Each mapper has to provide its information (NAME, DESCRIPTION) and has to implement the abstract method map. The method maps the given values to another domain (e.g., probabilities to validities)
Warning
If you inherit from this class, make sure that you call the super constructor and implement the abstract method map.
See also
autom8qc.core.components.BaseComponent
autom8qc.core.parameters.ParameterList
- Parameters
NAME (str) – Name of the test
DESCRIPTION (str) – Description of the test
parameters (ParameterList) – Supported parameters (default: None)
- autom8qc.mappers.base.BaseMapper.map(self, values)
Maps the given values to other values (e.g. probabilities to flags).
Warning
Make sure that you don’t override data points of the data. For effiency reasons the data won’t be copied.
- Raises
NotImplementedError – This is an abstract method
- Parameters
values (pd.Series) – Values that should be mapped (e.g. probabilities)
- Returns
Mapped values
- Return type
pd.Series
BaseFunction
- class autom8qc.functions.base.BaseFunction
Bases:
autom8qc.core.components.BaseComponent
Abstract base class that defines the interface for functions. Each function has to provide its information (NAME, DESCRIPTION) and has to implement the abstract method apply. Functions can be used for preprocessing and postprocessing.
See also
autom8qc.core.components.BaseComponent
autom8qc.core.parameters.ParameterList
Warning
If you inherit from this class, make sure that you call the super constructor and implement the abstract method apply.
- Parameters
NAME (str) – Name of the function
DESCRIPTION (str) – Description of the function
parameters (ParameterList) – Supported parameters (default: None)
- autom8qc.functions.base.BaseFunction.apply(self, data)
Applies the function to the given data.
Warning
Make sure that you don’t override data points of the data. For effiency reasons the data won’t be copied.
- Raises
NotImplementedError – This is an abstract method
- Parameters
data (BaseStructure) – Series, DataFrame, or mapped values
- Returns
Results of the function
- Return type
pd.Series
Example: autom8qc.functions.interpolation.FillValidityGapsFunction
BaseRule
- class autom8qc.rules.base.BaseRule
Bases:
autom8qc.core.components.BaseComponent
Abstract base class that defines the interface for rules. Each rule must provide its information (NAME, DESCRIPTION) and must implement the abstract method apply. Rules can be used to define rules for the test that will be applied on the results. An example is that all data points are set to invalid if over 20% of the data points are invalid.
See also
autom8qc.core.components.BaseComponent
autom8qc.core.parameters.ParameterList
Warning
If you inherit from this class, make sure that you call the super constructor and implement the abstract method apply.
- Parameters
NAME (string) – Name of the function
DESCRIPTION (string) – Description of the function
parameters (ParameterList) – Supported parameters (default: None)
- autom8qc.rules.base.BaseRule.apply(self, data)
Applies the rule to the given data.
Warning
Make sure that you don’t override data points of the data. For effiency reasons the data won’t be copied.
- Raises
NotImplementedError – This is an abstract method
- Parameters
data (BaseStructure) – Series, DataFrame, or mapped values
- Returns
Results of the function
- Return type
pd.Series
BaseMeasure
- class autom8qc.measures.base.BaseMeasure
Bases:
autom8qc.core.components.BaseComponent
Abstract base class that defines the interface for measures. Each measure has to provide its information (NAME, DESCRIPTION) and has to implement the abstract method apply. If you use a group or a sequence with several tests, each test will return its probabilities or mapped values. To combine them to a total result, you have to use a measure. An example of a measure is the weighted mean of the probabilities.
See also
autom8qc.core.components.BaseComponent
autom8qc.core.parameters.ParameterList
Warning
If you inherit from this class, make sure that you call the super constructor and implement the abstract method apply.
- Parameters
NAME (str) – Name of the test
DESCRIPTION (str) – Description of the test
parameters (ParameterList) – Supported parameters (default: None)
- autom8qc.measures.base.BaseMeasure.apply(self, component)
Apply the measure to the given component and returns the results.
Warning
Make sure that you don’t override data points of the data. For effiency reasons the data won’t be copied.
- Raises
InvalidType – If component has the wrong type
- Parameters
component (TestGroup or TestSequence) – Test group or test sequence
- Returns
Results
- Return type
pd.Series