CloneDigger Report

Source files: 6

Click here to show/hide file names

Source files:
algorithms/fiducialpairreduction.py,
algorithms/__init__.py,
algorithms/grammatrix.py,
algorithms/fiducialselection.py,
algorithms/core.py,
algorithms/germselection.py

Clones detected: 36

442 of 1927 lines are duplicates (22.94%)

Parameters
clustering_threshold = 10
distance_threshold = 5
size_threshold = 5
hashing_depth = 1
clusterize_using_hash = False
clusterize_using_dcup = False

Time elapsed
Construction of AST : 0.41 seconds
Building statement hash : 0.01 seconds
Building patterns : 1.08 seconds
Marking similar statements : 1.41 seconds
Finding similar sequences of statements : 0.18 seconds
Refining candidates : 0.39 seconds
Total time: 3.47
Started at: Mon Aug 1 06:55:02 2016
Finished at: Mon Aug 1 06:55:06 2016

Clone # 1
Distance between two fragments = 0
Clone size = 18

Source file "algorithms/core.py" The first line is 1026 |  | Source file "algorithms/core.py" The first line is 1998
if maxEvalSubTreeSize is not None: evTree.split(maxEvalSubTreeSize, None) |  | if maxEvalSubTreeSize is not None: evTree.split(maxEvalSubTreeSize, None)
if comm is not None: nprocs = comm.Get_size() if distributeMethod == 'gatestrings': if not evTree.is_split(): evTree.split(None, nprocs) else: assert maxEvalSubTreeSize is not None if len(evTree.get_sub_trees()) < nprocs: evTree.split(None, nprocs) if any([len(sub) > maxEvalSubTreeSize for sub in evTree.get_sub_trees() ]): evTree.split(maxEvalSubTreeSize, None) elif distributeMethod == 'deriv': pass else: raise ValueError(('Invalid distribute method: %s') % (distributeMethod)) |  | if comm is not None: nprocs = comm.Get_size() if distributeMethod == 'gatestrings': if not evTree.is_split(): evTree.split(None, nprocs) else: assert maxEvalSubTreeSize is not None if len(evTree.get_sub_trees()) < nprocs: evTree.split(None, nprocs) if any([len(sub) > maxEvalSubTreeSize for sub in evTree.get_sub_trees() ]): evTree.split(maxEvalSubTreeSize, None) elif distributeMethod == 'deriv': pass else: raise ValueError(('Invalid distribute method: %s') % (distributeMethod))
if ((comm is None) or (comm.Get_rank() == 0)) and (evTree.is_split()): printer.log('Memory limit and/or MPI has imposed a division of the evaluation tree:', 2) evTree.print_analysis() |  | if ((comm is None) or (comm.Get_rank() == 0)) and (evTree.is_split()): printer.log('Memory limit and/or MPI has imposed a division of the evaluation tree:', 2) evTree.print_analysis()

Clone # 2
Distance between two fragments = 1
Clone size = 16

Source file "algorithms/core.py" The first line is 1456 |  | Source file "algorithms/core.py" The first line is 1418
minErr, gs = do_mc2gst(dataset, curStartGateset, gateStringsToUse, maxiter, maxfev, tol, cptp_penalty_factor, minProbClipForWeighting, probClipInterval, useFreqWeightedChiSq, regularizeFactor, (printer) - (1), check, check_jacobian, gatestringWeights, None, memLimit, comm) |  | minErr, gs = do_mc2gst(dataset, curStartGateset, gateStringsToUse, maxiter, maxfev, tol, cptp_penalty_factor, minProbClipForWeighting, probClipInterval, useFreqWeightedChiSq, regularizeFactor, (printer) - (1), check, check_jacobian, gatestringWeights, None, memLimit, comm)
chiSq = sum([(x) ** (2) for x in minErr ]) |  | chiSq = sum([(x) ** (2) for x in minErr ])
chi2diff = (chiSq) - (chiSqBest) |  | chi2diff = (chiSq) - (chiSqBest)
paramDiff = (nParams) - (nParamsBest) |  | paramDiff = (nParams) - (nParamsBest)
if (chiSqBest) - (chiSq) > (2) * ((nParams) - (nParamsBest)): bestGS, bestMinErr, chiSqBest, nParamsBest = (gs, minErr, chiSq, nParams) msResult = 'Selected' else: msResult = 'Rejected' tryIncreasedDim = False |  | if (chiSqBest) - (chiSq) > (2) * ((nParams) - (nParamsBest)): bestGS, bestMinErr, chiSqBest, nParamsBest = (gs, minErr, chiSq, nParams) msResult = 'Selected' else: msResult = 'Rejected' tryDecreasedDim = False
printer.log(('%s dim %d: chi^2 = %g (%+g w.r.t. expected mean of %d strings - %d params = %d) (dChi^2=%d, 2*dParams=%d)') % ((msResult, curDim, chiSq, (chiSq) - ((nStrings) - (nParams)), nStrings, nParams, (nStrings) - (nParams), chi2diff, (2) * (paramDiff)))) |  | printer.log(('%s dim %d: chi^2 = %g (%+g w.r.t. expected mean of %d strings - %d params = %d) (dChi^2=%d, 2*dParams=%d)') % ((msResult, curDim, chiSq, (chiSq) - ((nStrings) - (nParams)), nStrings, nParams, (nStrings) - (nParams), chi2diff, (2) * (paramDiff))))

Clone # 3
Distance between two fragments = 0
Clone size = 13

Source file "algorithms/core.py" The first line is 971 |  | Source file "algorithms/core.py" The first line is 1948
if gateLabelAliases is not None: dsGateStringsToUse = [] for s in gateStringsToUse: for label, expandedStr in gateLabelAliases.items(): while label in tuple(s): i = tuple(s).index(label) s = ((tuple(s)[:i]) + (tuple(expandedStr))) + (tuple(s)[(i) + (1):]) dsGateStringsToUse.append(s) else: dsGateStringsToUse = gateStringsToUse |  | if gateLabelAliases is not None: dsGateStringsToUse = [] for s in gateStringsToUse: for label, expandedStr in gateLabelAliases.items(): while label in tuple(s): i = tuple(s).index(label) s = ((tuple(s)[:i]) + (tuple(expandedStr))) + (tuple(s)[(i) + (1):]) dsGateStringsToUse.append(s) else: dsGateStringsToUse = gateStringsToUse
evTree = gs.bulk_evaltree(gateStringsToUse) |  | evTree = gs.bulk_evaltree(gateStringsToUse)
ns = len(spamLabels) |  | ns = len(spamLabels)
ng = len(gateStringsToUse) |  | ng = len(gateStringsToUse)
ne = gs.num_params() |  | ne = gs.num_params()
gd = gs.get_dimension() |  | gd = gs.get_dimension()
C = (1.0) / ((1024.0) ** (3)) |  | C = (1.0) / ((1024.0) ** (3))

Clone # 4
Distance between two fragments = 2
Clone size = 11

Source file "algorithms/core.py" The first line is 3025 |  | Source file "algorithms/core.py" The first line is 2992
print_obj_func = _opt.create_obj_func_printer(objective_func) |  | print_obj_func = _opt.create_obj_func_printer(objective_func)
if objective_func(gs.to_vector()) < 1e-08: printer.log('Already in CP - no contraction necessary', 1) return (0.0, gs) |  | if objective_func(gs.to_vector()) < 1e-08: printer.log('Already in XP - no contraction necessary', 1) return (0.0, gs)
optSol = _opt.minimize(objective_func,gs.to_vector(), method=method, tol=tol, maxiter=maxiter, callback = print_obj_func if printer.verbosity > 2 else None) |  | optSol = _opt.minimize(objective_func,gs.to_vector(), method=method, tol=tol, maxiter=maxiter, callback = print_obj_func if printer.verbosity > 2 else None)
gs.from_vector(optSol.x) |  | gs.from_vector(optSol.x)
if optSol.fun >= CLIFF: _warnings.warn('Failed to contract gateset to CP') |  | if optSol.fun >= CLIFF: _warnings.warn('Failed to contract gateset to XP')
printer.log(('The closest legal point found was distance: ') + (str(optSol.fun)), 1) |  | printer.log(('The closest legal point found was distance: ') + (str(optSol.fun)), 1)
return (optSol.fun, gs) |  | return (optSol.fun, gs)

Clone # 5
Distance between two fragments = 2
Clone size = 11

Source file "algorithms/core.py" The first line is 2656 |  | Source file "algorithms/core.py" The first line is 2753
if constrainToTP: tpGateset = gateset tpGaugeMx = _np.identity(gateDim, 'd') else: _, tpGaugeMx, tpGateset = optimize_gauge(gateset, 'TP', maxiter, maxfev, tol, 'L-BFGS-B', targetGateset, targetFactor, constrainToTP, constrainToCP, constrainToValidSpam, True, gateWeight, spamWeight, itemWeights, (printer) - (1)) |  | if constrainToTP: tpGateset = gateset tpGaugeMx = _np.identity(gateDim, 'd') else: _, tpGaugeMx, tpGateset = optimize_gauge(gateset, 'TP and target', maxiter, maxfev, tol, 'L-BFGS-B', targetGateset, targetFactor, constrainToTP, constrainToCP, constrainToValidSpam, True, gateWeight, spamWeight, itemWeights, (printer) - (1))
printer.log('', 2) |  | printer.log('', 2)
printer.log(('--- Gauge Optimization to CPTP w/valid SPAM (%s) ---') % (method), 1, indentOffset=-1) |  | printer.log(('--- Gauge Optimization to CPTP and target w/valid SPAM (%s) ---') % (method), 1, indentOffset=-1)
constrainToTP = True |  | constrainToTP = True

Clone # 6
Distance between two fragments = 2
Clone size = 10

Source file "algorithms/core.py" The first line is 946 |  | Source file "algorithms/core.py" The first line is 1931
printer = _objs.VerbosityPrinter.build_printer(verbosity, comm) |  | printer = _objs.VerbosityPrinter.build_printer(verbosity, comm)
gs = startGateset.copy() |  | gs = startGateset.copy()
if maxfev is None: maxfev = maxiter |  | if maxfev is None: maxfev = maxiter
printer.log('', 2) |  | printer.log('', 2)
printer.log('--- Minimum Chi^2 GST ---', 1, indentOffset=-1) |  | printer.log('--- MLGST ---', 1, indentOffset=-1)
if comm is not None: gs_cmp = comm.bcast(gs if (comm.Get_rank() == 0) else None, root=0) if gs.frobeniusdist(gs_cmp) > 1e-6: raise ValueError("MPI ERROR: *different* MC2GST start gatesets" + " given to different processors!") |  | if comm is not None: gs_cmp = comm.bcast(gs if (comm.Get_rank() == 0) else None, root=0) if gs.frobeniusdist(gs_cmp) > 1e-6: raise ValueError("MPI ERROR: *different* MLGST start gatesets" + " given to different processors!")

Clone # 7
Distance between two fragments = 3
Clone size = 9

Source file "algorithms/core.py" The first line is 2361 |  | Source file "algorithms/core.py" The first line is 1602
printer = _objs.VerbosityPrinter.build_printer(verbosity, comm) |  | printer = _objs.VerbosityPrinter.build_printer(verbosity, comm)
if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation |  | if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation
mleGatesets = [] |  | lsgstGatesets = []
maxLogLs = [] |  | minErrs = []
mleGateset = startGateset.copy() |  | lsgstGateset = startGateset.copy()
nIters = len(gateStringLists) |  | nIters = len(gateStringLists)
tRef = _time.time() |  | tRef = _time.time()

Clone # 8
Distance between two fragments = 0
Clone size = 9

Source file "algorithms/core.py" The first line is 2733 |  | Source file "algorithms/core.py" The first line is 2711
matM = vectorM.reshape((gateDim, gateDim)) |  | matM = vectorM.reshape((gateDim, gateDim))
gs = gateset.copy() |  | gs = gateset.copy()
gs.transform(matM) |  | gs.transform(matM)
tpPenalty = 0 |  | tpPenalty = 0
for gate in list(gs.gates.values()): tpPenalty += ((1.0) - (gate[0,0])) ** (2) for k in range(1, gate.shape[1]): tpPenalty += (gate[0,k]) ** (2) |  | for gate in list(gs.gates.values()): tpPenalty += ((1.0) - (gate[0,0])) ** (2) for k in range(1, gate.shape[1]): tpPenalty += (gate[0,k]) ** (2)
for rhoVec in list(gs.preps.values()): tpPenalty += ((rhoVecFirstEl) - (rhoVec[0])) ** (2) |  | for rhoVec in list(gs.preps.values()): tpPenalty += ((rhoVecFirstEl) - (rhoVec[0])) ** (2)

Clone # 9
Distance between two fragments = 2
Clone size = 8

Source file "algorithms/core.py" The first line is 791 |  | Source file "algorithms/core.py" The first line is 1768
printer = _objs.VerbosityPrinter.build_printer(verbosity, comm) |  | printer = _objs.VerbosityPrinter.build_printer(verbosity, comm)
if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation |  | if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation
elgstGatesets = [] |  | lsgstGatesets = []
minErrs = [] |  | minErrs = []
elgstGateset = startGateset.copy() |  | lsgstGateset = startGateset.copy()
nIters = len(gateStringLists) |  | nIters = len(gateStringLists)

Clone # 10
Distance between two fragments = 3
Clone size = 8

Source file "algorithms/core.py" The first line is 791 |  | Source file "algorithms/core.py" The first line is 2361
printer = _objs.VerbosityPrinter.build_printer(verbosity, comm) |  | printer = _objs.VerbosityPrinter.build_printer(verbosity, comm)
if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation |  | if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation
elgstGatesets = [] |  | mleGatesets = []
minErrs = [] |  | maxLogLs = []
elgstGateset = startGateset.copy() |  | mleGateset = startGateset.copy()
nIters = len(gateStringLists) |  | nIters = len(gateStringLists)

Clone # 11
Distance between two fragments = 2
Clone size = 8

Source file "algorithms/core.py" The first line is 791 |  | Source file "algorithms/core.py" The first line is 1602
printer = _objs.VerbosityPrinter.build_printer(verbosity, comm) |  | printer = _objs.VerbosityPrinter.build_printer(verbosity, comm)
if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation |  | if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation
elgstGatesets = [] |  | lsgstGatesets = []
minErrs = [] |  | minErrs = []
elgstGateset = startGateset.copy() |  | lsgstGateset = startGateset.copy()
nIters = len(gateStringLists) |  | nIters = len(gateStringLists)

Clone # 12
Distance between two fragments = 3
Clone size = 8

Source file "algorithms/core.py" The first line is 1768 |  | Source file "algorithms/core.py" The first line is 2361
printer = _objs.VerbosityPrinter.build_printer(verbosity, comm) |  | printer = _objs.VerbosityPrinter.build_printer(verbosity, comm)
if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation |  | if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation
lsgstGatesets = [] |  | mleGatesets = []
minErrs = [] |  | maxLogLs = []
lsgstGateset = startGateset.copy() |  | mleGateset = startGateset.copy()
nIters = len(gateStringLists) |  | nIters = len(gateStringLists)

Clone # 13
Distance between two fragments = 0
Clone size = 8

Source file "algorithms/core.py" The first line is 1768 |  | Source file "algorithms/core.py" The first line is 1602
printer = _objs.VerbosityPrinter.build_printer(verbosity, comm) |  | printer = _objs.VerbosityPrinter.build_printer(verbosity, comm)
if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation |  | if (len(gateStringSetsToUseInEstimation) > 0) and (len(gateStringSetsToUseInEstimation[0]) > 0) and (isinstance(gateStringSetsToUseInEstimation[0][0], _objs.GateString)): gateStringLists = [[gstr.tup for gstr in gsList ] for gsList in gateStringSetsToUseInEstimation ] else: gateStringLists = gateStringSetsToUseInEstimation
lsgstGatesets = [] |  | lsgstGatesets = []
minErrs = [] |  | minErrs = []
lsgstGateset = startGateset.copy() |  | lsgstGateset = startGateset.copy()
nIters = len(gateStringLists) |  | nIters = len(gateStringLists)

Clone # 14
Distance between two fragments = 0
Clone size = 8

Source file "algorithms/core.py" The first line is 2131 |  | Source file "algorithms/core.py" The first line is 2153
pos_probs = _np.where(probs < min_p, min_p, probs) |  | pos_probs = _np.where(probs < min_p, min_p, probs)
S = (minusCntVecMx) / (min_p) |  | S = (minusCntVecMx) / (min_p)
S2 = ((-0.5) * (minusCntVecMx)) / ((min_p) ** (2)) |  | S2 = ((-0.5) * (minusCntVecMx)) / ((min_p) ** (2))
v = (freqTerm) + ((minusCntVecMx) * (_np.log(pos_probs))) |  | v = (freqTerm) + ((minusCntVecMx) * (_np.log(pos_probs)))
v = _np.maximum(v, 0) |  | v = _np.maximum(v, 0)
v = _np.where(probs < min_p, ((v) + ((S) * ((probs) - (min_p)))) + ((S2) * (((probs) - (min_p)) ** (2))), v) |  | v = _np.where(probs < min_p, ((v) + ((S) * ((probs) - (min_p)))) + ((S2) * (((probs) - (min_p)) ** (2))), v)
v = _np.where(minusCntVecMx == 0, 0.0, v) |  | v = _np.where(minusCntVecMx == 0, 0.0, v)
v = _np.sqrt(v) |  | v = _np.sqrt(v)

Clone # 15
Distance between two fragments = 0
Clone size = 8

Source file "algorithms/core.py" The first line is 2066 |  | Source file "algorithms/core.py" The first line is 2089
pos_probs = _np.where(probs < min_p, min_p, probs) |  | pos_probs = _np.where(probs < min_p, min_p, probs)
S = ((minusCntVecMx) / (min_p)) + (totalCntVec[None,None:None]) |  | S = ((minusCntVecMx) / (min_p)) + (totalCntVec[None,None:None])
S2 = ((-0.5) * (minusCntVecMx)) / ((min_p) ** (2)) |  | S2 = ((-0.5) * (minusCntVecMx)) / ((min_p) ** (2))
v = ((freqTerm) + ((minusCntVecMx) * (_np.log(pos_probs)))) + ((totalCntVec[None,None:None]) * (pos_probs)) |  | v = ((freqTerm) + ((minusCntVecMx) * (_np.log(pos_probs)))) + ((totalCntVec[None,None:None]) * (pos_probs))
v = _np.maximum(v, 0) |  | v = _np.maximum(v, 0)
v = _np.where(probs < min_p, ((v) + ((S) * ((probs) - (min_p)))) + ((S2) * (((probs) - (min_p)) ** (2))), v) |  | v = _np.where(probs < min_p, ((v) + ((S) * ((probs) - (min_p)))) + ((S2) * (((probs) - (min_p)) ** (2))), v)
v = _np.where(minusCntVecMx == 0, (totalCntVec[None,None:None]) * (_np.where(probs >= a, probs, ((((-1.0) / ((3) * ((a) ** (2)))) * ((probs) ** (3))) + (((probs) ** (2)) / (a))) + ((a) / (3.0)))), v) |  | v = _np.where(minusCntVecMx == 0, (totalCntVec[None,None:None]) * (_np.where(probs >= a, probs, ((((-1.0) / ((3) * ((a) ** (2)))) * ((probs) ** (3))) + (((probs) ** (2)) / (a))) + ((a) / (3.0)))), v)
v = _np.sqrt(v) |  | v = _np.sqrt(v)

Clone # 16
Distance between two fragments = 2
Clone size = 7

Source file "algorithms/core.py" The first line is 1456 |  | Source file "algorithms/core.py" The first line is 1388
minErr, gs = do_mc2gst(dataset, curStartGateset, gateStringsToUse, maxiter, maxfev, tol, cptp_penalty_factor, minProbClipForWeighting, probClipInterval, useFreqWeightedChiSq, regularizeFactor, (printer) - (1), check, check_jacobian, gatestringWeights, None, memLimit, comm) |  | minErr, gs = do_mc2gst(dataset, startGateset, gateStringsToUse, maxiter, maxfev, tol, cptp_penalty_factor, minProbClipForWeighting, probClipInterval, useFreqWeightedChiSq, regularizeFactor, (printer) - (1), check, check_jacobian, gatestringWeights, None, memLimit, comm)
chiSq = sum([(x) ** (2) for x in minErr ]) |  | chiSqBest = sum([(x) ** (2) for x in minErr ])

Clone # 17
Distance between two fragments = 2
Clone size = 7

Source file "algorithms/core.py" The first line is 1418 |  | Source file "algorithms/core.py" The first line is 1388
minErr, gs = do_mc2gst(dataset, curStartGateset, gateStringsToUse, maxiter, maxfev, tol, cptp_penalty_factor, minProbClipForWeighting, probClipInterval, useFreqWeightedChiSq, regularizeFactor, (printer) - (1), check, check_jacobian, gatestringWeights, None, memLimit, comm) |  | minErr, gs = do_mc2gst(dataset, startGateset, gateStringsToUse, maxiter, maxfev, tol, cptp_penalty_factor, minProbClipForWeighting, probClipInterval, useFreqWeightedChiSq, regularizeFactor, (printer) - (1), check, check_jacobian, gatestringWeights, None, memLimit, comm)
chiSq = sum([(x) ** (2) for x in minErr ]) |  | chiSqBest = sum([(x) ** (2) for x in minErr ])

Clone # 18
Distance between two fragments = 2
Clone size = 7

Source file "algorithms/germselection.py" The first line is 296 |  | Source file "algorithms/fiducialselection.py" The first line is 159
if scoreFunc == 'all': def list_score(input_array): return sum((1.0) / (input_array)) elif scoreFunc == 'worst': def list_score(input_array): return (1.0) / (min(input_array)) |  | if scoreFunc == 'all': def list_score(input_array): return sum((1.0) / (input_array)) elif scoreFunc == 'worst': def list_score(input_array): return (1.0) / (min(input_array))
gateset = gateset.copy() |  | dimRho = gateset.get_dimension()

Clone # 19
Distance between two fragments = 2
Clone size = 7

Source file "algorithms/fiducialselection.py" The first line is 563 |  | Source file "algorithms/germselection.py" The first line is 688
printer.log(('score = %s') % (score)) |  | printer.log(('score = %s') % (score))
printer.log(('weights = %s') % (weights)) |  | printer.log(('weights = %s') % (weights))
printer.log(('L1(weights) = %s') % (sum(weights))) |  | printer.log(('L1(weights) = %s') % (sum(weights)))
goodFidList = [] |  | goodGermsList = []
for index, val in enumerate(weights): if val == 1: goodFidList.append(fidList[index]) |  | for index, val in enumerate(weights): if val == 1: goodGermsList.append(germsList[index])

Clone # 20
Distance between two fragments = 0
Clone size = 7

Source file "algorithms/core.py" The first line is 1787 |  | Source file "algorithms/core.py" The first line is 1623
if (stringsToEstimate is None) or (len(stringsToEstimate) == 0): continue |  | if (stringsToEstimate is None) or (len(stringsToEstimate) == 0): continue
if gatestringWeightsDict is not None: gatestringWeights = _np.ones(len(stringsToEstimate), 'd') for gatestr, weight in gatestringWeightsDict.items(): if gatestr in stringsToEstimate: gatestringWeights[stringsToEstimate.index(gatestr)] = weight else: gatestringWeights = None |  | if gatestringWeightsDict is not None: gatestringWeights = _np.ones(len(stringsToEstimate), 'd') for gatestr, weight in gatestringWeightsDict.items(): if gatestr in stringsToEstimate: gatestringWeights[stringsToEstimate.index(gatestr)] = weight else: gatestringWeights = None

Clone # 21
Distance between two fragments = 0
Clone size = 7

Source file "algorithms/core.py" The first line is 2678 |  | Source file "algorithms/core.py" The first line is 2767
vectorM = _np.concatenate((firstRowForTP, vectorM)) |  | vectorM = _np.concatenate((firstRowForTP, vectorM))
matM = vectorM.reshape((gateDim, gateDim)) |  | matM = vectorM.reshape((gateDim, gateDim))
gs = tpGateset.copy() |  | gs = tpGateset.copy()
gs.transform(matM) |  | gs.transform(matM)
cpPenalties = _tools.sums_of_negative_choi_evals(gs) |  | cpPenalties = _tools.sums_of_negative_choi_evals(gs)
cpPenalty = sum(cpPenalties) |  | cpPenalty = sum(cpPenalties)
spamPenalty = sum([_tools.prep_penalty(rhoVec) for rhoVec in list(gs.preps.values()) ]) |  | spamPenalty = sum([_tools.prep_penalty(rhoVec) for rhoVec in list(gs.preps.values()) ])
spamPenalty += sum([_tools.effect_penalty(EVec) for EVec in list(gs.effects.values()) ]) |  | spamPenalty += sum([_tools.effect_penalty(EVec) for EVec in list(gs.effects.values()) ])

Clone # 22
Distance between two fragments = 2
Clone size = 6

Source file "algorithms/germselection.py" The first line is 693 |  | Source file "algorithms/fiducialselection.py" The first line is 487
for index, val in enumerate(weights): if val == 1: goodGermsList.append(germsList[index]) |  | for index, val in enumerate(weights): if val == 1: goodFidList.append(fidList[index])
if returnAll: return (goodGermsList, weights, scoreD) else: return goodGermsList |  | if returnAll: return (goodFidList, weights, scoreD) else: return goodFidList

Clone # 23
Distance between two fragments = 1
Clone size = 6

Source file "algorithms/fiducialselection.py" The first line is 171 |  | Source file "algorithms/fiducialselection.py" The first line is 408
if prepOrMeas == 'prep': fidArrayList = make_prep_mxs(gateset, fidList) elif prepOrMeas == 'meas': fidArrayList = make_meas_mxs(gateset, fidList) else: raise Exception('Invalid value for prepOrMeas (must be "prep" or "meas")!') |  | if prepOrMeas == 'prep': fidArrayList = make_prep_mxs(gateset, fidList) elif prepOrMeas == 'meas': fidArrayList = make_meas_mxs(gateset, fidList) else: raise Exception('prepOrMeas must be specified!')
numMxs = len(fidArrayList) |  | numMxs = len(fidArrayList)

Clone # 24
Distance between two fragments = 0
Clone size = 6

Source file "algorithms/core.py" The first line is 2193 |  | Source file "algorithms/core.py" The first line is 1256
nGateStrings = len(gateStringsToUse) |  | nGateStrings = len(gateStringsToUse)
nDataParams = (nGateStrings) * ((len(dataset.get_spam_labels())) - (1)) |  | nDataParams = (nGateStrings) * ((len(dataset.get_spam_labels())) - (1))
try: nModelParams = gs.num_nongauge_params() except: printer.warning('Could not obtain number of *non-gauge* parameters - using total params instead') nModelParams = gs.num_params() |  | try: nModelParams = gs.num_nongauge_params() except: printer.warning('Could not obtain number of *non-gauge* parameters - using total params instead') nModelParams = gs.num_params()

Clone # 25
Distance between two fragments = 0
Clone size = 6

Source file "algorithms/core.py" The first line is 1240 |  | Source file "algorithms/core.py" The first line is 662
x0 = gs.to_vector() |  | x0 = gs.to_vector()
opt_x, _, _, _, _ = _spo.leastsq(objective_func, x0, xtol=tol, ftol=tol, gtol=tol, maxfev=(maxfev) * ((len(x0)) + (1)), full_output=True, Dfun=jacobian) |  | opt_x, _, _, _, _ = _spo.leastsq(objective_func, x0, xtol=tol, ftol=tol, gtol=tol, maxfev=(maxfev) * ((len(x0)) + (1)), full_output=True, Dfun=jacobian)
full_minErrVec = objective_func(opt_x) |  | full_minErrVec = objective_func(opt_x)
minErrVec = full_minErrVec if regularizeFactor == 0 else full_minErrVec[0:-len(x0)] #don't include regularization terms |  | minErrVec = full_minErrVec if regularizeFactor == 0 else full_minErrVec[0:-len(x0)] #don't include regularization terms

Clone # 26
Distance between two fragments = 0
Clone size = 5

Source file "algorithms/core.py" The first line is 1990 |  | Source file "algorithms/core.py" The first line is 1018
printer.log((('Memory estimates: (%d spam labels,') % (ns)) + (('%d gate strings, %d gateset params, %d gate dim)') % ((ng, ne, gd))), 2) |  | printer.log((('Memory estimates: (%d spam labels,') % (ns)) + (('%d gate strings, %d gateset params, %d gate dim)') % ((ng, ne, gd))), 2)
printer.log(('Peristent: %g GB ') % ((persistentMem) * (C)), 2) |  | printer.log(('Peristent: %g GB ') % ((persistentMem) * (C)), 2)
printer.log(('Intermediate: %g GB ') % ((intermedMem) * (C)), 2) |  | printer.log(('Intermediate: %g GB ') % ((intermedMem) * (C)), 2)
printer.log(('Limit: %g GB') % ((memLimit) * (C)), 2) |  | printer.log(('Limit: %g GB') % ((memLimit) * (C)), 2)

Clone # 27
Distance between two fragments = 0
Clone size = 5

Source file "algorithms/core.py" The first line is 1104 |  | Source file "algorithms/core.py" The first line is 1115
gs.from_vector(vectorGS) |  | gs.from_vector(vectorGS)
gs.bulk_fill_probs(probs, spam_lbl_rows, evTree, probClipInterval, check, comm) |  | gs.bulk_fill_probs(probs, spam_lbl_rows, evTree, probClipInterval, check, comm)
weights = get_weights(probs) |  | weights = get_weights(probs)
v = ((probs) - (f)) * (weights) |  | v = ((probs) - (f)) * (weights)

Clone # 28
Distance between two fragments = 0
Clone size = 5

Source file "algorithms/core.py" The first line is 2084 |  | Source file "algorithms/core.py" The first line is 2148
gs.from_vector(vectorGS) |  | gs.from_vector(vectorGS)
gs.bulk_fill_dprobs(dprobs, spam_lbl_rows, evTree, prMxToFill=probs, clipTo=probClipInterval, check=check, comm=comm) |  | gs.bulk_fill_dprobs(dprobs, spam_lbl_rows, evTree, prMxToFill=probs, clipTo=probClipInterval, check=check, comm=comm)
pos_probs = _np.where(probs < min_p, min_p, probs) |  | pos_probs = _np.where(probs < min_p, min_p, probs)

Clone # 29
Distance between two fragments = 0
Clone size = 5

Source file "algorithms/core.py" The first line is 1154 |  | Source file "algorithms/core.py" The first line is 1170
gs.from_vector(vectorGS) |  | gs.from_vector(vectorGS)
gs.bulk_fill_dprobs(dprobs, spam_lbl_rows, evTree, prMxToFill=probs, clipTo=probClipInterval, check=check, comm=comm) |  | gs.bulk_fill_dprobs(dprobs, spam_lbl_rows, evTree, prMxToFill=probs, clipTo=probClipInterval, check=check, comm=comm)
weights = get_weights(probs) |  | weights = get_weights(probs)

Clone # 30
Distance between two fragments = 0
Clone size = 5

Source file "algorithms/core.py" The first line is 1154 |  | Source file "algorithms/core.py" The first line is 1137
gs.from_vector(vectorGS) |  | gs.from_vector(vectorGS)
gs.bulk_fill_dprobs(dprobs, spam_lbl_rows, evTree, prMxToFill=probs, clipTo=probClipInterval, check=check, comm=comm) |  | gs.bulk_fill_dprobs(dprobs, spam_lbl_rows, evTree, prMxToFill=probs, clipTo=probClipInterval, check=check, comm=comm)
weights = get_weights(probs) |  | weights = get_weights(probs)

Clone # 31
Distance between two fragments = 0
Clone size = 5

Source file "algorithms/core.py" The first line is 1170 |  | Source file "algorithms/core.py" The first line is 1137
gs.from_vector(vectorGS) |  | gs.from_vector(vectorGS)
gs.bulk_fill_dprobs(dprobs, spam_lbl_rows, evTree, prMxToFill=probs, clipTo=probClipInterval, check=check, comm=comm) |  | gs.bulk_fill_dprobs(dprobs, spam_lbl_rows, evTree, prMxToFill=probs, clipTo=probClipInterval, check=check, comm=comm)
weights = get_weights(probs) |  | weights = get_weights(probs)

Clone # 32
Distance between two fragments = 1
Clone size = 5

Source file "algorithms/core.py" The first line is 3013 |  | Source file "algorithms/core.py" The first line is 2978
CLIFF = 10000 |  | CLIFF = 10000
printer = _objs.VerbosityPrinter.build_printer(verbosity) |  | printer = _objs.VerbosityPrinter.build_printer(verbosity)
printer.log('', 2) |  | printer.log('', 2)
printer.log('--- Contract to CP ---', 1, indentOffset=-1) |  | printer.log('--- Contract to XP ---', 1, indentOffset=-1)
gs = gateset.copy() |  | gs = gateset.copy()

Clone # 33
Distance between two fragments = 1
Clone size = 5

Source file "algorithms/fiducialselection.py" The first line is 499 |  | Source file "algorithms/germselection.py" The first line is 595
def get_neighbors(boolVec): for i in range(nFids): v = boolVec.copy() v[i] = ((v[i]) + (1)) % (2) yield v |  | def get_neighbors(boolVec): for i in range(nGerms): v = boolVec.copy() v[i] = ((v[i]) + (1)) % (2) yield v

Clone # 34
Distance between two fragments = 0
Clone size = 5

Source file "algorithms/fiducialpairreduction.py" The first line is 169 |  | Source file "algorithms/fiducialpairreduction.py" The first line is 177
ret = [] |  | ret = []
for i in pairIndicesToTest: iRhoStr = (i) // (nEStrs) iEStr = (i) - ((iRhoStr) * (nEStrs)) ret.append((iRhoStr, iEStr)) |  | for i in pairIndicesToTest: iRhoStr = (i) // (nEStrs) iEStr = (i) - ((iRhoStr) * (nEStrs)) ret.append((iRhoStr, iEStr))

Clone # 35
Distance between two fragments = 0
Clone size = 5

Source file "algorithms/core.py" The first line is 1010 |  | Source file "algorithms/core.py" The first line is 1982
intermedMem = (8) * (((ng) + ((ng) * ((gd) ** (2)))) + (((ng) * ((gd) ** (2))) * (ne))) |  | intermedMem = (8) * (((ng) + ((ng) * ((gd) ** (2)))) + (((ng) * ((gd) ** (2))) * (ne)))
if (memLimit is not None) and (memLimit < intermedMem): reductionFactor = (float(intermedMem)) / (float(memLimit)) maxEvalSubTreeSize = int((ng) / (reductionFactor)) else: maxEvalSubTreeSize = None |  | if (memLimit is not None) and (memLimit < intermedMem): reductionFactor = (float(intermedMem)) / (float(memLimit)) maxEvalSubTreeSize = int((ng) / (reductionFactor)) else: maxEvalSubTreeSize = None

Clone # 36
Distance between two fragments = 1
Clone size = 5

Source file "algorithms/core.py" The first line is 2165 |  | Source file "algorithms/core.py" The first line is 2102
dprobs_factor = _np.where(probs < min_p, dprobs_factor_neg, dprobs_factor_pos) |  | dprobs_factor = _np.where(probs < min_p, dprobs_factor_neg, dprobs_factor_pos)
dprobs_factor = _np.where(minusCntVecMx == 0, 0.0, dprobs_factor) |  | dprobs_factor = _np.where(minusCntVecMx == 0, dprobs_factor_zerofreq, dprobs_factor)
jac = (dprobs) * (dprobs_factor[None:None,None:None,None]) |  | jac = (dprobs) * (dprobs_factor[None:None,None:None,None])
jac = jac.reshape([KM, vec_gs_len]) |  | jac = jac.reshape([KM, vec_gs_len])
return jac |  | return jac

Clone Digger is aimed to find software clones in Python and Java programs. It is provided under the GPL license and can be downloaded from the site http://clonedigger.sourceforge.net