A convenience wrapper for calibrations that acts like a dictionary.

Calibrations act as dictionaries whose keys are the names of the metric, and whose values are the metric values. The metric values themselves are represented as a dictionary. These metric value dictionaries have keys that are tuples of cirq.GridQubits and values that are lists of the metric values for those qubits. If a metric acts globally and is attached to no specified number of qubits, the map will be from the empty tuple to the metrics values.

Calibrations act just like a python dictionary. For example you can get a list of all of the metric names using


and query a single value by looking up the name by index:


This class can be instantiated either from a MetricsSnapshot proto or from a dictionary of metric values.

timestamp The time that this calibration was run, in milliseconds since the epoch.



D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.


View source

Return a heatmap for metrics that target single qubits.

key The metric key to return a heatmap for.

A cirq.Heatmap for the metric.

ValueError if the heatmap is not for one/two qubits or the metric values are not single floats.


D.items() -> a set-like object providing a view on D's items


View source

Returns a single qubit from a metric key.

ValueError if the metric key is a tuple of strings.


View source

Returns a tuple of qubits from a metric key.

ValueError if the metric key is a tuple of strings.


D.keys() -> a set-like object providing a view on D's keys


View source

Turns a string into a calibration key.

Attempts to parse it as a GridQubit. If this fails, returns the string itself.


View source

Return a string for the calibration timestamp.

tz The timezone for the string. If None, the method uses the platform's local timezone.
timespec See datetime.isoformat for valid values.

The string in ISO 8601 format YYYY-MM-DDTHH:MM:SS.ffffff.


View source

Reconstruct the protobuf message represented by this class.


View source

Returns a single float from a metric value.

Metric values can be a list of strings, ints, or floats. However, the typical case is that they are a single float. This converts the metric value to a single float.

If the metric value has multiple values, only the first will be returned. If the value is empty or a string that cannot be converted, this function will raise a ValueError.


D.values() -> an object providing a view on D's values



Return self==value.


View source

Supports getting calibrations by index.

Calibration may be accessed by key:


This returns a map from tuples of cirq.GridQubits to a list of the values of the metric. If there are no targets, the only key will only be an empty tuple.


View source


View source