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
Returns

ReportableQty

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

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

Parameters
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
  • value (object) – The value, usually a float or numpy array.

  • errbar (object, 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_ebs (bool, optional) – Whether these error bars are “non-markovian”-type error bars (it can be useful to keep track of this for formatting).

size

Returns the size of this ReportableQty’s value.

Type

int

__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__add__(self, x)
__mul__(self, x)
__truediv__(self, x)
__getstate__(self)
__setstate__(self, d)
__copy__(self)
__deepcopy__(self, memo)
log(self)

Returns a ReportableQty that is the logarithm of this one.

Returns

ReportableQty

real(self)

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

Returns

ReportableQty

imag(self)

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

Returns

ReportableQty

absdiff(self, 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_value (float or numpy.ndarray) – The constant value to use.

  • separate_re_im (bool, 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(self, 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_value (float or numpy.ndarray) – The constant value to use.

Returns

ReportableQty

mod(self, 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

x (int) – Value to modulus-divide by.

Returns

ReportableQty

hermitian_to_real(self)

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(self, *args)

Returns a ReportableQty whose underlying values are reshaped.

Returns

ReportableQty

property size(self)

Returns the size of this ReportableQty’s value.

Returns

int

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 - :class:`ReportableQty`s

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
  • value (object) – The value to convert.

  • non_markovian_ebs (bool, optional) – Whether the error bars are of the “non-markovian”-type.

Returns

ReportableQty

property has_errorbar(self)

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

Returns

bool

scale_inplace(self, factor)

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

Parameters

factor (float) – The scaling factor.

Returns

None

property value(self)

Returns the quantity’s value

Returns

object – Usually a float or numpy array.

property errorbar(self)

Returns the quantity’s error bar(s)

Returns

object – Usually a float or numpy array.

property value_and_errorbar(self)

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

Returns

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

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

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

Render this ReportableQty using the function f.

Parameters
  • f (function) – 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.

  • specs (dict, optional) – Additional parameters to pass to the formatter function f.

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

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

Returns

str