pygsti.report.reportableqty

The ReportableQty class

Module Contents

Classes

ReportableQty

A computed quantity and possibly its error bars, primarily for use in reports.

Functions

minimum(qty1, qty2)

Returns a ReportableQty that is the minimum of qty1 and qty2.

maximum(qty1, qty2)

Returns a ReportableQty that is the maximum of qty1 and qty2.

pygsti.report.reportableqty.minimum(qty1, qty2)

Returns a ReportableQty that is the minimum of qty1 and qty2.

Parameters

qty1ReportableQty

First quantity.

qty2ReportableQty

Second quantity.

Returns

ReportableQty

pygsti.report.reportableqty.maximum(qty1, qty2)

Returns a ReportableQty that is the maximum of qty1 and qty2.

Parameters

qty1ReportableQty

First quantity.

qty2ReportableQty

Second quantity.

Returns

ReportableQty

class pygsti.report.reportableqty.ReportableQty(value, errbar=None, non_markovian_ebs=False)

Bases: object

A computed quantity and possibly its error bars, primarily for use in reports.

Parameters

valueobject

The value, usually a float or numpy array.

errbarobject, optional

The (symmetric) error bar on value. If value is an array, errbar has the same shape. None is used to signify “no error bars”.

non_markovian_ebsbool, optional

Whether these error bars are “non-markovian”-type error bars (it can be useful to keep track of this for formatting).

Attributes

sizeint

Returns the size of this ReportableQty’s value.

Initialize a new ReportableQty object, which is essentially a container for a value and error bars.

Parameters

valueanything

The value to store

errbaranything

The error bar(s) to store

non_markovian_ebsbool

boolean indicating if non markovian error bars should be used

property size

Returns the size of this ReportableQty’s value.

Returns

int

property has_errorbar

Return whether this quantity is storing an error bar (bool).

Returns

bool

property value

Returns the quantity’s value

Returns
object

Usually a float or numpy array.

property errorbar

Returns the quantity’s error bar(s)

Returns
object

Usually a float or numpy array.

property value_and_errorbar

Returns the quantity’s value and error bar(s)

Returns
valueobject

This object’s value (usually a float or numpy array).

error_barobject

This object’s value (usually a float or numpy array).

log()

Returns a ReportableQty that is the logarithm of this one.

Returns

ReportableQty

real()

Returns a ReportableQty that is the real part of this one.

Returns

ReportableQty

imag()

Returns a ReportableQty that is the imaginary part of this one.

Returns

ReportableQty

absdiff(constant_value, separate_re_im=False)

Create a ReportableQty that is the difference between constant_value and this one.

The returned quantity’s value is given by (element-wise in the vector case):

abs(self - constant_value).

Parameters
constant_valuefloat or numpy.ndarray

The constant value to use.

separate_re_imbool, optional

When True, two separate real- and imaginary-part ReportableQty objects are returned (applicable to complex-valued quantities).

Returns
ReportableQty or tuple

The output ReportableQty`(s). If `separate_re_im=True then a 2-tuple of (real-part, imaginary-part) quantities is returned. Otherwise a single quantity is returned.

infidelity_diff(constant_value)

Creates a ReportableQty that is the difference between constant_value and this one.

The returned quantity’s value is given by (element-wise in the vector case):

1.0 - Re(conjugate(constant_value) * self )

Parameters
constant_valuefloat or numpy.ndarray

The constant value to use.

Returns

ReportableQty

mod(x)

Creates a ReportableQty that holds this_qty mod x.

That is, the value and error bar (if present) are modulus-divided by x.

Parameters
xint

Value to modulus-divide by.

Returns

ReportableQty

hermitian_to_real()

Creates a ReportableQty that holds a real “version” of a Hermitian matrix.

Specifically, the returned quantity’s value is the real matrix whose upper/lower triangle contains the real/imaginary parts of the corresponding off-diagonal matrix elements of the Hermitian matrix stored in this ReportableQty.

This is used for display purposes. If this object doesn’t contain a Hermitian matrix, ValueError is raised.

Returns

ReportableQty

reshape(*args)

Returns a ReportableQty whose underlying values are reshaped.

Returns

ReportableQty

static from_val(value, non_markovian_ebs=False)

Convert Table values into ReportableQtys or leave them be if they are well-formed types.

Well-formed types include: * strings * figures * ReportableQty

A tuple will be converted to a ReportableQty holding the first field as a value and second field as an error bar. Anything else will be converted to a ReportableQty with no error bars.

Parameters
valueobject

The value to convert.

non_markovian_ebsbool, optional

Whether the error bars are of the “non-markovian”-type.

Returns

ReportableQty

scale_inplace(factor)

Scale the value and error bar (if present) by factor.

Parameters
factorfloat

The scaling factor.

Returns

None

render_with(f, specs=None, ebstring='%s +/- %s', nmebstring=None)

Render this ReportableQty using the function f.

Parameters
ffunction

The formatter function which separately converts the stored value and error bar (if present) to string quantities that are then formatted using ebstring, nmebstring or just “%s” (if there’s no error bar). This function must have the signature f(val, specs) where val is either the value or error bar and specs is a dictionary given by the next argument.

specsdict, optional

Additional parameters to pass to the formatter function f.

ebstringstr, optional

format string that describes how to display the value and error bar after they are rendered as string (ebstring should have two %s in it).

nmebstringstr, optional

format string, similar to ebstring, for displaying non-Markovian error bars (if None then ebstring is used).

Returns

str