pygsti.modelmembers.states.densestate
¶
The DenseState and DensePureState classes and supporting functionality.
Module Contents¶
Classes¶
Adds a numpyarraymimicing interface onto a state object. 

TODO: update docstring 

TODO: docstring  a state that is interfaced as a dense ket 
 class pygsti.modelmembers.states.densestate.DenseStateInterface¶
Bases:
object
Adds a numpyarraymimicing interface onto a state object.
 property _ptr(self)¶
 _ptr_has_changed(self)¶
Derived classes should override this function to handle rep updates when the _ptr property is changed.
 to_array(self)¶
Return the array used to identify this state within its range of possible values.
For instance, if the state is a pure state, this returns a complex purestate vector regardless of the evolution type. The related :method:`to_dense` method, in contrast, returns the dense representation of the state, which varies by evolution type.
 Returns
numpy.ndarray
 property columnvec(self)¶
Direct access the the underlying data as column vector, i.e, a (dim,1)shaped array.
 __copy__(self)¶
 __deepcopy__(self, memo)¶
 __getitem__(self, key)¶
 __getslice__(self, i, j)¶
 __setitem__(self, key, val)¶
 __getattr__(self, attr)¶
 __pos__(self)¶
 __neg__(self)¶
 __abs__(self)¶
 __add__(self, x)¶
 __radd__(self, x)¶
 __sub__(self, x)¶
 __rsub__(self, x)¶
 __mul__(self, x)¶
 __rmul__(self, x)¶
 __truediv__(self, x)¶
 __rtruediv__(self, x)¶
 __floordiv__(self, x)¶
 __rfloordiv__(self, x)¶
 __pow__(self, x)¶
 __eq__(self, x)¶
Return self==value.
 __len__(self)¶
 __int__(self)¶
 __long__(self)¶
 __float__(self)¶
 __complex__(self)¶
 __str__(self)¶
Return str(self).
 class pygsti.modelmembers.states.densestate.DenseState(vec, evotype, state_space)¶
Bases:
DenseStateInterface
,pygsti.modelmembers.states.state.State
TODO: update docstring A state preparation vector that is interfaced/behaves as a dense superket (a numpy array).
This class is the common base class for parameterizations of a state vector that have a dense representation and can be accessed like a numpy array.
 Parameters
vec (numpy.ndarray) – The SPAM vector as a dense numpy array.
evotype ({"statevec", "densitymx"}) – The evolution type.
 _base_1d¶
Direct access to the underlying 1D array.
 Type
numpy.ndarray
 base¶
Direct access the the underlying data as column vector, i.e, a (dim,1)shaped array.
 Type
numpy.ndarray
 property _ptr(self)¶
 _ptr_has_changed(self)¶
Derived classes should override this function to handle rep updates when the _ptr property is changed.
 to_dense(self, on_space='minimal', scratch=None)¶
Return the dense array used to represent this state within its evolution type.
The memory in scratch maybe used when it is notNone.
 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 superbra/superket 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
 to_memoized_dict(self, mmg_memo)¶
Create a serializable dict with references to other objects in the memo.
 Parameters
mmg_memo (dict) – Memo dict from a ModelMemberGraph, i.e. keys are object ids and values are ModelMemberGraphNodes (which contain the serialize_id). This is NOT the same as other memos in ModelMember (e.g. copy, allocate_gpindices, etc.).
 Returns
mm_dict (dict) – A dict representation of this ModelMember ready for serialization This must have at least the following fields:
module, class, submembers, params, state_space, evotype
Additional fields may be added by derived classes.
 classmethod _from_memoized_dict(cls, mm_dict, serial_memo)¶
For subclasses to implement. Submemberexistence checks are performed, and the gpindices of the return value is set, by the nonunderscored :method:`from_memoized_dict` implemented in this class.
 _is_similar(self, other, rtol, atol)¶
Returns True if other model member (which it guaranteed to be the same type as self) has the same local structure, i.e., not considering parameter values or submembers
 class pygsti.modelmembers.states.densestate.DensePureState(purevec, basis, evotype, state_space)¶
Bases:
DenseStateInterface
,pygsti.modelmembers.states.state.State
TODO: docstring  a state that is interfaced as a dense ket
 property _ptr(self)¶
Gives a handle/pointer to the base numpy array that this object can be accessed as
 _ptr_has_changed(self)¶
Derived classes should override this function to handle rep updates when the _ptr property is changed.
 to_dense(self, on_space='minimal', scratch=None)¶
Return the dense array used to represent this state within its evolution type.
The memory in scratch maybe used when it is notNone.
 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 superbra/superket 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
 to_memoized_dict(self, mmg_memo)¶
Create a serializable dict with references to other objects in the memo.
 Parameters
mmg_memo (dict) – Memo dict from a ModelMemberGraph, i.e. keys are object ids and values are ModelMemberGraphNodes (which contain the serialize_id). This is NOT the same as other memos in ModelMember (e.g. copy, allocate_gpindices, etc.).
 Returns
mm_dict (dict) – A dict representation of this ModelMember ready for serialization This must have at least the following fields:
module, class, submembers, params, state_space, evotype
Additional fields may be added by derived classes.
 classmethod _from_memoized_dict(cls, mm_dict, serial_memo)¶
For subclasses to implement. Submemberexistence checks are performed, and the gpindices of the return value is set, by the nonunderscored :method:`from_memoized_dict` implemented in this class.
 _is_similar(self, other, rtol, atol)¶
Returns True if other model member (which it guaranteed to be the same type as self) has the same local structure, i.e., not considering parameter values or submembers