예제 #1
0
def main():
    """ Set up the parallel engine and the data space. Call the parallel engine, then write out the results """

    client = Client()[:]
    client.use_dill()
    client.execute("import furnace.performance, furnace.strategy, numpy, datetime")

    stock_percents = numpy.linspace(0.0, 0.4, 10)
    rebalancing_periods = numpy.arange(1, 40, 1)
    days_in = numpy.arange(1, 250, 1)
    begin = datetime.datetime(2003, 1, 2)
    end = datetime.datetime(2011, 12, 31)
    grid = list(itertools.product(stock_percents, rebalancing_periods, days_in))
    builder = function_builder(begin, end)
    results = client.map(builder, grid)

#TODO: does pandas have a plain 'save to csv' function?
    with open('data.csv', 'wb') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(['days_out', 'pct', 'ndays', 'r2r', 'cagr', 'volatility', 'ntrades'])
        writer.writerows(results)
예제 #2
0
파일: crop.py 프로젝트: fierval/whales
        cv2.imwrite(out_im_name, toSave)

    return out_im_name

def resize_only(image_name):
    image = cv2.imread(image_name)

    out_name = path.split(image_name)[1]
    out_im_name = path.join(out_path, out_name)

    toSave = cv2.resize(image, size)

    cv2.imwrite(out_im_name, toSave)

def kmeans_only(image_name, K=10):
    out_im_name = get_output_name(image_name)
    image = cv2.imread(image_name)
    
    toSave, _, _ = kmeans(image, K)

    cv2.imwrite(out_im_name, toSave)
        
prep_out_path(out_path)
dv = Client().load_balanced_view()
fs = dv.map(kmeans_only, np.array(image_paths))
print "Started: ", time_now_str()
fs.wait()
print "Finished: ", time_now_str()