QualityReport#

class pypillometry.QualityReport(name, class_name, sections, thresholds)[source]#

Bases: object

Data-quality report for an eyedata object.

Created by quality_report(). The report can be

  • shown as text (print(report); labels are colored if the terminal supports it),

  • shown as HTML in a Jupyter notebook (just display the object),

  • converted to a dict (to_dict()), e.g., to collect the reports of several datasets in a pandas.DataFrame.

Individual measures can be accessed like a dict: report["pupil"]["left"]["missing_pct"] is a QualityMetric.

Attributes:
namestr

name of the dataset

class_namestr

class of the dataset (e.g., “EyeData”)

sectionsdict

{section: {group: {metric_name: QualityMetric}}}, where the group is usually the eye (e.g., “left”)

thresholdsdict

thresholds used for the labels

overallstr or None

Worst label of all measures (None if no measure has a label).

Methods

issues

Return the measures with a label of min_label or worse.

keys

Return the available sections.

labels

Return the worst label for each section and group.

metrics

Iterate over all measures as (section, group, QualityMetric).

to_dict

Return the report as a dictionary.

to_text

Return the report as a (multi-line) text.

Details

issues(min_label='poor')[source]#

Return the measures with a label of min_label or worse.

Parameters:

min_label (str) – one of “ok”, “poor” or “bad” (default “poor”)

Return type:

list

Returns:

(section, group, QualityMetric), worst first

keys()[source]#

Return the available sections.

labels()[source]#

Return the worst label for each section and group.

Return type:

dict

Returns:

{section: {group: label}} (sections without labels are left out)

metrics()[source]#

Iterate over all measures as (section, group, QualityMetric).

to_dict(flat=False)[source]#

Return the report as a dictionary.

Parameters:

flat (bool) – If False (default), return a nested dict {"name", "class", "overall", <section>: {<group>: {<metric>: {...}}}}, where each metric is a dict with value, unit, label and description. If True, return a flat dict with keys like "pupil.left.missing_pct" (the value) and "pupil.left.missing_pct.label" (the label); convenient for creating a pandas.DataFrame from the reports of several datasets.

Return type:

dict

to_text(color=None, descriptions=False, width=80)[source]#

Return the report as a (multi-line) text.

Parameters:
  • color (Optional[bool]) – color the labels with ANSI escape codes; if None (default), colors are used if the output supports it (terminal or Jupyter; disable by setting the environment variable NO_COLOR)

  • descriptions (bool) – if True, explain each measure (and its thresholds) below its row

  • width (int) – maximum line width for the descriptions (default 80)

Return type:

str

property overall: Optional[str]#

Worst label of all measures (None if no measure has a label).