Skip to content

Commit 3b39d80

Browse files
authored
Merge branch 'develop' into add_type_checking_to_gauge_groups
2 parents 076cd1a + ddbeb5d commit 3b39d80

File tree

83 files changed

+1627
-857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1627
-857
lines changed

.github/workflows/reuseable-main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ jobs:
8181
if: ${{ inputs.run-unit-tests == 'true' }}
8282
run: |
8383
python -Ic "import pygsti; print(pygsti.__version__); print(pygsti.__path__)"
84-
python -m pytest -n auto --dist loadscope --cov=pygsti test/unit
84+
python -m pytest -n auto --dist loadscope --cov=pygsti --durations=25 test/unit
8585
- name: Run test_packages
8686
if: ${{ inputs.run-extra-tests == 'true' }}
8787
run: |
8888
python -Ic "import pygsti; print(pygsti.__version__); print(pygsti.__path__)"
89-
python -m pytest -v -n auto --dist loadscope --ignore=test/test_packages/mpi --ignore=test/test_packages/notebooks test/test_packages
89+
python -m pytest -v -n auto --dist loadscope --ignore=test/test_packages/mpi --ignore=test/test_packages/notebooks --durations=25 test/test_packages
9090
- name: Run notebook regression
9191
if: ${{ inputs.run-notebook-tests == 'true' }}
9292
run: |
@@ -95,4 +95,4 @@ jobs:
9595
gcc -o ./jupyter_notebooks/Tutorials/algorithms/advanced/chp ./jupyter_notebooks/Tutorials/algorithms/advanced/chp.c
9696
9797
python -Ic "import pygsti; print(pygsti.__version__); print(pygsti.__path__)"
98-
python -m pytest -n auto --nbval-lax --dist loadscope --nbval-current-env jupyter_notebooks
98+
python -m pytest -n auto --nbval-lax --dist loadscope --nbval-current-env --durations=25 jupyter_notebooks

pygsti/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# http://www.apache.org/licenses/LICENSE-2.0 or in the LICENSE file in the root pyGSTi directory.
88
#***************************************************************************************************
99
""" A Python implementation of LinearOperator Set Tomography """
10+
from .pgtypes import (
11+
SpaceT
12+
)
1013

1114
from . import baseobjs
1215
from . import algorithms as alg
@@ -19,6 +22,7 @@
1922
from . import protocols
2023
from . import report as rpt
2124
from . import serialization
25+
from . import enums
2226

2327
# Import the most important/useful routines of each module/sub-package
2428
# into the package namespace
@@ -30,6 +34,7 @@
3034
from pygsti.tools.gatetools import * # *_qubit_gate fns
3135
from .drivers import *
3236
from .tools import *
37+
3338
# NUMPY BUG FIX (imported from tools)
3439
from pygsti.baseobjs._compatibility import _numpy14einsumfix
3540

pygsti/algorithms/gaugeopt.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ def _jacobian_fn(gauge_group_el):
517517
# d(op_term) = S_inv * (-dS * S_inv * G * S + G * dS) = S_inv * (-dS * G' + G * dS)
518518
# Note: (S_inv * G * S) is G' (transformed G)
519519
wt = item_weights.get(lbl, opWeight)
520-
left = -1 * _np.dot(dS, mdl_post.operations[lbl].to_dense(on_space='minimal')) # shape (n,d1,d2)
521-
right = _np.swapaxes(_np.dot(G.to_dense(on_space='minimal'), dS), 0, 1) # shape (d1,n,d2) -> (n,d1,d2)
520+
left = -1 * _np.dot(dS, mdl_post.operations[lbl].to_dense('minimal')) # shape (n,d1,d2)
521+
right = _np.swapaxes(_np.dot(G.to_dense('minimal'), dS), 0, 1) # shape (d1,n,d2) -> (n,d1,d2)
522522
result = _np.swapaxes(_np.dot(S_inv, left + right), 1, 2) # shape (d1, d2, n)
523523
result = result.reshape((d**2, n)) # must copy b/c non-contiguous
524524
my_jacMx[start:start + d**2] = wt * result
@@ -530,8 +530,8 @@ def _jacobian_fn(gauge_group_el):
530530
wt = item_weights.get(ilbl, opWeight)
531531
for lbl, G in Inst.items():
532532
# same calculation as for operation terms
533-
left = -1 * _np.dot(dS, mdl_post.instruments[ilbl][lbl].to_dense(on_space='minimal')) # (n,d1,d2)
534-
right = _np.swapaxes(_np.dot(G.to_dense(on_space='minimal'), dS), 0, 1) # (d1,n,d2) -> (n,d1,d2)
533+
left = -1 * _np.dot(dS, mdl_post.instruments[ilbl][lbl].to_dense('minimal')) # (n,d1,d2)
534+
right = _np.swapaxes(_np.dot(G.to_dense('minimal'), dS), 0, 1) # (d1,n,d2) -> (n,d1,d2)
535535
result = _np.swapaxes(_np.dot(S_inv, left + right), 1, 2) # shape (d1, d2, n)
536536
result = result.reshape((d**2, n)) # must copy b/c non-contiguous
537537
my_jacMx[start:start + d**2] = wt * result
@@ -544,7 +544,7 @@ def _jacobian_fn(gauge_group_el):
544544
# Note: (S_inv * rho) is transformed rho
545545
wt = item_weights.get(lbl, spamWeight)
546546
Sinv_dS = _np.dot(S_inv, dS) # shape (d1,n,d2)
547-
result = -1 * _np.dot(Sinv_dS, rho.to_dense(on_space='minimal')) # shape (d,n)
547+
result = -1 * _np.dot(Sinv_dS, rho.to_dense('minimal')) # shape (d,n)
548548
my_jacMx[start:start + d] = wt * result
549549
start += d
550550

@@ -554,7 +554,7 @@ def _jacobian_fn(gauge_group_el):
554554
for lbl, E in povm.items():
555555
# d(ET_term) = E.T * dS
556556
wt = item_weights.get(povmlbl + "_" + lbl, spamWeight)
557-
result = _np.dot(E.to_dense(on_space='minimal')[None, :], dS).T # shape (1,n,d2).T => (d2,n,1)
557+
result = _np.dot(E.to_dense('minimal')[None, :], dS).T # shape (1,n,d2).T => (d2,n,1)
558558
my_jacMx[start:start + d] = wt * result.squeeze(2) # (d2,n)
559559
start += d
560560

@@ -851,7 +851,7 @@ def _spam_penalty_jac_fill(spam_penalty_vec_grad_to_fill, mdl_pre, mdl_post,
851851

852852
#get sgn(denMx) == d(|denMx|_Tr)/d(denMx) in std basis
853853
# dmDim = denMx.shape[0]
854-
denMx = _tools.vec_to_stdmx(prepvec.to_dense(on_space='minimal')[:, None], op_basis)
854+
denMx = _tools.vec_to_stdmx(prepvec.to_dense('minimal')[:, None], op_basis)
855855
assert(_np.linalg.norm(denMx - denMx.T.conjugate()) < 1e-4), \
856856
"denMx should be Hermitian!"
857857

@@ -865,7 +865,7 @@ def _spam_penalty_jac_fill(spam_penalty_vec_grad_to_fill, mdl_pre, mdl_post,
865865
# get d(prepvec')/dp = d(S_inv * prepvec)/dp in op_basis [shape == (n,dim)]
866866
# = (-S_inv*dS*S_inv) * prepvec = -S_inv*dS * prepvec'
867867
Sinv_dS = _np.dot(S_inv, dS) # shape (d1,n,d2)
868-
dVdp = -1 * _np.dot(Sinv_dS, prepvec.to_dense(on_space='minimal')[:, None]).squeeze(2) # shape (d,n,1) => (d,n)
868+
dVdp = -1 * _np.dot(Sinv_dS, prepvec.to_dense('minimal')[:, None]).squeeze(2) # shape (d,n,1) => (d,n)
869869
assert(dVdp.shape == (d, n))
870870

871871
# denMx = sum( spamvec[i] * Bmx[i] )
@@ -890,7 +890,7 @@ def _spam_penalty_jac_fill(spam_penalty_vec_grad_to_fill, mdl_pre, mdl_post,
890890
for lbl, effectvec in povm.items():
891891

892892
#get sgn(EMx) == d(|EMx|_Tr)/d(EMx) in std basis
893-
EMx = _tools.vec_to_stdmx(effectvec.to_dense(on_space='minimal')[:, None], op_basis)
893+
EMx = _tools.vec_to_stdmx(effectvec.to_dense('minimal')[:, None], op_basis)
894894
# dmDim = EMx.shape[0]
895895
assert(_np.linalg.norm(EMx - EMx.T.conjugate()) < 1e-4), \
896896
"denMx should be Hermitian!"
@@ -905,7 +905,7 @@ def _spam_penalty_jac_fill(spam_penalty_vec_grad_to_fill, mdl_pre, mdl_post,
905905
# get d(effectvec')/dp = [d(effectvec.T * S)/dp].T in op_basis [shape == (n,dim)]
906906
# = [effectvec.T * dS].T
907907
# OR = dS.T * effectvec
908-
pre_effectvec = mdl_pre.povms[povmlbl][lbl].to_dense(on_space='minimal')[:, None]
908+
pre_effectvec = mdl_pre.povms[povmlbl][lbl].to_dense('minimal')[:, None]
909909
dVdp = _np.dot(pre_effectvec.T, dS).squeeze(0).T
910910
# shape = (1,d) * (n, d1,d2) = (1,n,d2) => (n,d2) => (d2,n)
911911
assert(dVdp.shape == (d, n))

0 commit comments

Comments
 (0)