pygsti.report.modelfunction

Defines the ModelFunction class

Module Contents

Classes

ModelFunction

A "function of a model" for which one may want to compute error bars.

Functions

spamfn_factory(fn)

Creates a class that evaluates fn(preps,povms,...).

opfn_factory(fn)

Creates a class that evaluates fn(gate,basis,...).

opsfn_factory(fn)

Creates a class that evaluates fn(op1,op2,basis,...).

instrumentfn_factory(fn)

Creates a class that evaluates fn(instrument1,instrument2,basis,...).

vecfn_factory(fn)

Creates a class that evaluates fn(vec,basis,...).

vecsfn_factory(fn)

Creates a class that evaluates fn(vec1, vec2, basis,...).

povmfn_factory(fn)

Creates a class that evaluates fn(model,...) where fn only depends on the POVM effect elements model.

modelfn_factory(fn)

Creates a class that evaluates fn(model,...).

class pygsti.report.modelfunction.ModelFunction(model, dependencies)

Bases: object

A “function of a model” for which one may want to compute error bars.

Specifically, one may want to compute confidence-interval error bars based on a confidence region of the function’s model argument.

The “function” may have other parameters, and the reason for defining it as a class is so that it can hold

  1. relevant “meta” arguments in addition to the central Model, and

  2. information to speed up function evaluations at nearby Model “points”, for computing finite-difference derivatives.

Parameters

modelModel

A sample model giving the constructor a template for what type/parameterization of model to expect in calls to evaluate().

dependencieslist

A list of (type,*label*) tuples, or the special strings “all” and “spam”, indicating which Model parameters the function depends upon. Here type can be “gate”, “prep”, “povm”, or “instrument”, and label can be any of the corresponding labels found in the models being evaluated. The reason for specifying this at all is to speed up computation of the finite difference derivative needed to find the error bars.

Creates a new ModelFunction object.

Parameters

modelModel

A sample model giving the constructor a template for what type/parameterization of model to expect in calls to evaluate().

dependencieslist

A list of (type,*label*) tuples, or the special strings “all” and “spam”, indicating which Model parameters the function depends upon. Here type can be “gate”, “prep”, “povm”, or “instrument”, and label can be any of the corresponding labels found in the models being evaluated. The reason for specifying this at all is to speed up computation of the finite difference derivative needed to find the error bars.

evaluate(model)

Evaluate this gate-set-function at model.

Parameters
modelModel

The “point” at which to evaluate this function.

Returns

object

evaluate_nearby(nearby_model)

Evaluate this model-function at nearby_model.

nearby_model can be assumed to be very close to the model provided to the last call to evaluate().

Parameters
nearby_modelModel

A nearby “point” to evaluate this function at.

Returns

object

list_dependencies()

Return the dependencies of this model-function.

Returns
list

A list of (type,*label*) tuples, or the special strings “all” and “spam”, indicating which Model parameters the function depends upon. Here type can be “gate”, “prep”, “povm”, or “instrument”, and label can be any of the corresponding labels found in the models being evaluated.

pygsti.report.modelfunction.spamfn_factory(fn)

Creates a class that evaluates fn(preps,povms,…).

Here preps and povms are lists of the preparation SPAM vectors and POVMs of a Model, respectively, and are additional arguments (see below).

Parameters

fnfunction

A function of at least the two parameters as discussed above.

Returns

clsclass

A ModelFunction-derived class initialized by cls(model, …) where model is a Model and are optional additional arguments that are passed to fn.

pygsti.report.modelfunction.opfn_factory(fn)

Creates a class that evaluates fn(gate,basis,…).

Hhere gate is a single operation matrix, basis describes what basis it’s in, and are additional arguments (see below).

Parameters

fnfunction

A function of at least the two parameters as discussed above.

Returns

clsclass

A ModelFunction-derived class initialized by cls(model, gl, …) where model is a Model, gl is a gate label, and are optional additional arguments passed to fn.

pygsti.report.modelfunction.opsfn_factory(fn)

Creates a class that evaluates fn(op1,op2,basis,…).

Here op1 and op2 are a single operation matrices, basis describes what basis they’re in, and are additional arguments (see below).

Parameters

fnfunction

A function of at least the two parameters as discussed above.

Returns

clsclass

A ModelFunction-derived class initialized by cls(model1, model2, gl, …) where model1 and model2 are Models (only model1 and op1 are varied when computing a confidence region), gl is a operation label, and are optional additional arguments passed to fn.

pygsti.report.modelfunction.instrumentfn_factory(fn)

Creates a class that evaluates fn(instrument1,instrument2,basis,…).

Here instrument1 and instrument2 are a Instrument`s, `basis describes what basis they’re in, and are additional arguments (see below).

Parameters

fnfunction

A function of at least the two parameters as discussed above.

Returns

clsclass

A ModelFunction-derived class initialized by cls(model1, model2, gl, …) where model1 and model2 are Models (only model1 and op1 are varied when computing a confidence region), gl is a operation label, and are optional additional arguments passed to fn.

pygsti.report.modelfunction.vecfn_factory(fn)

Creates a class that evaluates fn(vec,basis,…).

Here vec is a single SPAM vector, basis describes what basis it’s in, and are additional arguments (see below).

Parameters

fnfunction

A function of at least the two parameters as discussed above.

Returns

clsclass

A ModelFunction-derived class initialized by cls(model, lbl, typ, …) where model is a Model, lbl is SPAM vector label, typ is either “prep” or “effect” (the type of the SPAM vector), and are optional additional arguments passed to fn.

pygsti.report.modelfunction.vecsfn_factory(fn)

Creates a class that evaluates fn(vec1, vec2, basis,…).

Hhere vec1 and vec2 are SPAM vectors, basis describes what basis they’re in, and are additional arguments (see below).

Parameters

fnfunction

A function of at least the two parameters as discussed above.

Returns

clsclass

A ModelFunction-derived class initialized by cls(model1, model2, lbl, typ, …) where model1 and model2 are Models (only model1 and vec1 are varied when computing a confidence region), lbl is a SPAM vector label, typ is either “prep” or “effect” (the type of the SPAM vector), and are optional additional arguments passed to fn.

pygsti.report.modelfunction.povmfn_factory(fn)

Creates a class that evaluates fn(model,…) where fn only depends on the POVM effect elements model.

Here model is the entire Model and are additional arguments (see below).

Parameters

fnfunction

A function of at least the one parameter as discussed above.

Returns

clsclass

A ModelFunction-derived class initialized by cls(model, …) where model is a Model and are optional additional arguments that are passed to fn.

pygsti.report.modelfunction.modelfn_factory(fn)

Creates a class that evaluates fn(model,…).

Here model is a Model object and are additional arguments (see below).

Parameters

fnfunction

A function of at least the single model parameter discussed above.

Returns

clsclass

A ModelFunction-derived class initialized by cls(model, …) where model is a Model, and are optional additional arguments passed to fn.