示例#1
0
from firefly import Firefly

from helpers import setup_sentry

setup_sentry()
app = Firefly()

@app.function
def fib(n):
    if n==0 or n==1: return n
    if n>10: raise ValueError('n greater than 10 not allowed')
    return fib(n-1) + fib(n-2)

if __name__ == "__main__":
    app.run()
示例#2
0
                           peakWidth=np.deg2rad(settings.Pwdes),
                           sidelobeHeight=settings.Slhdes)

    time = datetime.__str__(datetime.today())
    # time = time[:-10]
    time = time[0:10] + "_" + time[11:13] + "." + time[14:16]
    filepath = "data/" + time + "/"
    if not os.path.exists(filepath):
        os.makedirs(filepath)
    shutil.copyfile("./settings.py", filepath + "settings.txt")

    for ensemble in range(0, settings.ENSEMBLES):
        firefly.generate_initials()
        print "ensemble: %s" % ensemble

        x, R, fitness = firefly.run()

        if ensemble == 0:
            with open(filepath + "x.csv", "w") as xfile:
                writer = csv.writer(xfile)
                writer.writerows(x)
            with open(filepath + "R.csv", "w") as Rfile:
                writer = csv.writer(Rfile)
                writer.writerows(R)
            with open(filepath + "fitness.csv", "w") as fitnessfile:
                writer = csv.writer(fitnessfile)
                writer.writerow(fitness)
        else:
            with open(filepath + "x.csv", "a") as xfile:
                writer = csv.writer(xfile)
                writer.writerows(x)