atef.check.Comparison

class atef.check.Comparison(name: str | None = None, description: str | None = None, invert: bool = False, reduce_period: int | float | None = None, reduce_method: ReduceMethod = ReduceMethod.average, string: bool | None = None, severity_on_failure: Severity = Severity.error, if_disconnected: Severity = Severity.error)[source]

Base class for all atef value comparisons.

Subclasses of Comparison will be serialized as a tagged union. This means that the subclass name will be used as an identifier for the generated serialized dictionary (and JSON object).

Attributes:
description
name
reduce_period
string

Methods

__call__(value)

Run the comparison against value.

compare(value[, identifier])

Compare the provided value using the comparator's settings.

describe()

Human-readable description of the comparison operation itself.

get_data_for_signal(signal)

Get data for the given signal, according to the string and data reduction settings.

get_data_for_signal_async(signal, *[, executor])

Get data for the given signal, according to the string and data reduction settings.

prepare([cache])

Implement in subclass to grab and cache dynamic values.

Methods

__init__(name: str | None = None, description: str | None = None, invert: bool = False, reduce_period: int | float | None = None, reduce_method: ReduceMethod = ReduceMethod.average, string: bool | None = None, severity_on_failure: Severity = Severity.error, if_disconnected: Severity = Severity.error) None
compare(value: Any, identifier: str | None = None) Result[source]

Compare the provided value using the comparator’s settings.

Parameters:
value

The value to compare.

identifierstr, optional

An identifier that goes along with the provided value. Used for severity result descriptions.

describe() str[source]

Human-readable description of the comparison operation itself.

To be implemented by subclass.

get_data_for_signal(signal: Signal) Any[source]

Get data for the given signal, according to the string and data reduction settings.

Parameters:
signalophyd.Signal

The signal.

Returns:
Any

The acquired data.

Raises:
TimeoutError

If the get operation times out.

async get_data_for_signal_async(signal: Signal, *, executor: Executor | None = None) Any[source]

Get data for the given signal, according to the string and data reduction settings.

Parameters:
signalophyd.Signal

The signal.

executorconcurrent.futures.Executor, optional

The executor to run the synchronous call in. Defaults to the loop-defined default executor.

Returns:
Any

The acquired data.

Raises:
TimeoutError

If the get operation times out.

async prepare(cache: DataCache | None = None) None[source]

Implement in subclass to grab and cache dynamic values. This is expected to set self.is_prepared to True if successful.

Attributes

description: str | None = None

Description tied to this comparison.

if_disconnected: Severity = 2

If disconnected and unable to perform the comparison, set this result severity.

invert: bool = False

Invert the comparison’s result. Normally, a valid comparison - that is, one that evaluates to True - is considered successful. When invert is set, such a comparison would be considered a failure.

name: str | None = None
reduce_method: ReduceMethod = 'average'

Reduce collected samples by this reduce method.

reduce_period: int | float | None = None

Period over which the comparison will occur, where multiple samples may be acquired prior to a result being available.

severity_on_failure: Severity = 2

If the comparison fails, use this result severity.

string: bool | None = None

If applicable, request and compare string values rather than the default specified.