rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if not self.rl_history.is_at_start(): | if not self.rl_history.is_at_start: | def do_key_press_event(self, event): state = event.state & (gtk.gdk.CONTROL_MASK | gtk.gdk.MOD1_MASK | gtk.gdk.MOD4_MASK | gtk.gdk.SHIFT_MASK) if not state: if event.keyval == gtk.keysyms.F2: source = self.get_source_of_current_name() if source is not None: show_source_in_new_window(source, self.config.color_gtk_scheme... |
except XMLRPCError, e: self.interact.notify('Upload failed: %s' % (str(e), ) ) | except (XMLRPCError, socketerror), e: self.interact.notify('Upload failed: %s' % e) | def pastebin(self, s=None): """Upload to a pastebin and display the URL in the status bar.""" |
if not self.rl_history.is_at_end(): | if not self.rl_history.is_at_end: | def do_key_press_event(self, event): state = event.state & (gtk.gdk.CONTROL_MASK | gtk.gdk.MOD1_MASK | gtk.gdk.MOD4_MASK | gtk.gdk.SHIFT_MASK) if not state: if event.keyval == gtk.keysyms.F2: source = self.get_source_of_current_name() if source is not None: show_source_in_new_window(source, self.config.color_gtk_scheme... |
result += ' 62\n%s\n' % colors[l] | result += ' 62\n%s\n' % (int(colors[l]) + 1) | def process(self): '''Process the input data and return a string as output. |
d = ConnectDialog(self.myParent, connection_string) | d = ConnectDialog(self.myParent, str(TOPSerial)) | def connect_action(self, event): |
cs += + str(int(eval("self.option%s_value.get()" % n))) | cs += str(int(eval("self.option%s_value.get()" % n))) | def connect_action(self, event): |
iformat = __import__('totalopenstation.models.%s' % module, | imodel = __import__('totalopenstation.models.%s' % module, | def connect_action(self, event): |
mc = iformats.ModelConnector(chosen_port) | mc = imodel.ModelConnector(chosen_port) | def connect_action(self, event): |
policyFile = pexPolicy.DefaultPolicyFile("meas_pipeline", "WcsDeterminationStageDictionary.paf", "policy") self.defaultPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(), True) | self.defaultPolicy = pexPolicy.Policy.createPolicy(pexPolicy.PolicyString( """ inputExposureKey: visitExposure inputSourceSetKey: sourceSet allowDistortion: true matchThreshold: 22 blindSolve: false outputWcsKey: measuredWcs outputMatchListKey: matchList distanceForCatalogueMatchinArcsec: 1.0 cleaningParameter: 3 calcu... | def setUp(self): #Load the policy file policyFile = pexPolicy.DefaultPolicyFile("meas_pipeline", "WcsDeterminationStageDictionary.paf", "policy") self.defaultPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(), True) |
ok, version, reason = eupsObj.setup("astrometry_net_data", versionName="fergalDebug") | ok, version, reason = eupsObj.setup("astrometry_net_data", versionName="cfhtlsDeep") | def setUp(self): #Load the policy file policyFile = pexPolicy.DefaultPolicyFile("meas_pipeline", "WcsDeterminationStageDictionary.paf", "policy") self.defaultPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(), True) |
log.log(Log.INFO, 'Flag value %s: 0x%x, %i' % (flag, val, val)) log.log(Log.INFO, 'Good flag value: %i' % goodFlagValue) log.log(Log.INFO, "Number of sources: %d" % (len(sourceMatch))) | log.log(Log.DEBUG, 'Flag value %s: 0x%x, %i' % (flag, val, val)) log.log(Log.DEBUG, 'Good flag value: %i' % goodFlagValue) log.log(Log.DEBUG, "Number of sources: %d" % (len(sourceMatch))) | def calcPhotoCal(sourceMatch, log=None, goodFlagValue=(malgUtil.getDetectionFlags()['BINNED1'] | malgUtil.getDetectionFlags()['STAR'])): """Calculate photometric calibration, i.e the zero point magnitude""" if log is None: log = fakelog() if len(sourceMatch) == 0: raise ValueError("sourceMatch contains no elements") ... |
log.log(Log.INFO, "In determineWcs") | log.log(Log.DEBUG, "In determineWcs") | def determineWcs(policy, exposure, sourceSet, log=None, solver=None, doTrim=False, forceImageSize=None): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. In... |
metaFile = os.path.join(eups.productDir("astrometry_net_data"), "short.paf") | metaFile = os.path.join(eups.productDir("astrometry_net_data"), "metadata.paf") | def setUp(self): #Load sample input from disk path = os.path.join(eups.productDir("meas_astrom"), "examples") self.exposure = afwImg.ExposureF(os.path.join(path, "v695833-e0-c000-a00.sci")) #Set the filter properties. afwImg.Filter.reset() afwImg.FilterProperty.reset() #Both of these are required to reset fp = afwImg... |
print 'Number of matches:', len(matchList) ids = set([sm.second.getId() for sm in matchList]) print 'Number of unique ids:', len(ids) | uniq = set([sm.second.getId() for sm in matchList]) if len(matchList) != len(uniq): log.log(Log.WARN, "The list of matches stars contains duplicated reference sources (%i sources, %i unique ids)" % (len(matchList), len(uniq))) | def determineWcs(policy, exposure, sourceSet, log=None, solver=None, doTrim=False, forceImageSize=None): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. In... |
"""Increase the xAstrom value in a Source object by frac. E.g | """Increase the yAstrom value in a Source object by frac. E.g | def linearYDistort(src, frac=.001): """Increase the xAstrom value in a Source object by frac. E.g src.xAstrom = 1000 --> 1001 if frac=.001 Input: src A Source object frac How much to change X by Output: A deep copy of src, with the value of xAstrom changed """ out = afwDet.Source(src) out.setYAstrom( out.getY... |
frac How much to change X by | frac How much to change Y by | def linearYDistort(src, frac=.001): """Increase the xAstrom value in a Source object by frac. E.g src.xAstrom = 1000 --> 1001 if frac=.001 Input: src A Source object frac How much to change X by Output: A deep copy of src, with the value of xAstrom changed """ out = afwDet.Source(src) out.setYAstrom( out.getY... |
A deep copy of src, with the value of xAstrom changed | A deep copy of src, with the value of yAstrom changed | def linearYDistort(src, frac=.001): """Increase the xAstrom value in a Source object by frac. E.g src.xAstrom = 1000 --> 1001 if frac=.001 Input: src A Source object frac How much to change X by Output: A deep copy of src, with the value of xAstrom changed """ out = afwDet.Source(src) out.setYAstrom( out.getY... |
xfunc = lambda x: x.getXAstrom() yfunc = lambda x: x.getYAstrom() x = map(xfunc, srcSet) y = map(yfunc, srcSet) minx = min(x) maxx = max(x) miny = min(y) maxy = max(y) llc = wcs.pixelToSky(minx, miny) urc = wcs.pixelToSky(maxx, maxy) deltaRa = urc[0] - llc[0] deltaDec = urc[1] - llc[1] dist = math.sqrt(deltaRa**2... | xMin = float('inf') xMax = float('-inf') yMin = float('inf') yMax = float('-inf') for src in srcSet: x = src.getXAstrom() y = src.getYAstrom() if math.isnan(x) or math.isnan(y): continue if x < xMin: xMin = x if x > xMax: xMax = x if y < yMin: yMin = y if y > yMax: yMax = y dx = xMax - xMin dy = yMax - yMin size = wcs... | def getImageSizeInArcsec(srcSet, wcs): """ Get the approximate size of the image in arcseconds Input: srcSet List of detected objects in the image (with pixel positions) wcs Wcs converts pixel positions to ra/dec """ xfunc = lambda x: x.getXAstrom() yfunc = lambda x: x.getYAstrom() x = map(xfunc, srcSet) y = map(... |
ref = solver.getCatalogue(ra, dec, radius, filterName, idName, anid) | X = solver.getCatalogue(ra, dec, radius, filterName, idName, anid) ref = X.first inds = X.second | def plotsForField(inButler, keys, fixup, plots=None): if plots is None: plots = ['photom','corr','distortion'] filters = inButler.queryMetadata('raw', 'filter', **keys) print 'Filters:', filters filterName = filters[0] psources = inButler.get('icSrc', **keys) pmatches = inButler.get('icMatch', **keys) print 'Got sour... |
src.setRa(raDec[0]) src.setDec(raDec[1]) | src.setRa(math.degrees(raDec[0])) src.setDec(math.degrees(raDec[1])) | def loadCatalogue(self, filename, gas): """Load a list of xy points from a file, solve for position, and return a SourceSet of points""" |
solver.setImageSize(*forceImageSize) else: solver.setImageSize(exp.getWidth(), exp.getHeight()) | (W,H) = forceImageSize else: (W,H) = (exp.getWidth(), exp.getHeight()) solver.setImageSize(W, H) | def determineWcs(policy, exposure, sourceSet, log=None, solver=None, doTrim=False, forceImageSize=None): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. In... |
imgSizeInArcsec = getImageSizeInArcsec(srcSet, wcs) | imgSizeInArcsec = wcs.pixelScale() * hypot(W,H) | def determineWcs(policy, exposure, sourceSet, log=None, solver=None, doTrim=False, forceImageSize=None): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. In... |
def getImageSizeInArcsec(srcSet, wcs): """ Get the approximate size of the image in arcseconds Input: srcSet List of detected objects in the image (with pixel positions) wcs Wcs converts pixel positions to ra/dec """ xfunc = lambda x: x.getXAstrom() yfunc = lambda x: x.getYAstrom() x = map(xfunc, srcSet) y = map(... | def chooseFilterName(exposure, policy, solver, log): """When extracting catalogue magnitudes, which colour filter should we request e.g U,B,V etc.""" if log is None: log = StdoutLog() filterName = exposure.getFilter().getName() if filterName == "_unknown_": #No symbol for this in afw log.log(log.DEBUG, "Exposure ha... | |
return [matchList, sipObject.getNewWcs()] | return [matchList, outWcs] | def determineWcs(policy, exposure, sourceSet, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: An lsst.pex.polic... |
msg="Sip Iteration %i: %i objects match. rms scatter is %g arcsec or %g pixels" \ %(i, matchSize, sipObject.getScatterInArcsec(), sipObject.getScatterInPixels()) log.log(Log.DEBUG, msg) | def determineWcs(policy, exposure, sourceSet, log=None, solver=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: An l... | |
outputWcsKey = policy.get('outputWcsKey') | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... | |
log.log(log.DEBUG, "Finished Solve step") | log.log(log.DEBUG, "Finished Solve step.") | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... |
if filterName == None: | if filterName is None: | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... |
except LsstCppException(e): | except LsstCppException, e: | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... |
newWcs = sipObject.getNewWcs() | outWcs = sipObject.getNewWcs() log.log(Log.DEBUG, "Updating wcs in input exposure with distorted wcs") exposure.setWcs(outWcs) else: log.log(Log.DEBUG, "Updating wcs in input exposure with linear wcs") exposure.setWcs(linearWcs) | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... |
self.gas.setLogLevel(verbose) | self.gas.setLogLevel(3) | def testVerifyCFHTField(self): if verbose: print "testVerifyCFHTField..." |
tc = WCSTestCaseNetUSNOB('testVerifyCFHTField') unittest.TextTestRunner(verbosity=2).run(tc) | verbose = 3 tc = WCSTestCaseNetUSNOB('testSolveGD66Wcs') unittest.TextTestRunner(verbosity=3).run(tc) | def run(exit=False): """Run the tests""" utilsTests.run(suite(), exit) |
wcs = sipObject.getNewWcs() | proposedWcs = sipObject.getNewWcs() | def determineWcs(policy, exposure, sourceSet, log=None, solver=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: An l... |
proposedMatchlist = matchSrcAndCatalogue(cat=cat, img=srcSet, wcs=wcs, | proposedMatchlist = matchSrcAndCatalogue(cat=cat, img=srcSet, wcs=proposedWcs, | def determineWcs(policy, exposure, sourceSet, log=None, solver=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: An l... |
def determineWcs(policy, exposure, sourceSet, log=None): | def determineWcs(policy, exposure, sourceSet, log=None, doTrim=False): | def determineWcs(policy, exposure, sourceSet, log=None): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: An lsst.pex.policy.Policy objec... |
if isSolved == False: | if not isSolved: | def determineWcs(policy, exposure, sourceSet, log=None): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: An lsst.pex.policy.Policy objec... |
if not(par[1] - err[1] < 1 and par[1] + err[1] > 1): | if not(par[1] - err[1] <= 1 and par[1] + err[1] >= 1): | def calcPhotoCal(sourceMatch, log=None): """Calculate photometric calibration, i.e the zero point magnitude""" #Convert fluxes to magnitudes out = getMagnitudes(sourceMatch) #Fit to get zeropoint lsf = robustFit(out["src"], out["cat"], order=2, plot=True) par = lsf.getParams() err = lsf.getErrors() #Sanity check out... |
pass | mypath = eups.productDir("meas_astrom") datapath = os.path.join(mypath, 'tests', 'astrometry_net_data', 'photocal') print 'Setting up astrometry_net_data:', datapath os.environ['HOME'] = 'iswheretheheartis' eupsObj = eups.Eups(root=datapath) ok, version, reason = eupsObj.setup('astrometry_net_data') if not ok: raise ... | def setUp(self): pass |
ra,dec,rad = 2.389, 3.287, 0.158 filtername,idname = 'r','id' anindid = 101109003 | ra,dec,rad = (-145., 53., 0.15) filtername,idname = 'mag','id' anindid = 2033 | def testJoin(self): pol = policy.Policy() pol.set('matchThreshold', 30) log = Log.getDefaultLog() |
anindfn = '/home/dalang/lsst/astrometry_net_data/imsim-2010-11-09-0/index-101109003.fits' | anindfn = os.path.join(anpath, 'photocal', 'index-2033.fits') | def testJoin(self): pol = policy.Policy() pol.set('matchThreshold', 30) log = Log.getDefaultLog() |
catSrcErr = np.sqrt(fluxCat) | def getMagnitudes(sourceMatch): #Extract the fluxes as numpy arrays. Catalogues don't come with fluxes #so do an estimate using sqrt(counts) fluxCat = np.array(map(lambda x: x.first.getPsfFlux(), sourceMatch)) fluxSrc = np.array(map(lambda x: x.second.getPsfFlux(), sourceMatch)) fluxSrcErr = np.array(map(lambda x: x.s... | |
idx = where(fluxSrc >= 0) | idx = np.where(fluxSrc > 0) | def getMagnitudes(sourceMatch): #Extract the fluxes as numpy arrays. Catalogues don't come with fluxes #so do an estimate using sqrt(counts) fluxCat = np.array(map(lambda x: x.first.getPsfFlux(), sourceMatch)) fluxSrc = np.array(map(lambda x: x.second.getPsfFlux(), sourceMatch)) fluxSrcErr = np.array(map(lambda x: x.s... |
idx = where(fluxCat >= 0) | idx = np.where(fluxCat > 0) | def getMagnitudes(sourceMatch): #Extract the fluxes as numpy arrays. Catalogues don't come with fluxes #so do an estimate using sqrt(counts) fluxCat = np.array(map(lambda x: x.first.getPsfFlux(), sourceMatch)) fluxSrc = np.array(map(lambda x: x.second.getPsfFlux(), sourceMatch)) fluxSrcErr = np.array(map(lambda x: x.s... |
fluxSrcErr = np.hypot(fluxSrcErr, catSrcErr) | fluxSrcErr = np.hypot(fluxSrcErr, fluxCatErr) | def getMagnitudes(sourceMatch): #Extract the fluxes as numpy arrays. Catalogues don't come with fluxes #so do an estimate using sqrt(counts) fluxCat = np.array(map(lambda x: x.first.getPsfFlux(), sourceMatch)) fluxSrc = np.array(map(lambda x: x.second.getPsfFlux(), sourceMatch)) fluxSrcErr = np.array(map(lambda x: x.s... |
if doBlindSolve or True: | if doBlindSolve: | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... |
def doFoo(self, inValue): print "In doFoo" print type(inValue), inValue.size, inValue.shape inType = type(inValue) out = inType(inValue) print type(out), out.size, out.shape print "Leaving doFoo" return out | def doFoo(self, inValue): print "In doFoo" print type(inValue), inValue.size, inValue.shape #out = np.array(inValue) inType = type(inValue) out = inType(inValue) print type(out), out.size, out.shape print "Leaving doFoo" return out | |
else | else: | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... |
except LsstCppException e: | except LsstCppException(e): | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... |
log.log(Log.WARN, "Attempting to access catalogue positions and fluxes" log.log(Log.WARN, "Catalogue version: %s" %(eups.productDir("astrometry_net_data")) log.log(Log.WARN, "Requested filter: %s" %(filterName) log.log(Log.WARN, "Available filters: " + solver.getCatalogueMetadataFields() | log.log(Log.WARN, "Attempting to access catalogue positions and fluxes") version = eups.productDir("astrometry_net_data") log.log(Log.WARN, "Catalogue version: %s" %(version)) log.log(Log.WARN, "Requested filter: %s" %(filterName)) log.log(Log.WARN, "Available filters: " + solver.getCatalogueMetadataFields()) | def determineWcs(policy, exposure, sourceSet, filterName=None, log=None, doTrim=False): """Top level function for calculating a Wcs. Given an initial guess at a Wcs (hidden inside an exposure) and a set of sources (sourceSet), use astrometry.net to confirm the Wcs, then calculate distortion terms. Input: policy: ... |
goodFlagValue= 128 | flags = malgUtil.getDetectionFlags() goodFlagValue= flags['BINNED1'] | flags['STAR'] | def calcPhotoCal(sourceMatch, log=None): """Calculate photometric calibration, i.e the zero point magnitude""" if len(sourceMatch) == 0: raise ValueError("sourceMatch contains no elements") #Only use stars for which the flags indicate the photometry is good. goodFlagValue= 128 #Put some logic here cleanList = [] for ... |
if ident in ['abs', 'int', 'float', 'str', 'dict', 'tuple', 'list', 'type', 'cmp', 'sum', 'zip', 'max', 'min']: | if ident in ['abs', 'int', 'float', 'str', 'dict', 'tuple', 'list', 'type', 'cmp', 'sum', 'zip']: | def visitCallFunc(self, node, func=None): objexpr, ident, direct_call, method_call, constructor, parent_constr = analyze_callfunc(node) funcs = callfunc_targets(node, self.mergeinh) |
elif ident in ['iter', 'round']: | elif ident in ['min', 'max', 'iter', 'round']: | def visitCallFunc(self, node, func=None): objexpr, ident, direct_call, method_call, constructor, parent_constr = analyze_callfunc(node) funcs = callfunc_targets(node, self.mergeinh) |
self.append('__box((') | self.append('___box((') | def visit_callfunc_args(self, funcs, node, func): objexpr, ident, direct_call, method_call, constructor, parent_constr = analyze_callfunc(node) target = funcs[0] # XXX |
self.visitm(', __box(', n, ')', func) | self.visitm(', ___box(', n, ')', func) | def visitMod(self, node, func=None): # --- non-str % .. if [t for t in getgx().merged_inh[node.left] if t[0].ident != 'str_']: self.visitBinary(node.left, node.right, '__mod__', '%', func) return |
self.visitm(', __box(', n, ')', func) | self.visitm(', ___box(', n, ')', func) | def visitPrint(self, node, func=None, print_space=True): self.start('print2(') if node.dest: self.visitm(node.dest, ', ', func) if print_space: self.append('1,') else: self.append('0,') self.append(str(len(node.nodes))) for n in node.nodes: types = [t[0].ident for t in self.mergeinh[n]] if 'float_' in types or 'int_' i... |
return name in cl.funcs and not cl.funcs[name].inherited and cpp.hmcpa(cl.funcs[name]) | return name in cl.funcs and not cl.funcs[name].invisible and not cl.funcs[name].inherited and cpp.hmcpa(cl.funcs[name]) | def hasmethod(cl, name): # XXX shared.py return name in cl.funcs and not cl.funcs[name].inherited and cpp.hmcpa(cl.funcs[name]) |
print a | def wopper(x): print 'wopper', x | |
if DEBUG: print 'IFA visit var %s.%s, %d' % (cl.ident, var.name, dcpa) | def ifa_split_vars(cl, dcpa, vars, nr_classes, classes_nr, split): for (varnum, var) in enumerate(vars): if not (var, dcpa, 0) in getgx().cnode: continue node = getgx().cnode[var, dcpa, 0] creation_points, paths, assignsets, allnodes, csites, emptycsites = ifa_flow_graph(cl, dcpa, node) if len(csites)+len(emptycsites) ... | |
if DEBUG: print 'IFA found simple splits, aborting' | def ifa_split_vars(cl, dcpa, vars, nr_classes, classes_nr, split): for (varnum, var) in enumerate(vars): if not (var, dcpa, 0) in getgx().cnode: continue node = getgx().cnode[var, dcpa, 0] creation_points, paths, assignsets, allnodes, csites, emptycsites = ifa_flow_graph(cl, dcpa, node) if len(csites)+len(emptycsites) ... | |
print "body %d: %s" % (j, b.pos) | print "body %s: %s" % (repr(j), repr(b.pos)) | def main(args): BH.parse_cmd_line(args) |
if isinstance(expr, CallFunc) and not expr.args: | if (isinstance(expr, CallFunc) and not expr.args) or expr in getgx().lambdawrapper: | def propagate(): #print 'propagate' seed_nodes() worklist = init_worklist() #print 'worklist', worklist getgx().checkcallfunc = [] # XXX # --- check whether seeded nodes are object/argument to call changed = set() for w in worklist: for callfunc in w.callfuncs: #print 'seed changed', w.callfunc, w.dcpa, w.cpa changed... |
self.sysdir = os.sep.join(__file__.split(os.sep)[:-2]) | self.sysdir = '/'.join(__file__.split(os.sep)[:-2]) | def __init__(self): self.constraints = set() self.allvars = set() self.allfuncs = set() self.allclasses = set() self.cnode = {} self.types = {} self.templates = 0 self.modules = {} self.inheritance_relations = {} self.inheritance_tempvars = {} self.parent_nodes = {} self.inherited = set() self.nrcltypes = 8; self.empty... |
return 1 | return True | def __eq__(self, n): if n.lid == self.lid: return 1 else: return 0 |
return 0 | return False | def __eq__(self, n): if n.lid == self.lid: return 1 else: return 0 |
nodes = []; totalCost = n.mCost; p = n.parent; nodes.insert(0,n); | nodes = [] totalCost = n.mCost p = n.parent nodes.insert(0,n) | def _tracePath(self,n): nodes = []; totalCost = n.mCost; p = n.parent; nodes.insert(0,n); while 1: if p.parent is None: break |
return 1 | return True | def __eq__(self, l): """MUST BE IMPLEMENTED""" if l.x == self.x and l.y == self.y: return 1 else: return 0 |
return 0 | return False | def __eq__(self, l): """MUST BE IMPLEMENTED""" if l.x == self.x and l.y == self.y: return 1 else: return 0 |
return Node(location,d,((y*self.w)+x)); | return Node(location,d,((y*self.w)+x)) | def getNode(self, location): """MUST BE IMPLEMENTED""" x = location.x y = location.y if x<0 or x>=self.w or y<0 or y>=self.h: return None d = self.m[(y*self.w)+x] if d == -1: return None |
if self.only_classes(rvalue_node, ('list',)): | if i < 2 and self.only_classes(rvalue_node, ('tuple2',)): sel = ['__getfirst__()', '__getsecond__()'][i] elif self.getfast(rvalue_node): | def get_selector(self, temp, item, i): rvalue_node = getgx().item_rvalue[item] sel = '__getitem__(%d)' % i if self.only_classes(rvalue_node, ('list',)): sel = '__getfast__(%d)' % i elif i < 2 and self.only_classes(rvalue_node, ('tuple2',)): sel = ['__getfirst__()', '__getsecond__()'][i] return '%s->%s' % (temp, sel) |
elif i < 2 and self.only_classes(rvalue_node, ('tuple2',)): sel = ['__getfirst__()', '__getsecond__()'][i] | def get_selector(self, temp, item, i): rvalue_node = getgx().item_rvalue[item] sel = '__getitem__(%d)' % i if self.only_classes(rvalue_node, ('list',)): sel = '__getfast__(%d)' % i elif i < 2 and self.only_classes(rvalue_node, ('tuple2',)): sel = ['__getfirst__()', '__getsecond__()'][i] return '%s->%s' % (temp, sel) | |
if ident == '__getitem__' and self.only_classes(node.expr, ('list',)): | if ident == '__getitem__' and self.getfast(node.expr): | def visitGetattr(self, node, func=None): cl, module = lookup_class_module(node.expr, inode(node).mv, func) |
elif b.thing.parent.ident in ['list', 'tuple', 'frozenset', 'set', 'file','__iter'] and b.thing.name != 'unit': continue elif b.thing.parent.ident == 'dict' and b.thing.name not in ['unit', 'value']: continue | elif b.thing.parent.ident in ['list', 'tuple', 'frozenset', 'set', 'file','__iter', 'deque'] and b.thing.name != 'unit': continue elif b.thing.parent.ident in ('dict', 'defaultdict') and b.thing.name not in ['unit', 'value']: continue | def propagate(): #print 'propagate' seed_nodes() worklist = init_worklist() #print 'worklist', worklist getgx().checkcallfunc = [] # XXX # --- check whether seeded nodes are object/argument to call changed = set() for w in worklist: for callfunc in w.callfuncs: #print 'seed changed', w.callfunc, w.dcpa, w.cpa changed... |
okay = True | def ifa_seed_template(func, cart, dcpa, cpa, worklist): if cart != None: # (None means we are not in the process of propagation) #print 'funccopy', func.ident #, func.nodes if isinstance(func.parent, class_): # self cart = ((func.parent, dcpa),)+cart for node in func.nodes: if node.constructor and isinstance(node.thin... | |
if a == b: pass elif isinstance(a[0], class_) and a[0] is b[0] and a[1] in a[0].splits and a[0].splits[a[1]] == b[1]: pass else: okay = False | if a != b and not (isinstance(a[0], class_) and a[0] is b[0] and a[1] in a[0].splits and a[0].splits[a[1]] == b[1]): | def ifa_seed_template(func, cart, dcpa, cpa, worklist): if cart != None: # (None means we are not in the process of propagation) #print 'funccopy', func.ident #, func.nodes if isinstance(func.parent, class_): # self cart = ((func.parent, dcpa),)+cart for node in func.nodes: if node.constructor and isinstance(node.thin... |
if okay: | else: | def ifa_seed_template(func, cart, dcpa, cpa, worklist): if cart != None: # (None means we are not in the process of propagation) #print 'funccopy', func.ident #, func.nodes if isinstance(func.parent, class_): # self cart = ((func.parent, dcpa),)+cart for node in func.nodes: if node.constructor and isinstance(node.thin... |
sum([(r is not False) for r in results]), len(results)) | sum([(r is not None) for r in results]), len(results)) | def solve_file(filename, sep, action): #=lambda x: x): "Parse a file into a sequence of 81-char descriptions and solve them." results = [action(search(parse_grid(grid))) for grid in file(filename).read().strip().split(sep)] print "## Got %d out of %d" % ( sum([(r is not False) for r in results]), len(results)) return r... |
self.eol(') { return 0; }') | if retexpr and self.mergeinh[func.retnode.thing] == set([(defclass('bool_'), 0)]): self.eol(') { return False; }') else: self.eol(') { return 0; }') | def virtuals(self, cl, declare): for ident, subclasses in cl.virtuals.items(): if not subclasses: continue |
print '*** SHED SKIN Python-to-C++ Compiler 0.4 ***' print 'Copyright 2005-2009 Mark Dufour; License GNU GPL version 3 (See LICENSE)' | print '*** SHED SKIN Python-to-C++ Compiler 0.5 ***' print 'Copyright 2005-2010 Mark Dufour; License GNU GPL version 3 (See LICENSE)' | def main(): setgx(newgx()) print '*** SHED SKIN Python-to-C++ Compiler 0.4 ***' print 'Copyright 2005-2009 Mark Dufour; License GNU GPL version 3 (See LICENSE)' print # --- some checks major, minor = sys.version_info[:2] if (major, minor) not in [(2, 4), (2, 5), (2, 6)]: print '*ERROR* Shed Skin is not compatible wit... |
creation_points, paths, assignsets, allnodes, csites = ifa_flow_graph(cl, dcpa, node) if len(csites) == 1: | creation_points, paths, assignsets, allnodes, csites, emptycsites = ifa_flow_graph(cl, dcpa, node) if len(csites)+len(emptycsites) == 1: | def ifa_split_vars(cl, dcpa, vars, nr_classes, classes_nr, split): for (varnum, var) in enumerate(vars): if not (var, dcpa, 0) in getgx().cnode: continue node = getgx().cnode[var, dcpa, 0] creation_points, paths, assignsets, allnodes, csites = ifa_flow_graph(cl, dcpa, node) if len(csites) == 1: continue if DEBUG: print... |
ifa_split_empties(cl, dcpa, allnodes, assignsets, split) if len(merge_simple_types(getgx().types[node])) < 2 or len(assignsets) == 1: continue ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, allnodes, split) | if ((len(merge_simple_types(getgx().types[node])) > 1 and len(assignsets) > 1) or \ (assignsets and emptycsites)): ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, emptycsites, allnodes, split) | def ifa_split_vars(cl, dcpa, vars, nr_classes, classes_nr, split): for (varnum, var) in enumerate(vars): if not (var, dcpa, 0) in getgx().cnode: continue node = getgx().cnode[var, dcpa, 0] creation_points, paths, assignsets, allnodes, csites = ifa_flow_graph(cl, dcpa, node) if len(csites) == 1: continue if DEBUG: print... |
def ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, allnodes, split): | def ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, emptycsites, allnodes, split): | def ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, allnodes, split): '''creation sites on single path: split them off, possibly reusing contour''' attr_types = nr_classes[dcpa] noconf = set([n for n in csites if len(n.paths)==1]) others = len(csites) - len(noconf) subtype_csites = {} for node ... |
attr_types = nr_classes[dcpa] noconf = set([n for n in csites if len(n.paths)==1]) others = len(csites) - len(noconf) | attr_types = list(nr_classes[dcpa]) noconf = set([n for n in csites if len(n.paths)==1]+emptycsites) others = len(csites) + len(emptycsites) - len(noconf) | def ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, allnodes, split): '''creation sites on single path: split them off, possibly reusing contour''' attr_types = nr_classes[dcpa] noconf = set([n for n in csites if len(n.paths)==1]) others = len(csites) - len(noconf) subtype_csites = {} for node ... |
assign_set = node.paths[0] if len(attr_types) == 1 and list(attr_types)[0] == assign_set: | if node.paths: assign_set = node.paths[0] else: assign_set = frozenset() if attr_types[varnum] == assign_set: | def ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, allnodes, split): '''creation sites on single path: split them off, possibly reusing contour''' attr_types = nr_classes[dcpa] noconf = set([n for n in csites if len(n.paths)==1]) others = len(csites) - len(noconf) subtype_csites = {} for node ... |
subtype = list(attr_types) | subtype = attr_types[:] | def ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, allnodes, split): '''creation sites on single path: split them off, possibly reusing contour''' attr_types = nr_classes[dcpa] noconf = set([n for n in csites if len(n.paths)==1]) others = len(csites) - len(noconf) subtype_csites = {} for node ... |
def ifa_split_empties(cl, dcpa, allnodes, assignsets, split): ''' split off empty assignment sets (eg, [], or [x[0]] where x is None in some template) ''' endpoints = [huh for huh in allnodes if not huh.in_] if assignsets and cl.ident in ['list', 'tuple', 'tuple2']: allcsites = set() for n, types in getgx().types.iteri... | def ifa_split_no_confusion(cl, dcpa, varnum, classes_nr, nr_classes, csites, allnodes, split): '''creation sites on single path: split them off, possibly reusing contour''' attr_types = nr_classes[dcpa] noconf = set([n for n in csites if len(n.paths)==1]) others = len(csites) - len(noconf) subtype_csites = {} for node ... | |
return creation_points, paths, assignsets, allnodes, csites | allcsites = set() for n, types in getgx().types.iteritems(): if (cl, dcpa) in types and not n.in_: allcsites.add(n) emptycsites = list(allcsites-set(csites)) for n in emptycsites: n.paths = [] return creation_points, paths, assignsets, allnodes, csites, emptycsites | def ifa_flow_graph(cl, dcpa, node): creation_points, paths, assignsets = {}, {}, {} allnodes = set() csites = [] # --- determine assignment sets for a in node.in_: types = getgx().types[a] if types: if a.thing in getgx().assign_target: # XXX *args target = getgx().cnode[getgx().assign_target[a.thing], a.dcpa, a.cpa] #... |
"""Usage: %s [options] root_dir | """Usage: %s [options] | def usage(): usage = \ |
<title>%(title)s - QuickServer</title> | <title>%(title)s - QuickFileServer</title> | def num(s): if s.isdigit(): return int(s) return s |
raw_input("Press [Enter] to stop server") | raw_input("Press [Enter] to stop server\n") server.socket.close() | def main(): global verbose, debug verbose = False debug = False try: opts, args = getopt.getopt(sys.argv[1:], "hvur:p:n", \ ["help", "verbose", "update", "root-dir=", "http-port=", "no-dir-list"]) except getopt.GetoptError, err: print str(err) sys.exit(2) server_port = 8080 root_dir = os.getcwd() list_dir = True if ... |
rel_path = self.path[1:] | rel_path = unquote(self.path[1:]) | def do_GET(self): global verbose try: # remove leading '/' rel_path = self.path[1:] abs_path = os.path.abspath(os.path.join( self.server.root_dir, rel_path)) print "rel_path=%s abs_path=%s" % (rel_path, abs_path) if os.path.isfile(abs_path): if verbose: print "File get '%s'" % rel_path content = open(abs_path, 'rb') co... |
print "rel_path=%s abs_path=%s" % (rel_path, abs_path) | if verbose: print "rel_path=%s abs_path=%s" % (rel_path, abs_path) | def do_GET(self): global verbose try: # remove leading '/' rel_path = self.path[1:] abs_path = os.path.abspath(os.path.join( self.server.root_dir, rel_path)) print "rel_path=%s abs_path=%s" % (rel_path, abs_path) if os.path.isfile(abs_path): if verbose: print "File get '%s'" % rel_path content = open(abs_path, 'rb') co... |
if len(list(catalog)) != len(list(catalog.getIndexes())): logger.info('Updating Discussion Catalog Indexes...') catalog.clear() catalog.updateIndexes() logger.info('Done!') | try: if len(list(catalog)) != len(list(catalog.getIndexes())): logger.info('Updating Discussion Catalog Indexes...') catalog.clear() catalog.updateIndexes() logger.info('Done!') except ComponentLookupError: continue | def findObjectsProviding(root): if ISite.providedBy(root): yield root |
def PostComment(object, instance, *args, **kw): | def PostCommentKey(object, instance, *args, **kw): instance.updateForms() | def PostComment(object, instance, *args, **kw): if not instance.postsAllowed or \ instance.request.has_key('discussion.buttons.post'): raise DoNotCache() return () |
instance.request.has_key('discussion.buttons.post'): | instance.request.has_key('discussion.buttons.post') or \ (len(instance.forms) or len(instance.subforms)): | def PostComment(object, instance, *args, **kw): if not instance.postsAllowed or \ instance.request.has_key('discussion.buttons.post'): raise DoNotCache() return () |
@cache('content.discussion.reply', PostComment, PrincipalAndContext) | @cache('content.discussion.reply', PostCommentKey, PrincipalAndContext) | def isAvailable(self): return self.postsAllowed |
@setproperty def status(self, value): context = removeAllProxies(self.context) if value == 3: if IContentDiscussionAware.providedBy(context): interface.noLongerProvides(context, IContentDiscussionAware) else: if not IContentDiscussionAware.providedBy(context): interface.alsoProvides(context, IContentDiscussionAware) ... | def modified(self, value): self.data.modified = value | |
if T.typeName in _typeNameToMostRecentClass: | if not T.__legacy__ and T.typeName in _typeNameToMostRecentClass: | def __new__(meta, name, bases, dictionary): T = slotmachine.SchemaMetaMachine.__new__(meta, name, bases, dictionary) if T.__name__ == 'Item' and T.__module__ == __name__: return T T.__already_inherited__ += 1 if T.__already_inherited__ >= 2: raise NoInheritance("already inherited from item once: " "in-database inherita... |
opts,args = getopt.getopt(argv[1:],"d:f:e:r:vt:p:s:o:n:a:b:Fmc", | opts,args = getopt.getopt(argv[1:],"d:f:e:x:r:vt:p:s:o:n:a:b:Fmc", | def getargs(argv): try: opts,args = getopt.getopt(argv[1:],"d:f:e:r:vt:p:s:o:n:a:b:Fmc", ["dir=", "file=", "exit=", "reason=", "resultfilter=", "proto=", "verbose", "statuscode=", "sortby=", "noreason=", "after=", "before=", "falsepositives", "email", "confirmed"]) except getopt.GetoptError,err: print str(err) usage(ar... |
results = dh.filterByNode(dh.getAll(), "$"+node) | results = dh.filterByNode(dh.getAll(), node) | def main(argv): now = time.time() use_dir,use_file,node,reasons,noreasons,result,verbose,resultfilter,proto,sortby,before,after,falsepositives,send_email,confirmed=getargs(argv) dh = DataHandler(use_dir) if use_file: results = [dh.getResult(use_file)] elif node: results = dh.filterByNode(dh.getAll(), "$"+node) else: r... |
FixedTargetTest.__init__(self, targets) | FixedTargetTest.__init__(self, utargets) | def __init__(self, targets): BaseHTTPTest.__init__(self) utargets = [t for t in targets if self._is_useable_url(t, ['http'])] FixedTargetTest.__init__(self, targets) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.