hooqu.constraints

Submodules

hooqu.constraints.analysis_based_constraint module

class hooqu.constraints.analysis_based_constraint.AnalysisBasedConstraint(analyzer, assertion, value_picker=None, hint=None)[source]

Bases: hooqu.constraints.constraint.Constraint, typing.Generic

Common functionality for all analysis based constraints that provides unified way to access AnalyzerContext and metrics stored in it.

Runs the analysis and get the value of the metric returned by the analysis, picks the numeric value that will be used in the assertion function with metric picker runs the assertion.

__init__(analyzer, assertion, value_picker=None, hint=None)[source]
Parameters
  • analyzer (Analyzer[~S, Metric[~M]]) – Analyzer to be run on the data frame

  • assertion (Assertion callable) –

  • value_picker ((NOT IMPLEMENTED)) – Optional function to pick the interested part of the metric value that the assertion will be running on. Absence of such function means the metric value would be used in the assertion as it is.

  • hint (Optional[str]) – A hint to provide additional context why a constraint could have failed

exception hooqu.constraints.analysis_based_constraint.ConstraintAssertionException[source]

Bases: Exception

hooqu.constraints.constraint module

class hooqu.constraints.constraint.Constraint[source]

Bases: abc.ABC

class hooqu.constraints.constraint.ConstraintDecorator(inner)[source]

Bases: hooqu.constraints.constraint.Constraint

class hooqu.constraints.constraint.ConstraintResult(constraint: hooqu.constraints.constraint.Constraint, status: hooqu.constraints.constraint.ConstraintStatus, message: Union[str, NoneType] = None, metric: Union[hooqu.metrics.Metric, NoneType] = None)[source]

Bases: object

class hooqu.constraints.constraint.ConstraintStatus(value)[source]

Bases: enum.Enum

An enumeration.

class hooqu.constraints.constraint.NamedConstraint(constraint, name)[source]

Bases: hooqu.constraints.constraint.ConstraintDecorator

hooqu.constraints.constraints module

hooqu.constraints.constraints.compliance_constraint(name, column, assertion, where=None, hint=None)[source]

Runs given the expression on the given column(s) and executes the assertion

name:

A name that summarizes the check being made. This name is being used to name the metrics for the analysis being done.

column:

The column expression to be evaluated.

assertion:

Callable that receives a float input parameter and returns a boolean

where:

Additional filter to apply before the analyzer is run.

Hint

A hint to provide additional context why a constraint could have failed

Return type

Constraint

hooqu.constraints.constraints.quantile_constraint(column, quantile, assertion, where=None, hint=None)[source]

Runs quantile analysis on the given column and executes the assertion

column:

Column to run the assertion on

quantile:

Which quantile to assert on

assertion

Callable that receives a float input parameter (the computed quantile) and returns a boolean

Hint

A hint to provide additional context why a constraint could have failed

Return type

Constraint

hooqu.constraints.constraints.uniqueness_constraint(columns, assertion, where=None, hint=None)[source]

Runs Uniqueness analysis on the given columns and executes the assertion columns.

columns:

Columns to run the assertion on.

assertion:

Callable that receives a float input parameter and returns a boolean

where:

Additional filter to apply before the analyzer is run.

Hint

A hint to provide additional context why a constraint could have failed

Return type

Constraint

Module contents

class hooqu.constraints.AnalysisBasedConstraint(analyzer, assertion, value_picker=None, hint=None)[source]

Bases: hooqu.constraints.constraint.Constraint, typing.Generic

Common functionality for all analysis based constraints that provides unified way to access AnalyzerContext and metrics stored in it.

Runs the analysis and get the value of the metric returned by the analysis, picks the numeric value that will be used in the assertion function with metric picker runs the assertion.

__init__(analyzer, assertion, value_picker=None, hint=None)[source]
Parameters
  • analyzer (Analyzer[~S, Metric[~M]]) – Analyzer to be run on the data frame

  • assertion (Assertion callable) –

  • value_picker ((NOT IMPLEMENTED)) – Optional function to pick the interested part of the metric value that the assertion will be running on. Absence of such function means the metric value would be used in the assertion as it is.

  • hint (Optional[str]) – A hint to provide additional context why a constraint could have failed

class hooqu.constraints.Constraint[source]

Bases: abc.ABC

class hooqu.constraints.ConstraintDecorator(inner)[source]

Bases: hooqu.constraints.constraint.Constraint

class hooqu.constraints.ConstraintResult(constraint: hooqu.constraints.constraint.Constraint, status: hooqu.constraints.constraint.ConstraintStatus, message: Union[str, NoneType] = None, metric: Union[hooqu.metrics.Metric, NoneType] = None)[source]

Bases: object

class hooqu.constraints.ConstraintStatus(value)[source]

Bases: enum.Enum

An enumeration.

hooqu.constraints.compliance_constraint(name, column, assertion, where=None, hint=None)[source]

Runs given the expression on the given column(s) and executes the assertion

name:

A name that summarizes the check being made. This name is being used to name the metrics for the analysis being done.

column:

The column expression to be evaluated.

assertion:

Callable that receives a float input parameter and returns a boolean

where:

Additional filter to apply before the analyzer is run.

Hint

A hint to provide additional context why a constraint could have failed

Return type

Constraint

hooqu.constraints.quantile_constraint(column, quantile, assertion, where=None, hint=None)[source]

Runs quantile analysis on the given column and executes the assertion

column:

Column to run the assertion on

quantile:

Which quantile to assert on

assertion

Callable that receives a float input parameter (the computed quantile) and returns a boolean

Hint

A hint to provide additional context why a constraint could have failed

Return type

Constraint

hooqu.constraints.uniqueness_constraint(columns, assertion, where=None, hint=None)[source]

Runs Uniqueness analysis on the given columns and executes the assertion columns.

columns:

Columns to run the assertion on.

assertion:

Callable that receives a float input parameter and returns a boolean

where:

Additional filter to apply before the analyzer is run.

Hint

A hint to provide additional context why a constraint could have failed

Return type

Constraint