CloneDigger Report

Source files: 16

Click here to show/hide file names

Source files:
objects/spamspec.py,
objects/gateset.py,
objects/dataset.py,
objects/gate.py,
objects/gigateset.py,
objects/confidenceregion.py,
objects/protectedarray.py,
objects/__init__.py,
objects/gatestring.py,
objects/gscalc.py,
objects/evaltree.py,
objects/verbosityprinter.py,
objects/multidataset.py,
objects/spamvec.py,
objects/exceptions.py,
objects/labeldicts.py

Clones detected: 53

605 of 4513 lines are duplicates (13.41%)

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 : 1.46 seconds
Building statement hash : 0.01 seconds
Building patterns : 3.56 seconds
Marking similar statements : 5.47 seconds
Finding similar sequences of statements : 0.51 seconds
Refining candidates : 0.50 seconds
Total time: 11.51
Started at: Mon Aug 1 06:56:08 2016
Finished at: Mon Aug 1 06:56:20 2016

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

Source file "objects/gscalc.py" The first line is 3501 |  | Source file "objects/gscalc.py" The first line is 3453
def diamonddist(self, otherCalc, transformMx=None): T = transformMx if T is not None: Ti = _nla.inv(T) dists = [_gt.diamonddist(_np.dot(Ti, _np.dot(self.gates[gateLabel], T)), otherCalc.gates[gateLabel]) for gateLabel in self.gates ] for spamLabel in self.spamdefs: spamGate = self._make_spamgate(spamLabel) spamGate2 = otherCalc._make_spamgate(spamLabel) if (spamGate is not None) and (spamGate2 is not None): dists.append(_gt.diamonddist(_np.dot(Ti, _np.dot(spamGate, T)), spamGate2)) else: dists = [_gt.diamonddist(self.gates[gateLabel], otherCalc.gates[gateLabel]) for gateLabel in self.gates ] for spamLabel in self.spamdefs: spamGate = self._make_spamgate(spamLabel) spamGate2 = otherCalc._make_spamgate(spamLabel) if (spamGate is not None) and (spamGate2 is not None): dists.append(_gt.diamonddist(spamGate, spamGate2)) return max(dists) |  | def jtracedist(self, otherCalc, transformMx=None): T = transformMx if T is not None: Ti = _nla.inv(T) dists = [_gt.jtracedist(_np.dot(Ti, _np.dot(self.gates[gateLabel], T)), otherCalc.gates[gateLabel]) for gateLabel in self.gates ] for spamLabel in self.spamdefs: spamGate = self._make_spamgate(spamLabel) spamGate2 = otherCalc._make_spamgate(spamLabel) if (spamGate is not None) and (spamGate2 is not None): dists.append(_gt.jtracedist(_np.dot(Ti, _np.dot(spamGate, T)), spamGate2)) else: dists = [_gt.jtracedist(self.gates[gateLabel], otherCalc.gates[gateLabel]) for gateLabel in self.gates ] for spamLabel in self.spamdefs: spamGate = self._make_spamgate(spamLabel) spamGate2 = otherCalc._make_spamgate(spamLabel) if (spamGate is not None) and (spamGate2 is not None): dists.append(_gt.jtracedist(spamGate, spamGate2)) return max(dists)

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

Source file "objects/gscalc.py" The first line is 2548 |  | Source file "objects/gscalc.py" The first line is 2339
remainder_row_index = None |  | remainder_row_index = None
for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex |  | for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex
if wrtFilter is not None: assert wrtBlockSize is None tot_rho = self.tot_rho_params tot_spam = (self.tot_rho_params) + (self.tot_e_params) wrtFilters = {'preps': [x for x in wrtFilter if x < tot_rho], 'effects': [(x) - (tot_rho) for x in wrtFilter if tot_rho <= x < tot_spam], 'gates': [(x) - (tot_spam) for x in wrtFilter if x >= tot_spam]} else: wrtFilters = None |  | if wrtFilter is not None: assert wrtBlockSize is None tot_rho = self.tot_rho_params tot_spam = (self.tot_rho_params) + (self.tot_e_params) wrtFilters = {'preps': [x for x in wrtFilter if x < tot_rho], 'effects': [(x) - (tot_rho) for x in wrtFilter if tot_rho <= x < tot_spam], 'gates': [(x) - (tot_spam) for x in wrtFilter if x >= tot_spam]} else: wrtFilters = None
subtrees = evalTree.get_sub_trees() |  | subtrees = evalTree.get_sub_trees()
mySubTreeIndices, subTreeOwners, mySubComm = self._distribute_indices(list(range(len(subtrees))), comm) |  | mySubTreeIndices, subTreeOwners, mySubComm = self._distribute_indices(list(range(len(subtrees))), comm)
my_results = [] |  | my_results = []

Clone # 3
Distance between two fragments = 3
Clone size = 18

Source file "objects/spamvec.py" The first line is 71 |  | Source file "objects/gate.py" The first line is 189
def get_dimension(self): return self.dim |  | def get_dimension(self): return self.dim
def __setstate__(self, state): self.__dict__.update(state) |  | def __setstate__(self, state): self.__dict__.update(state)
def __getitem__(self, key): return self.base.__getitem__(key) |  | def __getitem__(self, key): return self.base.__getitem__(key)
def __getslice__(self, i, j): return self.__getitem__(slice(i, j)) |  | def __getslice__(self, i, j): return self.__getitem__(slice(i, j))
def __setitem__(self, key, val): return self.base.__setitem__(key, val) |  | def __setitem__(self, key, val): return self.base.__setitem__(key, val)
def __getattr__(self, attr): ret = getattr(self.__dict__['base'], attr) if self.base.shape != (self.dim, 1): raise ValueError('Cannot change dimension of Vector') return ret |  | def __getattr__(self, attr): ret = getattr(self.__dict__['base'], attr) if self.base.shape != (self.dim, self.dim): raise ValueError('Cannot change shape of Gate') return ret
def __pos__(self): return self.base |  | def __pos__(self): return self.base
def __neg__(self): return -self.base |  | def __neg__(self): return -self.base
def __abs__(self): return abs(self.base) |  | def __abs__(self): return abs(self.base)

Clone # 4
Distance between two fragments = 4
Clone size = 13

Source file "objects/gate.py" The first line is 732 |  | Source file "objects/gate.py" The first line is 391
def copy(self): return TPParameterizedGate(self.base) |  | def copy(self): return StaticGate(self.base)
def transform(self, S, Si): self.set_matrix(_np.dot(Si, _np.dot(self.base, S))) |  | def transform(self, S, Si): self.set_matrix(_np.dot(Si, _np.dot(self.base, S)))
def compose(self, otherGate): assert isinstance(otherGate, TPParameterizedGate) return TPParameterizedGate(_np.dot(self.base, otherGate)) |  | def compose(self, otherGate): assert isinstance(otherGate, StaticGate) return StaticGate(_np.dot(self.base, otherGate.base))
def __str__(self): s = ('TP Parameterized gate with shape %s\n') % (str(self.base.shape)) s += _mt.mx_to_string(self.base, width=4, prec=2) return s |  | def __str__(self): s = ('Static gate with shape %s\n') % (str(self.base.shape)) s += _mt.mx_to_string(self.base, width=4, prec=2) return s
def __reduce__(self): return (TPParameterizedGate, (_np.identity(self.dim, 'd')), self.__dict__) |  | def __reduce__(self): return (StaticGate, (_np.identity(self.dim, 'd')), self.__dict__)

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

Source file "objects/gscalc.py" The first line is 1236 |  | Source file "objects/gscalc.py" The first line is 1372
if comm.Get_size() > nGateDerivCols: if evalTree.is_split(): raise NotImplementedError('Need to finish implementing this case!') '\n subtrees = evalTree.get_sub_trees()\n allSubTreeIndices = list(range(len(subtrees)))\n mySubTreeIndices, subTreeOwners, mySubComm = self._distribute_indices(allSubTreeIndices, comm)\n #split *many* procs among a smaller number of indices, assigning the\n # same index list to multiple procs and making a "myComm" group for them.\n\n assert(wrtFilter is None) # sub-tree division occurs *before* wrtFilter division\n my_results = [ self._compute_dproduct_cache(\n subtrees[iSubTree],prodCache,scaleCache, myComm)\n for iSubTree in mySubTreeIndices ]\n\n psd = (1,nGateDerivCols,dim,dim) # per string dimension of dProdCache\n return self._gather_multiple_subtree_results(\n evalTree, subTreeOwners, mySubTreeIndices, my_results,\n None, psd, myComm, comm) #this fn needs to gather tree results\n # only from the *root* processors of each myComm group... then broadcast?\n ' else: _warnings.warn(((('Increased speed could be obtained') + (' by giving dproduct cache computation')) + (' a *split* tree, as there are more cpus')) + (' than derivative columns.')) |  | if comm.Get_size() > nGateDerivCols2: if evalTree.is_split(): raise NotImplementedError('Need to finish implementing this case!') '\n\n subtrees = evalTree.get_sub_trees()\n allSubTreeIndices = list(range(len(subtrees)))\n mySubTreeIndices, subTreeOwners, mySubComm = self._distribute_indices_multiple(allSubTreeIndices, comm)\n #split *many* procs among a smaller number of indices, assigning the\n # same index list to multiple procs and making a "myComm" group for them.\n\n assert(wrtFilter is None) # sub-tree division occurs *before* wrtFilter division\n my_results = [ self._compute_hproduct_cache(\n subtrees[iSubTree],prodCache,dProdCache,scaleCache,myComm)\n for iSubTree in mySubTreeIndices ]\n\n psd = (1,nGateDerivCols,dim,dim) # per string dimension of dProdCache\n return self._gather_multiple_subtree_results(\n evalTree, subTreeOwners, mySubTreeIndices, my_results,\n None, psd, myComm, comm) #this fn needs to gather tree results\n # only from the *root* processors of each myComm group... then broadcast?\n\n ' else: _warnings.warn(((('Increased speed could be obtained') + (' by giving hproduct cache computation')) + (' a *split* tree, as there are more cpus')) + (' than derivative columns.'))
allDerivColIndices = list(range(nGateDerivCols)) if (wrtFilter is None) else wrtFilter |  | allDeriv2ColIndices = list(range(nGateDerivCols2)) if (wrtFilter is None) else wrtFilter
myDerivColIndices, _, mySubComm = self._distribute_indices(allDerivColIndices, comm) |  | myDerivColIndices, _, mySubComm = self._distribute_indices(allDeriv2ColIndices, comm)

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

Source file "objects/multidataset.py" The first line is 170 |  | Source file "objects/dataset.py" The first line is 246
def __contains__(self, datasetName): return datasetName in self.countsDict |  | def __contains__(self, gatestring): return gatestring in self.gsIndex
def keys(self): return list(self.countsDict.keys()) |  | def keys(self): return list(self.gsIndex.keys())
def has_key(self, datasetName): return datasetName in self.countsDict |  | def has_key(self, gatestring): return gatestring in self.gsIndex
def iteritems(self): return MultiDataSet_KeyValIterator(self) |  | def iteritems(self): return DataSet_KeyValIterator(self)
def itervalues(self): return MultiDataSet_ValIterator(self) |  | def itervalues(self): return DataSet_ValIterator(self)

Clone # 7
Distance between two fragments = 4
Clone size = 10

Source file "objects/confidenceregion.py" The first line is 567 |  | Source file "objects/confidenceregion.py" The first line is 555
for ELabel, EVec in self.gateset.effects.items(): nEParams = EVec.num_params() off = self.gateset_offsets[ELabel][0] vec = EVec.to_vector() for i in range(nEParams): vecEps = vec.copy() vecEps[i] += eps gsEps.effects[ELabel].from_vector(vecEps) gradF[(off) + (i)] = ((fnOfSpamVecs(gsEps.get_preps(), gsEps.get_effects())) - (f0)) / (eps) gsEps.effects[ELabel] = EVec.copy() |  | for prepLabel, rhoVec in self.gateset.preps.items(): nRhoParams = rhoVec.num_params() off = self.gateset_offsets[prepLabel][0] vec = rhoVec.to_vector() for i in range(nRhoParams): vecEps = vec.copy() vecEps[i] += eps gsEps.preps[prepLabel].from_vector(vecEps) gradF[(off) + (i)] = ((fnOfSpamVecs(gsEps.get_preps(), gsEps.get_effects())) - (f0)) / (eps) gsEps.preps[prepLabel] = rhoVec.copy()

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

Source file "objects/spamvec.py" The first line is 174 |  | Source file "objects/spamvec.py" The first line is 298
def __init__(self, vec): SPAMVec.__init__(self, SPAMVec.convert_to_vector(vec)) |  | def __init__(self, vec): SPAMVec.__init__(self, SPAMVec.convert_to_vector(vec))
def set_vector(self, vec): vec = SPAMVec.convert_to_vector(vec) if vec.size != self.dim: raise ValueError(('Argument must be length %d') % (self.dim)) self.base[None:None,None:None] = vec |  | def set_vector(self, vec): vec = SPAMVec.convert_to_vector(vec) if vec.size != self.dim: raise ValueError(('Argument must be length %d') % (self.dim)) self.base[None:None,None:None] = vec
def num_params(self): return 0 |  | def num_params(self): return self.dim

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

Source file "objects/gscalc.py" The first line is 729 |  | Source file "objects/gscalc.py" The first line is 603
derivWrtAnyEvec = (scale) * (_np.transpose(_np.dot(prod, rho))) |  | derivWrtAnyEvec = (scale) * (_np.transpose(_np.dot(prod, rho)))
if elabel == self._remainderLabel: assert self._remainderLabel not in self.effects for ei, evec in enumerate(self.effects.values()): dpr_dEs[0,e_offset[ei]:e_offset[(ei) + (1)]] = (-1.0) * (_np.dot(derivWrtAnyEvec, evec.deriv_wrt_params())) else: eIndex = list(self.effects.keys()).index(elabel) dpr_dEs[0,e_offset[eIndex]:e_offset[(eIndex) + (1)]] = _np.dot(derivWrtAnyEvec, self.effects[elabel].deriv_wrt_params()) |  | if elabel == self._remainderLabel: assert self._remainderLabel not in self.effects for ei, evec in enumerate(self.effects.values()): dpr_dEs[0,e_offset[ei]:e_offset[(ei) + (1)]] = (-1.0) * (_np.dot(derivWrtAnyEvec, evec.deriv_wrt_params())) else: eIndex = list(self.effects.keys()).index(elabel) dpr_dEs[0,e_offset[eIndex]:e_offset[(eIndex) + (1)]] = _np.dot(derivWrtAnyEvec, self.effects[elabel].deriv_wrt_params())

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

Source file "objects/spamvec.py" The first line is 387 |  | Source file "objects/spamvec.py" The first line is 267
def copy(self): return FullyParameterizedSPAMVec(self.base) |  | def copy(self): return StaticSPAMVec(self.base)
def __str__(self): s = ('Fully Parameterized spam vector with length %d\n') % (len(self.base)) s += _mt.mx_to_string(self.base, width=4, prec=2) return s |  | def __str__(self): s = ('Static spam vector with length %d\n') % (len(self.base)) s += _mt.mx_to_string(self.base, width=4, prec=2) return s
def __reduce__(self): return (FullyParameterizedSPAMVec, (_np.empty((self.dim, 1), 'd')), self.__dict__) |  | def __reduce__(self): return (StaticSPAMVec, (_np.empty((self.dim, 1), 'd')), self.__dict__)

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

Source file "objects/gate.py" The first line is 310 |  | Source file "objects/gate.py" The first line is 472
def set_matrix(self, M): mx = Gate.convert_to_matrix(M) if mx.shape != (self.dim, self.dim): raise ValueError(('Argument must be a (%d,%d) matrix!') % ((self.dim, self.dim))) self.base[None:None,None:None] = _np.array(mx) |  | def set_matrix(self, M): mx = Gate.convert_to_matrix(M) if mx.shape != (self.dim, self.dim): raise ValueError(('Argument must be a (%d,%d) matrix!') % ((self.dim, self.dim))) self.base[None:None,None:None] = _np.array(mx)
def num_params(self): return 0 |  | def num_params(self): return (self.dim) ** (2)

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

Source file "objects/gateset.py" The first line is 2489 |  | Source file "objects/gateset.py" The first line is 2548
curDim = self.get_dimension() |  | curDim = self.get_dimension()
assert newDimension > curDim |  | assert newDimension < curDim
new_gateset = GateSet('full', self.preps._prefix, self.effects._prefix, self.gates._prefix, self._remainderlabel, self._identitylabel) |  | new_gateset = GateSet('full', self.preps._prefix, self.effects._prefix, self.gates._prefix, self._remainderlabel, self._identitylabel)
new_gateset._dim = newDimension |  | new_gateset._dim = newDimension
new_gateset.reset_basis() |  | new_gateset.reset_basis()
new_gateset.spamdefs.update(self.spamdefs) |  | new_gateset.spamdefs.update(self.spamdefs)

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

Source file "objects/gigateset.py" The first line is 453 |  | Source file "objects/gigateset.py" The first line is 386
rho_tilde = rho_tilde.flatten() |  | rho_tilde = rho_tilde.flatten()
E_tilde = E_tilde.flatten() |  | E_tilde = E_tilde.flatten()
inv_delta0_diag = _np.empty(len(rho_tilde), 'complex') |  | inv_delta0_diag = _np.empty(len(rho_tilde), 'complex')
printer = VerbosityPrinter.build_printer(verbosity) |  | printer = VerbosityPrinter.build_printer(verbosity)
printer.log('Finding delta0', 4) |  | printer.log('Finding delta0', 4)
printer.log((' rho-tilde = %s') % (_mt.mx_to_string(rho_tilde)), 4) |  | printer.log((' rho-tilde = %s') % (_mt.mx_to_string(rho_tilde)), 4)
printer.log((' E-tilde = %s') % (_mt.mx_to_string(E_tilde)), 4) |  | printer.log((' E-tilde = %s') % (_mt.mx_to_string(E_tilde)), 4)
printer.log((' D0-params = %s') % (_mt.mx_to_string(D0_params)), 4) |  | printer.log((' D0-params = %s') % (_mt.mx_to_string(D0_params)), 4)

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

Source file "objects/gscalc.py" The first line is 2665 |  | Source file "objects/gscalc.py" The first line is 2449
all_blk_results = self._gather_blk_results(nBlks, blkOwners, myBlkIndices, blk_results, mySubComm) |  | all_blk_results = self._gather_blk_results(nBlks, blkOwners, myBlkIndices, blk_results, mySubComm)
for spamLabel in sub_results: to_concat = ([sub_results[spamLabel][2]]) + ([blk[spamLabel][2] for blk in all_blk_results ]) sub_results[spamLabel] = list(sub_results[spamLabel]) sub_results[spamLabel][2] = _np.concatenate(to_concat, axis=2) sub_results[spamLabel] = tuple(sub_results[spamLabel]) |  | for spamLabel in sub_results: to_concat = ([sub_results[spamLabel][1]]) + ([blk[spamLabel][1] for blk in all_blk_results ]) sub_results[spamLabel] = list(sub_results[spamLabel]) sub_results[spamLabel][1] = _np.concatenate(to_concat, axis=1) sub_results[spamLabel] = tuple(sub_results[spamLabel])

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

Source file "objects/gscalc.py" The first line is 2409 |  | Source file "objects/gscalc.py" The first line is 2623
assert wrtFilter is None |  | assert wrtFilter is None
nBlks = (self.tot_gate_params) // (blkSize) |  | nBlks = (self.tot_gate_params) // (blkSize)
blocks = [list(range((blkSize) * (i), (blkSize) * ((i) + (1)))) for i in range(nBlks) ] |  | blocks = [list(range((blkSize) * (i), (blkSize) * ((i) + (1)))) for i in range(nBlks) ]
if (blkSize) * (nBlks) < self.tot_gate_params: blocks.append(list(range((blkSize) * (nBlks), self.tot_gate_params))) nBlks += 1 |  | if (blkSize) * (nBlks) < self.tot_gate_params: blocks.append(list(range((blkSize) * (nBlks), self.tot_gate_params))) nBlks += 1

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

Source file "objects/gscalc.py" The first line is 2388 |  | Source file "objects/gscalc.py" The first line is 2602
if wrtFilter is None: blkSize = wrtBlockSize #could be None if (mySubComm is not None) and (mySubComm.Get_size() > 1): comm_blkSize = self.tot_gate_params // mySubComm.Get_size() blkSize = comm_blkSize if (blkSize is None) \ else min(comm_blkSize, blkSize) #override with smaller comm_blkSize else: blkSize = None # wrtFilter dictates block |  | if wrtFilter is None: blkSize = wrtBlockSize #could be None if (mySubComm is not None) and (mySubComm.Get_size() > 1): comm_blkSize = self.tot_gate_params // mySubComm.Get_size() blkSize = comm_blkSize if (blkSize is None) \ else min(comm_blkSize, blkSize) #override with smaller comm_blkSize else: blkSize = None # wrtFilter dictates block

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

Source file "objects/gscalc.py" The first line is 1485 |  | Source file "objects/gscalc.py" The first line is 1335
scale = (scaleCache[i]) - ((scaleCache[iLeft]) + (scaleCache[iRight])) |  | scale = (scaleCache[i]) - ((scaleCache[iLeft]) + (scaleCache[iRight]))
if not _np.isclose(scale, 0): hProdCache[i] /= _np.exp(scale) if (hProdCache[i].max() < HSMALL) and (hProdCache[i].min() > -HSMALL): _warnings.warn('Scaled hProd small in order to keep prod managable.') elif (_np.count_nonzero(hProdCache[i])) and (hProdCache[i].max() < HSMALL) and (hProdCache[i].min() > -HSMALL): _warnings.warn('hProd is small (oh well!).') |  | if not _np.isclose(scale, 0): dProdCache[i] /= _np.exp(scale) if (dProdCache[i].max() < DSMALL) and (dProdCache[i].min() > -DSMALL): _warnings.warn('Scaled dProd small in order to keep prod managable.') elif (_np.count_nonzero(dProdCache[i])) and (dProdCache[i].max() < DSMALL) and (dProdCache[i].min() > -DSMALL): _warnings.warn('Would have scaled dProd but now will not alter scaleCache.')

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

Source file "objects/gscalc.py" The first line is 2219 |  | Source file "objects/gscalc.py" The first line is 3192
remainder_row_index = None |  | remainder_row_index = None
for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex |  | for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex
subtrees = evalTree.get_sub_trees() |  | nGateStrings = evalTree.num_final_strings()

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

Source file "objects/dataset.py" The first line is 601 |  | Source file "objects/multidataset.py" The first line is 349
bOpen = not hasattr(fileOrFilename, 'write') |  | bOpen = not hasattr(fileOrFilename, 'write')
if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'rb') else: f = open(fileOrFilename, 'rb') else: f = fileOrFilename |  | if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'rb') else: f = open(fileOrFilename, 'rb') else: f = fileOrFilename
state_dict = _pickle.load(f) |  | state_dict = _pickle.load(f)

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

Source file "objects/dataset.py" The first line is 568 |  | Source file "objects/multidataset.py" The first line is 322
bOpen = not hasattr(fileOrFilename, 'write') |  | bOpen = not hasattr(fileOrFilename, 'write')
if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'wb') else: f = open(fileOrFilename, 'wb') else: f = fileOrFilename |  | if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'wb') else: f = open(fileOrFilename, 'wb') else: f = fileOrFilename
_pickle.dump(toPickle, f) |  | _pickle.dump(toPickle, f)

Clone # 21
Distance between two fragments = 4
Clone size = 6

Source file "objects/gscalc.py" The first line is 3020 |  | Source file "objects/gscalc.py" The first line is 3103
vdp = _np.empty( (1,nGateStrings,nDerivCols), 'd' ) \ if returnDeriv else None |  | vdp = _np.empty( (nSpamLabels,nGateStrings,nDerivCols), 'd' ) \ if returnDeriv else None
vp = _np.empty( (1,nGateStrings), 'd' ) if returnPr else None |  | vp = _np.empty( (nSpamLabels,nGateStrings), 'd' ) if returnPr else None
self.bulk_fill_hprobs(vhp, {spamLabel: 0}, evalTree, vp, vdp, clipTo, check, comm, wrtFilter, wrtBlockSize) |  | self.bulk_fill_hprobs(vhp, spam_label_rows, evalTree, vp, vdp, clipTo, check, comm, wrtFilter, wrtBlockSize)

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

Source file "objects/gscalc.py" The first line is 1811 |  | Source file "objects/gscalc.py" The first line is 1659
hGs = hProdCache.take(finalIndxList, axis=0) |  | dGs = dProdCache.take(finalIndxList, axis=0)
if not bScale: old_err = _np.seterr(over='ignore', invalid='ignore') hGs = _np.swapaxes((_np.swapaxes(hGs, 0, 4)) * (scaleVals), 0, 4) hGs[_np.isnan(hGs)] = 0 _np.seterr(, **old_err) |  | if not bScale: old_err = _np.seterr(over='ignore', invalid='ignore') dGs = _np.swapaxes((_np.swapaxes(dGs, 0, 3)) * (scaleVals), 0, 3) dGs[_np.isnan(dGs)] = 0 _np.seterr(, **old_err)

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

Source file "objects/gate.py" The first line is 332 |  | Source file "objects/spamvec.py" The first line is 209
def num_params(self): return 0 |  | def num_params(self): return 0
def to_vector(self): return _np.array([], 'd') |  | def to_vector(self): return _np.array([], 'd')
def from_vector(self, v): assert len(v) == 0 |  | def from_vector(self, v): assert len(v) == 0

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

Source file "objects/labeldicts.py" The first line is 126 |  | Source file "objects/gate.py" The first line is 265
try: d1 = len(M) d2 = len(M[0]) except: raise ValueError(("%s doesn't look like a 2D array/list") % (M)) |  | try: dim = len(M) d2 = len(M[0]) except: raise ValueError(("%s doesn't look like a 2D array/list") % (M))
if any([len(row) != d1 for row in M ]): raise ValueError(('%s is not a *square* 2D array') % (M)) |  | if any([len(row) != dim for row in M ]): raise ValueError(('%s is not a *square* 2D array') % (M))

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

Source file "objects/gscalc.py" The first line is 2548 |  | Source file "objects/gscalc.py" The first line is 3192
remainder_row_index = None |  | remainder_row_index = None
for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex |  | for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex

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

Source file "objects/gscalc.py" The first line is 2548 |  | Source file "objects/gscalc.py" The first line is 2219
remainder_row_index = None |  | remainder_row_index = None
for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex |  | for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex

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

Source file "objects/gscalc.py" The first line is 2339 |  | Source file "objects/gscalc.py" The first line is 3192
remainder_row_index = None |  | remainder_row_index = None
for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex |  | for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex

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

Source file "objects/gscalc.py" The first line is 2339 |  | Source file "objects/gscalc.py" The first line is 2219
remainder_row_index = None |  | remainder_row_index = None
for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex |  | for spamLabel, rowIndex in spam_label_rows.items(): if self._is_remainder_spamlabel(spamLabel): assert self.assumeSumToOne assert remainder_row_index is None remainder_row_index = rowIndex

Clone # 29
Distance between two fragments = 3
Clone size = 6

Source file "objects/confidenceregion.py" The first line is 367 |  | Source file "objects/confidenceregion.py" The first line is 306
nPrepParams = prepObj.num_params() |  | nGateParams = gateObj.num_params()
prepVec0 = prepObj.to_vector() |  | gateVec0 = gateObj.to_vector()
if type(f0) == float: gradF = _np.zeros(nParams, 'd') else: gradSize = ((nParams)) + (tuple(f0.shape)) gradF = _np.zeros(gradSize, f0.dtype) |  | if type(f0) == float: gradF = _np.zeros(nParams, 'd') else: gradSize = ((nParams)) + (tuple(f0.shape)) gradF = _np.zeros(gradSize, f0.dtype)

Clone # 30
Distance between two fragments = 3
Clone size = 6

Source file "objects/confidenceregion.py" The first line is 433 |  | Source file "objects/confidenceregion.py" The first line is 367
nEffectParams = effectObj.num_params() |  | nPrepParams = prepObj.num_params()
effectVec0 = effectObj.to_vector() |  | prepVec0 = prepObj.to_vector()
if type(f0) == float: gradF = _np.zeros(nParams, 'd') else: gradSize = ((nParams)) + (tuple(f0.shape)) gradF = _np.zeros(gradSize, f0.dtype) |  | if type(f0) == float: gradF = _np.zeros(nParams, 'd') else: gradSize = ((nParams)) + (tuple(f0.shape)) gradF = _np.zeros(gradSize, f0.dtype)

Clone # 31
Distance between two fragments = 3
Clone size = 6

Source file "objects/confidenceregion.py" The first line is 433 |  | Source file "objects/confidenceregion.py" The first line is 306
nEffectParams = effectObj.num_params() |  | nGateParams = gateObj.num_params()
effectVec0 = effectObj.to_vector() |  | gateVec0 = gateObj.to_vector()
if type(f0) == float: gradF = _np.zeros(nParams, 'd') else: gradSize = ((nParams)) + (tuple(f0.shape)) gradF = _np.zeros(gradSize, f0.dtype) |  | if type(f0) == float: gradF = _np.zeros(nParams, 'd') else: gradSize = ((nParams)) + (tuple(f0.shape)) gradF = _np.zeros(gradSize, f0.dtype)

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

Source file "objects/multidataset.py" The first line is 349 |  | Source file "objects/multidataset.py" The first line is 322
bOpen = not hasattr(fileOrFilename, 'write') |  | bOpen = not hasattr(fileOrFilename, 'write')
if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'rb') else: f = open(fileOrFilename, 'rb') else: f = fileOrFilename |  | if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'wb') else: f = open(fileOrFilename, 'wb') else: f = fileOrFilename

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

Source file "objects/multidataset.py" The first line is 349 |  | Source file "objects/dataset.py" The first line is 568
bOpen = not hasattr(fileOrFilename, 'write') |  | bOpen = not hasattr(fileOrFilename, 'write')
if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'rb') else: f = open(fileOrFilename, 'rb') else: f = fileOrFilename |  | if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'wb') else: f = open(fileOrFilename, 'wb') else: f = fileOrFilename

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

Source file "objects/dataset.py" The first line is 601 |  | Source file "objects/multidataset.py" The first line is 322
bOpen = not hasattr(fileOrFilename, 'write') |  | bOpen = not hasattr(fileOrFilename, 'write')
if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'rb') else: f = open(fileOrFilename, 'rb') else: f = fileOrFilename |  | if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'wb') else: f = open(fileOrFilename, 'wb') else: f = fileOrFilename

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

Source file "objects/dataset.py" The first line is 601 |  | Source file "objects/dataset.py" The first line is 568
bOpen = not hasattr(fileOrFilename, 'write') |  | bOpen = not hasattr(fileOrFilename, 'write')
if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'rb') else: f = open(fileOrFilename, 'rb') else: f = fileOrFilename |  | if bOpen: if fileOrFilename.endswith('.gz'): import gzip as _gzip f = _gzip.open(fileOrFilename, 'wb') else: f = open(fileOrFilename, 'wb') else: f = fileOrFilename

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

Source file "objects/gscalc.py" The first line is 2921 |  | Source file "objects/gscalc.py" The first line is 2847
vdp = _np.empty((nSpamLabels, nGateStrings, nDerivCols), 'd') |  | vdp = _np.empty((1, nGateStrings, nDerivCols), 'd')
vp = _np.empty( (nSpamLabels,nGateStrings), 'd' ) if returnPr else None |  | vp = _np.empty( (1,nGateStrings), 'd' ) if returnPr else None
self.bulk_fill_dprobs(vdp, spam_label_rows, evalTree, vp, clipTo, check, comm, wrtFilter, wrtBlockSize) |  | self.bulk_fill_dprobs(vdp, {spamLabel: 0}, evalTree, vp, clipTo, check, comm, wrtFilter, wrtBlockSize)

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

Source file "objects/gscalc.py" The first line is 2423 |  | Source file "objects/gscalc.py" The first line is 2640
sub_results = self._compute_sub_result(spam_label_rows, calc_from_spamlabel) |  | sub_results = self._compute_sub_result(spam_label_rows, calc_from_spamlabel)
myBlkIndices, blkOwners, blkComm = self._distribute_indices(list(range(nBlks)), mySubComm) |  | myBlkIndices, blkOwners, blkComm = self._distribute_indices(list(range(nBlks)), mySubComm)
if blkComm is not None: _warnings.warn('Note: more CPUs than derivative columns!') |  | if blkComm is not None: _warnings.warn('Note: more CPUs than derivative columns!')

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

Source file "objects/gatestring.py" The first line is 131 |  | Source file "objects/gatestring.py" The first line is 99
assert len(gateLabels) < 26 |  | assert len(gateLabels) < 26
translateDict = {} |  | translateDict = {}
c = 'A' |  | c = 'A'
for gateLabel in gateLabels: translateDict[c] = gateLabel c = chr((ord(c)) + (1)) |  | for gateLabel in gateLabels: translateDict[gateLabel] = c c = chr((ord(c)) + (1))

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

Source file "objects/spamvec.py" The first line is 120 |  | Source file "objects/gate.py" The first line is 239
def __len__(self): return len(self.base) |  | def __len__(self): return len(self.base)
def __int__(self): return int(self.base) |  | def __int__(self): return int(self.base)
def __long__(self): return int(self.base) |  | def __long__(self): return int(self.base)
def __float__(self): return float(self.base) |  | def __float__(self): return float(self.base)
def __complex__(self): return complex(self.base) |  | def __complex__(self): return complex(self.base)

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

Source file "objects/spamvec.py" The first line is 120 |  | Source file "objects/protectedarray.py" The first line is 55
def __len__(self): return len(self.base) |  | def __len__(self): return len(self.base)
def __int__(self): return int(self.base) |  | def __int__(self): return int(self.base)
def __long__(self): return int(self.base) |  | def __long__(self): return int(self.base)
def __float__(self): return float(self.base) |  | def __float__(self): return float(self.base)
def __complex__(self): return complex(self.base) |  | def __complex__(self): return complex(self.base)

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

Source file "objects/gate.py" The first line is 239 |  | Source file "objects/protectedarray.py" The first line is 55
def __len__(self): return len(self.base) |  | def __len__(self): return len(self.base)
def __int__(self): return int(self.base) |  | def __int__(self): return int(self.base)
def __long__(self): return int(self.base) |  | def __long__(self): return int(self.base)
def __float__(self): return float(self.base) |  | def __float__(self): return float(self.base)
def __complex__(self): return complex(self.base) |  | def __complex__(self): return complex(self.base)

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

Source file "objects/gscalc.py" The first line is 3118 |  | Source file "objects/gscalc.py" The first line is 2928
if returnPr: return { spamLabel: (vhp[i],vp[i]) \ for (i,spamLabel) in enumerate(self.spamdefs) } else: return { spamLabel: vhp[i] \ for (i,spamLabel) in enumerate(self.spamdefs) } |  | if returnPr: return { spamLabel: (vdp[i],vp[i]) \ for (i,spamLabel) in enumerate(self.spamdefs) } else: return { spamLabel: vdp[i] \ for (i,spamLabel) in enumerate(self.spamdefs) }

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

Source file "objects/gscalc.py" The first line is 2915 |  | Source file "objects/gscalc.py" The first line is 3096
spam_label_rows = \ { spamLabel: i for (i,spamLabel) in enumerate(self.spamdefs) } |  | spam_label_rows = \ { spamLabel: i for (i,spamLabel) in enumerate(self.spamdefs) }
nGateStrings = evalTree.num_final_strings() |  | nGateStrings = evalTree.num_final_strings()
nDerivCols = self.tot_params |  | nDerivCols = self.tot_params
nSpamLabels = len(self.spamdefs) |  | nSpamLabels = len(self.spamdefs)

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

Source file "objects/multidataset.py" The first line is 19 |  | Source file "objects/multidataset.py" The first line is 36
def __init__(self, multidataset): self.multidataset = multidataset self.countsDictIter = multidataset.countsDict.__iter__() |  | def __init__(self, multidataset): self.multidataset = multidataset self.countsDictIter = multidataset.countsDict.__iter__()
def __iter__(self): return self |  | def __iter__(self): return self

Clone # 45
Distance between two fragments = 3
Clone size = 5

Source file "objects/multidataset.py" The first line is 19 |  | Source file "objects/dataset.py" The first line is 37
def __init__(self, multidataset): self.multidataset = multidataset self.countsDictIter = multidataset.countsDict.__iter__() |  | def __init__(self, dataset): self.dataset = dataset self.countIter = dataset.counts.__iter__()
def __iter__(self): return self |  | def __iter__(self): return self

Clone # 46
Distance between two fragments = 3
Clone size = 5

Source file "objects/multidataset.py" The first line is 36 |  | Source file "objects/dataset.py" The first line is 37
def __init__(self, multidataset): self.multidataset = multidataset self.countsDictIter = multidataset.countsDict.__iter__() |  | def __init__(self, dataset): self.dataset = dataset self.countIter = dataset.counts.__iter__()
def __iter__(self): return self |  | def __iter__(self): return self

Clone # 47
Distance between two fragments = 3
Clone size = 5

Source file "objects/gscalc.py" The first line is 2095 |  | Source file "objects/gscalc.py" The first line is 2085
if _nla.norm((hprMxToFill[rowIndex]) - (check_vhp)) > 1e-06: _warnings.warn(('norm(vhp-check_vhp) = %g - %g = %g') % ((_nla.norm(hprMxToFill[rowIndex]), _nla.norm(check_vhp), _nla.norm((hprMxToFill[rowIndex]) - (check_vhp))))) |  | if _nla.norm((dprMxToFill[rowIndex]) - (check_vdp)) > 1e-06: _warnings.warn(('norm(vdp-check_vdp) = %g - %g = %g') % ((_nla.norm(dprMxToFill[rowIndex]), _nla.norm(check_vdp), _nla.norm((dprMxToFill[rowIndex]) - (check_vdp)))))

Clone # 48
Distance between two fragments = 3
Clone size = 5

Source file "objects/gscalc.py" The first line is 2095 |  | Source file "objects/gscalc.py" The first line is 2072
if _nla.norm((hprMxToFill[rowIndex]) - (check_vhp)) > 1e-06: _warnings.warn(('norm(vhp-check_vhp) = %g - %g = %g') % ((_nla.norm(hprMxToFill[rowIndex]), _nla.norm(check_vhp), _nla.norm((hprMxToFill[rowIndex]) - (check_vhp))))) |  | if _nla.norm((prMxToFill[rowIndex]) - (check_vp)) > 1e-06: _warnings.warn(('norm(vp-check_vp) = %g - %g = %g') % ((_nla.norm(prMxToFill[rowIndex]), _nla.norm(check_vp), _nla.norm((prMxToFill[rowIndex]) - (check_vp)))))

Clone # 49
Distance between two fragments = 3
Clone size = 5

Source file "objects/gscalc.py" The first line is 2085 |  | Source file "objects/gscalc.py" The first line is 2072
if _nla.norm((dprMxToFill[rowIndex]) - (check_vdp)) > 1e-06: _warnings.warn(('norm(vdp-check_vdp) = %g - %g = %g') % ((_nla.norm(dprMxToFill[rowIndex]), _nla.norm(check_vdp), _nla.norm((dprMxToFill[rowIndex]) - (check_vdp))))) |  | if _nla.norm((prMxToFill[rowIndex]) - (check_vp)) > 1e-06: _warnings.warn(('norm(vp-check_vp) = %g - %g = %g') % ((_nla.norm(prMxToFill[rowIndex]), _nla.norm(check_vp), _nla.norm((prMxToFill[rowIndex]) - (check_vp)))))

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

Source file "objects/gscalc.py" The first line is 1783 |  | Source file "objects/gscalc.py" The first line is 1628
finalIndxList = evalTree.get_list_of_final_value_tree_indices() |  | finalIndxList = evalTree.get_list_of_final_value_tree_indices()
old_err = _np.seterr(over='ignore') |  | old_err = _np.seterr(over='ignore')
scaleExps = scaleCache.take(finalIndxList) |  | scaleExps = scaleCache.take(finalIndxList)
scaleVals = _np.exp(scaleExps) |  | scaleVals = _np.exp(scaleExps)
_np.seterr(, **old_err) |  | _np.seterr(, **old_err)

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

Source file "objects/gscalc.py" The first line is 2366 |  | Source file "objects/gscalc.py" The first line is 2234
evalSubTree = subtrees[iSubTree] |  | evalSubTree = subtrees[iSubTree]
finalIndxList = evalSubTree.get_list_of_final_value_tree_indices() |  | finalIndxList = evalSubTree.get_list_of_final_value_tree_indices()
prodCache, scaleCache = self._compute_product_cache(evalSubTree, mySubComm) |  | prodCache, scaleCache = self._compute_product_cache(evalSubTree, mySubComm)
scaleVals = self._scaleExp(scaleCache.take(finalIndxList)) |  | scaleVals = self._scaleExp(scaleCache.take(finalIndxList))
Gs = prodCache.take(finalIndxList, axis=0) |  | Gs = prodCache.take(finalIndxList, axis=0)

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

Source file "objects/gateset.py" The first line is 2273 |  | Source file "objects/gateset.py" The first line is 2267
r = (max_spam_noise) * (rndm.random_sample(len(self.effects))) |  | r = (max_spam_noise) * (rndm.random_sample(len(self.preps)))
for i, lbl in enumerate(self.effects): D = _np.diag(([1]) + (([(1) - (r[i])]) * ((gateDim) - (1)))) newGateset.effects[lbl] = _sv.FullyParameterizedSPAMVec(_np.dot(D, self.effects[lbl])) |  | for i, lbl in enumerate(self.preps): D = _np.diag(([1]) + (([(1) - (r[i])]) * ((gateDim) - (1)))) newGateset.preps[lbl] = _sv.FullyParameterizedSPAMVec(_np.dot(D, self.preps[lbl]))

Clone # 53
Distance between two fragments = 4
Clone size = 6

Source file "objects/gscalc.py" The first line is 2679 |  | Source file "objects/gscalc.py" The first line is 2463
self._gather_subtree_results(evalTree, spam_label_rows, subTreeOwners, mySubTreeIndices, (prMxToFill, derivMxToFill, mxToFill), my_results, comm) |  | self._gather_subtree_results(evalTree, spam_label_rows, subTreeOwners, mySubTreeIndices, (prMxToFill, mxToFill), my_results, comm)
if (clipTo is not None) and (prMxToFill is not None): _np.clip(prMxToFill, clipTo[0], clipTo[1], out=prMxToFill) |  | if (clipTo is not None) and (prMxToFill is not None): _np.clip(prMxToFill, clipTo[0], clipTo[1], out=prMxToFill)

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