def testBalance1(self): ts = [just_sleep(0.5) for i in range(LocalExecutor.NUM_THREADS)] start = time.time() res = resultset(ts) for r in res: pass end = time.time() print "Took %f" % (end - start) self.assertTrue(end - start < 1.0)
def testResultBag(self): COUNT = 10 res1 = (py_ivar(i) for i in range(COUNT)) res2 = (inc(i - 1) for i in range(COUNT)) res2b = (inc(i - 1) for i in range(COUNT)) exp = [(x, x) for x in range(COUNT)] # with max-running at 1 should be in order self.checkSequential((item for i, item in resultset(res2b, max_ready=1)), COUNT) # Check that all of the expected results turn up act1 = [(i, x.get()) for i, x in list(resultset(res1))] print act1 self.assertEquals(sorted(act1), exp) act2 = [(i, x.get()) for i, x in list(resultset(res2))] print act2 self.assertEquals(sorted(act2), exp)
def testResultBag(self): COUNT = 10 res1 = (py_ivar(i) for i in range(COUNT)) res2 = (inc(i - 1) for i in range(COUNT)) res2b = (inc(i - 1) for i in range(COUNT)) exp = [(x, x) for x in range(COUNT)] # with max-running at 1 should be in order self.checkSequential( (item for i, item in resultset(res2b, max_ready=1)), COUNT) # Check that all of the expected results turn up act1 = [(i, x.get()) for i, x in list(resultset(res1))] print act1 self.assertEquals(sorted(act1), exp) act2 = [(i, x.get()) for i, x in list(resultset(res2))] print act2 self.assertEquals(sorted(act2), exp)
proj << mProjectPP(raw_img, header) # Generate a temporary table with info about images proj_table = MTable(path.join(bands, 'proj', 'pimages.tbl')) proj_table << mImgtbl(*projected) # Now combine the projected images into a montage band_img = MImage(path.join(bands, bands + ".fits")) band_img << mAdd(proj_table, header, *projected) return band_img # Get info for the three bands we are interested in allbands = ['DSS2B', 'DSS2R', 'DSS2IR'] img_tables = [archive_fetch(bands) for bands in allbands] # For each of the three bands, stitch together the different # images into a grayscale image. # Use of resultset sparks all futures in img_tables # , and allows to process the results out of order as # soon as data is ready. band_imgs = [ process_one_band(bands, tbl, header) for bands, tbl in resultset(img_tables, allbands) ] # Make a false-color JPEG image out of the three bands res = JPEG("DSS2_BRIR.jpeg") << mJPEGrgb(band_imgs[2], band_imgs[1], band_imgs[0]) res.get() # Calling get triggers execution
for proj, raw_img in zip(projected, raw_images): proj << mProjectPP(raw_img, header) # Generate a temporary table with info about images proj_table = MTable(path.join(bands, 'proj', 'pimages.tbl')) proj_table << mImgtbl(*projected) # Now combine the projected images into a montage band_img = MImage(path.join(bands, bands+".fits")) band_img << mAdd(proj_table, header, *projected) return band_img # Get info for the three bands we are interested in allbands = ['DSS2B', 'DSS2R', 'DSS2IR'] img_tables = [archive_fetch(bands) for bands in allbands] # For each of the three bands, stitch together the different # images into a grayscale image. # Use of resultset sparks all futures in img_tables # , and allows to process the results out of order as # soon as data is ready. band_imgs = [process_one_band(bands, tbl, header) for bands, tbl in resultset(img_tables, allbands)] # Make a false-color JPEG image out of the three bands res = JPEG("DSS2_BRIR.jpeg") << mJPEGrgb(band_imgs[2], band_imgs[1], band_imgs[0]) res.get() # Calling get triggers execution