pygsti.modelmembers.povms.composedeffect

The ComposedPOVMEffect class and supporting functionality.

Module Contents

Classes

ComposedPOVMEffect

TODO: update docstring

class pygsti.modelmembers.povms.composedeffect.ComposedPOVMEffect(static_effect, errormap)

Bases: pygsti.modelmembers.povms.effect.POVMEffect

TODO: update docstring A Lindblad-parameterized POVMEffect (that is also expandable into terms).

Parameters
  • pure_vec (numpy array or POVMEffect) –

    An array or POVMEffect in the full density-matrix space (this vector will have dimension 4 in the case of a single qubit) which represents a pure-state preparation or projection. This is used as the “base” preparation or projection that is followed or preceded by, respectively, the parameterized Lindblad-form error generator. (This argument is not copied if it is a POVMEffect. A numpy array

    is converted to a new static POVM effect.)

  • errormap (MapOperator) – The error generator action and parameterization, encapsulated in a gate object. Usually a LindbladOp or ComposedOp object. (This argument is not copied, to allow ComposedPOVMEffects to share error generator parameters with other gates and spam vectors.)

classmethod _from_memoized_dict(cls, mm_dict, serial_memo)

For subclasses to implement. Submember-existence checks are performed, and the gpindices of the return value is set, by the non-underscored :method:`from_memoized_dict` implemented in this class.

property size(self)

Return the number of independent elements in this gate (when viewed as a dense array)

Returns

int

submembers(self)

Get the ModelMember-derived objects contained in this one.

Returns

list

set_gpindices(self, gpindices, parent, memo=None)

Set the parent and indices into the parent’s parameter vector that are used by this ModelMember object.

Parameters
  • gpindices (slice or integer ndarray) – The indices of this objects parameters in its parent’s array.

  • parent (Model or ModelMember) – The parent whose parameter array gpindices references.

  • memo (dict, optional) – A memo dict used to avoid circular references.

Returns

None

to_dense(self, on_space='minimal', scratch=None)

Return this POVM effect vector as a (dense) numpy array.

The memory in scratch maybe used when it is not-None.

Parameters
  • on_space ({'minimal', 'Hilbert', 'HilbertSchmidt'}) – The space that the returned dense operation acts upon. For unitary matrices and bra/ket vectors, use ‘Hilbert’. For superoperator matrices and super-bra/super-ket vectors use ‘HilbertSchmidt’. ‘minimal’ means that ‘Hilbert’ is used if possible given this operator’s evolution type, and otherwise ‘HilbertSchmidt’ is used.

  • scratch (numpy.ndarray, optional) – scratch space available for use.

Returns

numpy.ndarray

taylor_order_terms(self, order, max_polynomial_vars=100, return_coeff_polys=False)

Get the order-th order Taylor-expansion terms of this POVM effect vector.

This function either constructs or returns a cached list of the terms at the given order. Each term is “rank-1”, meaning that it is a state preparation followed by or POVM effect preceded by actions on a density matrix rho of the form:

rho -> A rho B

The coefficients of these terms are typically polynomials of the POVMEffect’s parameters, where the polynomial’s variable indices index the global parameters of the POVMEffect’s parent (usually a Model) , not the POVMEffect’s local parameter array (i.e. that returned from to_vector).

Parameters
  • order (int) – The order of terms to get.

  • max_polynomial_vars (int, optional) – maximum number of variables the created polynomials can have.

  • return_coeff_polys (bool) – Whether a parallel list of locally-indexed (using variable indices corresponding to this object’s parameters rather than its parent’s) polynomial coefficients should be returned as well.

Returns

  • terms (list) – A list of RankOneTerm objects.

  • coefficients (list) – Only present when return_coeff_polys == True. A list of compact polynomial objects, meaning that each element is a (vtape,ctape) 2-tuple formed by concatenating together the output of :method:`Polynomial.compact`.

taylor_order_terms_above_mag(self, order, max_polynomial_vars, min_term_mag)

Get the order-th order Taylor-expansion terms of this POVM effect that have magnitude above min_term_mag.

This function constructs the terms at the given order which have a magnitude (given by the absolute value of their coefficient) that is greater than or equal to min_term_mag. It calls :method:`taylor_order_terms` internally, so that all the terms at order order are typically cached for future calls.

Parameters
  • order (int) – The order of terms to get.

  • max_polynomial_vars (int, optional) – maximum number of variables the created polynomials can have.

  • min_term_mag (float) – the minimum term magnitude.

Returns

list

property total_term_magnitude(self)

Get the total (sum) of the magnitudes of all this POVM effect vector’s terms.

The magnitude of a term is the absolute value of its coefficient, so this function returns the number you’d get from summing up the absolute-coefficients of all the Taylor terms (at all orders!) you get from expanding this POVM effect vector in a Taylor series.

Returns

float

property total_term_magnitude_deriv(self)

The derivative of the sum of all this POVM effect vector’s terms.

Get the derivative of the total (sum) of the magnitudes of all this POVM effect vector’s terms with respect to the operators (local) parameters.

Returns

numpy array – An array of length self.num_params

deriv_wrt_params(self, wrt_filter=None)

The element-wise derivative this POVM effect vector.

Construct a matrix whose columns are the derivatives of the POVM effect vector with respect to a single param. Thus, each column is of length dimension and there is one column per POVM effect vector parameter.

Parameters

wrt_filter (list or numpy.ndarray) – List of parameter indices to take derivative with respect to. (None means to use all the this operation’s parameters.)

Returns

numpy array – Array of derivatives, shape == (dimension, num_params)

hessian_wrt_params(self, wrt_filter1=None, wrt_filter2=None)

Construct the Hessian of this POVM effect vector with respect to its parameters.

This function returns a tensor whose first axis corresponds to the flattened operation matrix and whose 2nd and 3rd axes correspond to the parameters that are differentiated with respect to.

Parameters
  • wrt_filter1 (list or numpy.ndarray) – List of parameter indices to take 1st derivatives with respect to. (None means to use all the this operation’s parameters.)

  • wrt_filter2 (list or numpy.ndarray) – List of parameter indices to take 2nd derivatives with respect to. (None means to use all the this operation’s parameters.)

Returns

numpy array – Hessian with shape (dimension, num_params1, num_params2)

property parameter_labels(self)

An array of labels (usually strings) describing this model member’s parameters.

property num_params(self)

Get the number of independent parameters which specify this POVM effect vector.

Returns

int – the number of independent parameters.

to_vector(self)

Extract a vector of the underlying gate parameters from this gate.

Returns

numpy array – a 1D numpy array with length == num_params().

from_vector(self, v, close=False, dirty_value=True)

Initialize the POVM effect vector using a 1D array of parameters.

Parameters
  • v (numpy array) – The 1D vector of POVM effect vector parameters. Length must == num_params()

  • close (bool, optional) – Whether v is close to this POVM effect vector’s current set of parameters. Under some circumstances, when this is true this call can be completed more quickly.

  • dirty_value (bool, optional) – The value to set this object’s “dirty flag” to before exiting this call. This is passed as an argument so it can be updated recursively. Leave this set to True unless you know what you’re doing.

Returns

None

transform_inplace(self, s)

Update POVM effect (column) vector V as inv(s) * V or s^T * V

Note that this is equivalent to state preparation vectors getting mapped: rho -> inv(s) * rho and the transpose of effect vectors being mapped as E^T -> E^T * s.

Generally, the transform function updates the parameters of the POVM effect vector such that the resulting vector is altered as described above. If such an update cannot be done (because the gate parameters do not allow for it), ValueError is raised.

Parameters

s (GaugeGroupElement) – A gauge group element which specifies the “s” matrix (and it’s inverse) used in the above similarity transform.

Returns

None

depolarize(self, amount)

Depolarize this POVM effect vector by the given amount.

Generally, the depolarize function updates the parameters of the POVMEffect such that the resulting vector is depolarized. If such an update cannot be done (because the gate parameters do not allow for it), ValueError is raised.

Parameters

amount (float or tuple) – The amount to depolarize by. If a tuple, it must have length equal to one less than the dimension of the spam vector. All but the first element of the spam vector (often corresponding to the identity element) are multiplied by amount (if a float) or the corresponding amount[i] (if a tuple).

Returns

None