Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove commented-out function definitions and delete files with no executable code #452

Open
wants to merge 41 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
10ba164
initial attempt at removing out unneeded commented-out function defin…
rileyjmurray Jun 7, 2024
ccc6464
Add guardrails around public model attributes
Aug 31, 2024
0a1b0ca
Allow SIGINT set to be skipped via env variable.
sserita Sep 12, 2024
dd7bfe2
Logic bugfix
sserita Sep 12, 2024
bbbb471
Fix a bug with parameter label management for interposers
Sep 19, 2024
9522fb5
Initial implementation of caching for layout creation
May 22, 2024
6383cc3
Add caching for spam-free circuit expansion
May 29, 2024
093247b
New method for doing bulk intrument/effect expansion
May 30, 2024
9d57884
Minor COPA Layout __init__ tweaks
May 30, 2024
aa9519d
Refactor some OrderedDicts into regular ones
May 30, 2024
957facd
Start the process of adding caching to MDC store creation
Jun 1, 2024
9df2a61
Tweak omitted freqs and counts + DataSet and slicetools
Jun 3, 2024
8d5cfc7
Fix dataset bug
Jun 3, 2024
cd653b3
Another minor bugfix caught by testing
Jun 3, 2024
fd1e8d1
Another minor bugfix caught by testing
Jun 3, 2024
1ee6112
Faster implementation of __getitem__
Jun 5, 2024
1c83f9b
Implement caching for map layout creation
Jun 5, 2024
7a38689
Fix bugs in new extract_labels implementation
Jun 5, 2024
070c2f4
Finish refactoring expand_instruments_and_separate_povm
Jun 5, 2024
8f80e31
Refactor expand_instruments_and_separate_povm
Jun 5, 2024
007c449
Refactor cache creation functions
Jun 5, 2024
bc6d6ca
Add in DataSet key aliasing
Jul 31, 2024
a79f286
Minor refactors and updates
Jul 31, 2024
c6ed8ee
Unrelated RB testing fix
Jul 31, 2024
9ec8c87
Make test_rb paths absolute.
sserita Sep 19, 2024
599faa0
Fix beta tests.
sserita Sep 19, 2024
4d40eb7
Merge resolution with #488.
sserita Sep 19, 2024
bb9a278
main changes (breaks some calling functions elsewhere)
rileyjmurray May 22, 2024
cf7dcd1
check in
rileyjmurray May 23, 2024
e7b99e9
remove change that wasnt strictly in-scope for the PR
rileyjmurray May 23, 2024
b0b6d7d
remove changes that werent strictly necessary
rileyjmurray May 23, 2024
ec12bdb
tests pass
rileyjmurray May 23, 2024
a156511
remove is_normal function
rileyjmurray May 23, 2024
362788f
add a comment and remove unused imports
rileyjmurray May 23, 2024
a67f17f
interpygate helpers
rileyjmurray Sep 24, 2024
e79b2af
remove safe_dot
rileyjmurray Sep 24, 2024
2cdfe87
rebase step 1
rileyjmurray Sep 24, 2024
024d553
found lots of other commented-out function definitions
rileyjmurray Sep 30, 2024
5aa5cb7
add back commented-out function per request from Corey
rileyjmurray Oct 24, 2024
344670d
revert out-of-scope and unnecessary change
rileyjmurray Oct 24, 2024
00982b2
restore fogitools to state on develop
rileyjmurray Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pygsti/algorithms/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,8 +1150,6 @@ def find_closest_unitary_opmx(operation_mx):
# d = _np.sqrt(operation_mx.shape[0])
# I = _np.identity(d)

#def getu_1q(basisVec): # 1 qubit version
# return _spl.expm( 1j * (basisVec[0]*_tools.sigmax + basisVec[1]*_tools.sigmay + basisVec[2]*_tools.sigmaz) )
def _get_gate_mx_1q(basis_vec): # 1 qubit version
return _tools.single_qubit_gate(basis_vec[0],
basis_vec[1],
Expand Down
7 changes: 0 additions & 7 deletions pygsti/algorithms/fiducialselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,6 @@ def final_result_test(final_fids, verb_printer):
return prepFidList, measFidList


#def bool_list_to_ind_list(boolList):
# output = _np.array([])
# for i, boolVal in boolList:
# if boolVal == 1:
# output = _np.append(i)
# return output

def xor(*args):
"""
Implements logical xor function for arbitrary number of inputs.
Expand Down
147 changes: 74 additions & 73 deletions pygsti/algorithms/germselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3295,80 +3295,81 @@ def symmetric_low_rank_spectrum_update(update, orig_e, U, proj_U, force_rank_inc
#return the new eigenvalues
return new_evals, True

#Note: This function won't work for our purposes because of the assumptions
#about the rank of the update on the nullspace of the matrix we're updating,
#but keeping this here commented for future reference.
#Function for doing fast calculation of the updated inverse trace:
#def riedel_style_inverse_trace(update, orig_e, U, proj_U, force_rank_increase=True):
# """
# input:
#
# update : ndarray
# symmetric low-rank update to perform.
# This is the first half the symmetric rank decomposition s.t.
# [email protected]= the full update matrix.
#
# orig_e : ndarray
# Spectrum of the original matrix. This is a 1-D array.
#
# proj_U : ndarray
# Projector onto the complement of the column space of the
# original matrix's eigenvectors.
#
# output:
#
# trace : float
# Value of the trace of the updated psuedoinverse matrix.
#
# updated_rank : int
# total rank of the updated matrix.
#
# rank_increase_flag : bool
# a flag that is returned to indicate is a candidate germ failed to amplify additional parameters.
# This indicates things short circuited and so the scoring function should skip this germ.
# """
#
# #First we need to for the matrix P, whose column space
# #forms an orthonormal basis for the component of update
# #that is in the complement of U.
#
# proj_update= proj_U@update
#
# #Next take the RRQR decomposition of this matrix:
# q_update, r_update, _ = _sla.qr(proj_update, mode='economic', pivoting=True)
#
# #Construct P by taking the columns of q_update corresponding to non-zero values of r_A on the diagonal.
# nonzero_indices_update= _np.nonzero(_np.diag(r_update)>1e-10) #HARDCODED (threshold is hardcoded)
#
# #if the rank doesn't increase then we can't use the Riedel approach.
# #Abort early and return a flag to indicate the rank did not increase.
# if len(nonzero_indices_update[0])==0 and force_rank_increase:
# return None, None, False
#
# P= q_update[: , nonzero_indices_update[0]]
#
# updated_rank= len(orig_e)+ len(nonzero_indices_update[0])
#
# #Now form the matrix R_update which is given by P.T @ proj_update.
# R_update= P.T@proj_update
#
# #R_update gets concatenated with U.T@update to form
# #a block column matrixblock_column= np.concatenate([U.T@update, R_update], axis=0)
#
# Uta= U.T@update
#
# try:
# RRRDinv= R_update@_np.linalg.inv(R_update.T@R_update)
# except _np.linalg.LinAlgError as err:
# print('Numpy thinks this matrix is singular, condition number is: ', _np.linalg.cond(R_update.T@R_update))
# print((R_update.T@R_update).shape)
# raise err
# pinv_orig_e_mat= _np.diag(1/orig_e)
#
# trace= _np.sum(1/orig_e) + _np.trace( RRRDinv@(_np.eye(Uta.shape[1]) + Uta.T@pinv_orig_e_mat@Uta)@RRRDinv.T )
#
# return trace, updated_rank, True
# Note: Th function below won't work for our purposes because of the assumptions
# about the rank of the update on the nullspace of the matrix we're updating,
# but keeping this here commented for future reference.
'''
def riedel_style_inverse_trace(update, orig_e, U, proj_U, force_rank_increase=True):
"""
input:

update : ndarray
symmetric low-rank update to perform.
This is the first half the symmetric rank decomposition s.t.
[email protected]= the full update matrix.

orig_e : ndarray
Spectrum of the original matrix. This is a 1-D array.

proj_U : ndarray
Projector onto the complement of the column space of the
original matrix's eigenvectors.

output:

trace : float
Value of the trace of the updated psuedoinverse matrix.

updated_rank : int
total rank of the updated matrix.

rank_increase_flag : bool
a flag that is returned to indicate is a candidate germ failed to amplify additional parameters.
This indicates things short circuited and so the scoring function should skip this germ.
"""

#First we need to for the matrix P, whose column space
#forms an orthonormal basis for the component of update
#that is in the complement of U.

proj_update= proj_U@update

#Next take the RRQR decomposition of this matrix:
q_update, r_update, _ = _sla.qr(proj_update, mode='economic', pivoting=True)

#Construct P by taking the columns of q_update corresponding to non-zero values of r_A on the diagonal.
nonzero_indices_update= _np.nonzero(_np.diag(r_update)>1e-10) #HARDCODED (threshold is hardcoded)

#if the rank doesn't increase then we can't use the Riedel approach.
#Abort early and return a flag to indicate the rank did not increase.
if len(nonzero_indices_update[0])==0 and force_rank_increase:
return None, None, False

P= q_update[: , nonzero_indices_update[0]]

updated_rank= len(orig_e)+ len(nonzero_indices_update[0])

#Now form the matrix R_update which is given by P.T @ proj_update.
R_update= P.T@proj_update

#R_update gets concatenated with U.T@update to form
#a block column matrixblock_column= np.concatenate([U.T@update, R_update], axis=0)

Uta= U.T@update

try:
RRRDinv= R_update@_np.linalg.inv(R_update.T@R_update)
except _np.linalg.LinAlgError as err:
print('Numpy thinks this matrix is singular, condition number is: ', _np.linalg.cond(R_update.T@R_update))
print((R_update.T@R_update).shape)
raise err
pinv_orig_e_mat= _np.diag(1/orig_e)

trace= _np.sum(1/orig_e) + _np.trace( RRRDinv@(_np.eye(Uta.shape[1]) + Uta.T@pinv_orig_e_mat@Uta)@RRRDinv.T )

return trace, updated_rank, True
'''

def minamide_style_inverse_trace(update, orig_e, U, proj_U, force_rank_increase=False):
"""
This function performs a low-rank update to the components of
Expand Down
Loading