|
9 | 9 | # in compliance with the License. You may obtain a copy of the License at
|
10 | 10 | # http://www.apache.org/licenses/LICENSE-2.0 or in the LICENSE file in the root pyGSTi directory.
|
11 | 11 | #***************************************************************************************************
|
12 |
| -import _collections |
13 | 12 | import functools as _functools
|
14 | 13 | import itertools as _itertools
|
15 | 14 |
|
|
42 | 41 |
|
43 | 42 | def create_from_pure_vectors(pure_vectors, povm_type, basis='pp', evotype='default', state_space=None,
|
44 | 43 | on_construction_error='warn'):
|
45 |
| - """ TODO: docstring -- create a POVM from a list/dict of (key, pure-vector) pairs """ |
| 44 | + """ |
| 45 | + Creates a Positive Operator-Valued Measure (POVM) from a list or dictionary of (key, pure-vector) pairs. |
| 46 | +
|
| 47 | + Parameters |
| 48 | + ---------- |
| 49 | + pure_vectors : list or dict |
| 50 | + A list of (key, pure-vector) pairs or a dictionary where keys are labels and values are pure state vectors. |
| 51 | + |
| 52 | + povm_type : str or tuple |
| 53 | + The type of POVM to create. This can be a single string or a tuple of strings indicating the preferred types. |
| 54 | + Supported types include 'computational', 'static pure', 'full pure', 'static', 'full', 'full TP', and any valid |
| 55 | + Lindblad parameterization type. |
| 56 | +
|
| 57 | + basis : str, optional |
| 58 | + The basis in which the pure vectors are expressed. Default is 'pp'. |
| 59 | +
|
| 60 | + evotype : str, optional |
| 61 | + The evolution type. Default is 'default'. |
| 62 | +
|
| 63 | + state_space : StateSpace, optional |
| 64 | + The state space in which the POVM operates. Default is None. |
| 65 | +
|
| 66 | + on_construction_error : str, optional |
| 67 | + Specifies the behavior when an error occurs during POVM construction. Options are 'raise' to raise the error, |
| 68 | + 'warn' to print a warning message, or any other value to silently ignore the error. Default is 'warn'. |
| 69 | +
|
| 70 | + Returns |
| 71 | + ------- |
| 72 | + POVM |
| 73 | + The constructed POVM object. |
| 74 | + """ |
46 | 75 | povm_type_preferences = (povm_type,) if isinstance(povm_type, str) else povm_type
|
47 | 76 | if not isinstance(pure_vectors, dict): # then assume it's a list of (key, value) pairs
|
48 |
| - pure_vectors = _collections.OrderedDict(pure_vectors) |
| 77 | + pure_vectors = dict(pure_vectors) |
49 | 78 | if state_space is None:
|
50 | 79 | state_space = _statespace.default_space_for_udim(len(next(iter(pure_vectors.values()))))
|
51 | 80 |
|
@@ -94,10 +123,41 @@ def create_from_pure_vectors(pure_vectors, povm_type, basis='pp', evotype='defau
|
94 | 123 |
|
95 | 124 | def create_from_dmvecs(superket_vectors, povm_type, basis='pp', evotype='default', state_space=None,
|
96 | 125 | on_construction_error='warn'):
|
97 |
| - """ TODO: docstring -- create a POVM from a list/dict of (key, pure-vector) pairs """ |
| 126 | + """ |
| 127 | + Creates a Positive Operator-Valued Measure (POVM) from a list or dictionary of (key, superket) pairs. |
| 128 | +
|
| 129 | + Parameters |
| 130 | + ---------- |
| 131 | + superket_vectors : list or dict |
| 132 | + A list of (key, pure-vector) pairs or a dictionary where keys are labels and values are superket vectors. |
| 133 | + i.e. vectorized density matrices. |
| 134 | + |
| 135 | + povm_type : str or tuple |
| 136 | + The type of POVM to create. This can be a single string or a tuple of strings indicating the preferred types. |
| 137 | + Supported types include 'full', 'static', 'full TP', 'computational', 'static pure', 'full pure', and any valid |
| 138 | + Lindblad parameterization type. |
| 139 | +
|
| 140 | + basis : str or `Basis`, optional |
| 141 | + The basis in which the density matrix vectors are expressed. Default is 'pp'. |
| 142 | +
|
| 143 | + evotype : str, optional |
| 144 | + The evolution type. Default is 'default'. |
| 145 | +
|
| 146 | + state_space : StateSpace, optional |
| 147 | + The state space in which the POVM operates. Default is None. |
| 148 | +
|
| 149 | + on_construction_error : str, optional |
| 150 | + Specifies the behavior when an error occurs during POVM construction. Options are 'raise' to raise the error, |
| 151 | + 'warn' to print a warning message, or any other value to silently ignore the error. Default is 'warn'. |
| 152 | +
|
| 153 | + Returns |
| 154 | + ------- |
| 155 | + POVM |
| 156 | + The constructed POVM object. |
| 157 | + """ |
98 | 158 | povm_type_preferences = (povm_type,) if isinstance(povm_type, str) else povm_type
|
99 | 159 | if not isinstance(superket_vectors, dict): # then assume it's a list of (key, value) pairs
|
100 |
| - superket_vectors = _collections.OrderedDict(superket_vectors) |
| 160 | + superket_vectors = dict(superket_vectors) |
101 | 161 |
|
102 | 162 | for typ in povm_type_preferences:
|
103 | 163 | try:
|
@@ -140,12 +200,42 @@ def create_from_dmvecs(superket_vectors, povm_type, basis='pp', evotype='default
|
140 | 200 | print('Failed to construct povm with type "{}" with error: {}'.format(typ, str(err)))
|
141 | 201 | pass # move on to next type
|
142 | 202 |
|
143 |
| - raise ValueError("Could not create a POVM of type(s) %s from the given pure vectors!" % (str(povm_type))) |
| 203 | + raise ValueError("Could not create a POVM of type(s) %s from the given density matrix vectors!" % (str(povm_type))) |
144 | 204 |
|
145 | 205 |
|
146 | 206 | def create_effect_from_pure_vector(pure_vector, effect_type, basis='pp', evotype='default', state_space=None,
|
147 | 207 | on_construction_error='warn'):
|
148 |
| - """ TODO: docstring -- create a State from a state vector """ |
| 208 | + """ |
| 209 | + Creates a POVM effect from a pure state vector. |
| 210 | +
|
| 211 | + Parameters |
| 212 | + ---------- |
| 213 | + pure_vector : array-like |
| 214 | + The pure state vector from which to create the POVM effect. |
| 215 | + |
| 216 | + effect_type : str or tuple |
| 217 | + The type of effect to create. This can be a single string or a tuple of strings indicating the preferred types. |
| 218 | + Supported types include 'computational', 'static pure', 'full pure', 'static', 'full', 'static clifford', and |
| 219 | + any valid Lindblad parameterization type. |
| 220 | +
|
| 221 | + basis : str or `Basis` optional |
| 222 | + The basis in which the pure vector is expressed. Default is 'pp'. |
| 223 | +
|
| 224 | + evotype : str, optional |
| 225 | + The evolution type. Default is 'default'. |
| 226 | +
|
| 227 | + state_space : StateSpace, optional |
| 228 | + The state space in which the effect operates. Default is None. |
| 229 | +
|
| 230 | + on_construction_error : str, optional |
| 231 | + Specifies the behavior when an error occurs during effect construction. Options are 'raise' to raise the error, |
| 232 | + 'warn' to print a warning message, or any other value to silently ignore the error. Default is 'warn'. |
| 233 | +
|
| 234 | + Returns |
| 235 | + ------- |
| 236 | + POVMEffect |
| 237 | + The constructed POVM effect object. |
| 238 | + """ |
149 | 239 | effect_type_preferences = (effect_type,) if isinstance(effect_type, str) else effect_type
|
150 | 240 | if state_space is None:
|
151 | 241 | state_space = _statespace.default_space_for_udim(len(pure_vector))
|
@@ -196,6 +286,38 @@ def create_effect_from_pure_vector(pure_vector, effect_type, basis='pp', evotype
|
196 | 286 |
|
197 | 287 | def create_effect_from_dmvec(superket_vector, effect_type, basis='pp', evotype='default', state_space=None,
|
198 | 288 | on_construction_error='warn'):
|
| 289 | + """ |
| 290 | + Creates a POVM effect from a density matrix vector (superket). |
| 291 | +
|
| 292 | + Parameters |
| 293 | + ---------- |
| 294 | + superket_vector : array-like |
| 295 | + The density matrix vector (superket) from which to create the POVM effect. |
| 296 | + |
| 297 | + effect_type : str or tuple |
| 298 | + The type of effect to create. This can be a single string or a tuple of strings indicating the preferred types. |
| 299 | + Supported types include 'static', 'full', and any valid Lindblad parameterization type. For other types |
| 300 | + we first try to convert to a pure state vector and then utilize `create_effect_from_pure_vector` |
| 301 | +
|
| 302 | + basis : str or `Basis` optional |
| 303 | + The basis in which the superket vector is expressed. Default is 'pp'. |
| 304 | +
|
| 305 | + evotype : str, optional |
| 306 | + The evolution type. Default is 'default'. |
| 307 | +
|
| 308 | + state_space : StateSpace, optional |
| 309 | + The state space in which the effect operates. Default is None. |
| 310 | +
|
| 311 | + on_construction_error : str, optional |
| 312 | + Specifies the behavior when an error occurs during effect construction. Options are 'raise' to raise the error, |
| 313 | + 'warn' to print a warning message, or any other value to silently ignore the error. Default is 'warn'. |
| 314 | +
|
| 315 | + Returns |
| 316 | + ------- |
| 317 | + POVMEffect |
| 318 | + The constructed POVM effect object. |
| 319 | + """ |
| 320 | + |
199 | 321 | effect_type_preferences = (effect_type,) if isinstance(effect_type, str) else effect_type
|
200 | 322 | if state_space is None:
|
201 | 323 | state_space = _statespace.default_space_for_dim(len(superket_vector))
|
@@ -241,7 +363,8 @@ def create_effect_from_dmvec(superket_vector, effect_type, basis='pp', evotype='
|
241 | 363 |
|
242 | 364 |
|
243 | 365 | def povm_type_from_op_type(op_type):
|
244 |
| - """Decode an op type into an appropriate povm type. |
| 366 | + """ |
| 367 | + Decode an op type into an appropriate povm type. |
245 | 368 |
|
246 | 369 | Parameters:
|
247 | 370 | -----------
|
|
0 commit comments