def header(sg1: common.stargate, target):
    while (sg1.mystatus.observe == "TRUE"):
        common.header(sg1, 'OBSERVE')
        print(datetime.datetime.utcnow())
        print('')
        print('target: ' + str(target))
        #calculations
        print('LMST: ' + str(sg1.mycalc.LMST))
        print('****************** RA ******************')
        print('setpoint: ' + str(sg1.mycalc.ra_sp))
        print('actual value: ' + str(sg1.motor_ra.get_degree()))
        print('setpoint steps: ' + str(sg1.mycalc.ra_sp_steps))
        print('actual value steps: ' + str(sg1.motor_ra.get_steps()))
        print('direction: ' + str(sg1.mycalc.ra_dir))
        print('****************** DEC ******************')
        print('setpoint: ' + str(sg1.mycalc.dec_sp))
        print('actual value: ' + str(sg1.motor_dec.get_degree()))
        print('setpoint steps: ' + str(sg1.mycalc.dec_sp_steps))
        print('actual value steps: ' + str(sg1.motor_dec.get_steps()))
        print('direction: ' + str(sg1.mycalc.dec_dir))
        print('')
        print('---------------- OPTIONS -----------------')
        print('x ... exit')
        print('s ... stop the motors')
        print('m ... manual mode')
        time.sleep(0.1)
Example #2
0
 def get_wiki(self, arg):
     editurl = '/wiki/edit/' + arg
     o = self.response.out
     obj = self.repo.traverse(gitcontent.wiki_to_git_path(arg))
     if obj is not None:
         contents = babygit.babygit.obj_contents(obj)
         common.header(o, "")
         o.write('<script type="text/javascript">GH={};</script>')
         o.write('<script src="/js/typeset.js" type="text/javascript"></script>')
         o.write('<script src="/js/sexpression.js" type="text/javascript"></script>')
         o.write('<script src="/js/prover/numUtil.js" type="text/javascript"></script>')
         o.write('<script src="/js/prover/setUtil.js" type="text/javascript"></script>')
         o.write('<script src="/js/prover/tupleUtil.js" type="text/javascript"></script>')
         o.write('<script type="text/javascript"')
         o.write('  src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">')
         o.write('</script>')
         o.write('<div id="text-body">')
         # o.write("Ghilbert wiki: " + arg)
         o.write(ghmarkup.process_ghmarkup(contents, '/'))
         if self.has_write_perm:
             o.write('<div><a href="%s">Edit</a></div>\n' % urllib.quote(editurl))
         else:
             o.write('<div><a href="/account/Login">Login to edit</a></div>\n')
         o.write('<script type="text/javascript">GH.typeset.formatWiki()</script>')
     else:
         o.write('<p>No page yet for ' + cgi.escape(arg) + ', but you can <a href="' + editurl + '">create</a> one.</p>')
Example #3
0
 def get_wiki(self, arg):
     editurl = '/wiki/edit/' + arg
     o = self.response.out
     obj = self.repo.traverse(gitcontent.wiki_to_git_path(arg))
     if obj is not None:
         contents = babygit.babygit.obj_contents(obj)
         common.header(o, "")
         o.write('<script type="text/javascript">GH={};</script>')
         o.write('<script src="/js/typeset.js" type="text/javascript"></script>')
         o.write('<script src="/js/sexpression.js" type="text/javascript"></script>')
         o.write('<script src="/js/prover/numUtil.js" type="text/javascript"></script>')
         o.write('<script src="/js/prover/setUtil.js" type="text/javascript"></script>')
         o.write('<script src="/js/prover/tupleUtil.js" type="text/javascript"></script>')
         o.write('<script type="text/javascript"')
         o.write('  src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">')
         o.write('</script>')
         o.write('<div id="text-body">')
         # o.write("Ghilbert wiki: " + arg)
         o.write(ghmarkup.process_ghmarkup(contents, '/'))
         if self.has_write_perm:
             o.write('<div><a href="%s">Edit</a></div>\n' % urllib.quote(editurl))
         else:
             o.write('<div><a href="/account/Login">Login to edit</a></div>\n')
         o.write('<script type="text/javascript">GH.typeset.formatWiki()</script>')
     else:
         o.write('<p>No page yet for ' + cgi.escape(arg) + ', but you can <a href="' + editurl + '">create</a> one.</p>')
Example #4
0
 def serve_createaction(self):
     o = self.response.out
     common.header(o, 'Account creation results')
     username = self.request.get('username')
     passwd = self.request.get('password')
     identity = self.request.get('identity')
     if len(username) < 1: return self.errmsg('username must be nonempty')
     if not self.valid_username.match(username):
         return self.errmsg('username must be alphanumeric with _')
     if len(passwd) < 6: return self.errmsg('password must be at least 6 characters')
     if passwd != self.request.get('password2'):
         return self.errmsg('passwords don\'t match')
     if not self.valid_identity.match(identity):
         return self.errmsg('identity must be of the form Name &lt;email&gt;')
     if User.get_by_key_name(username):
         return self.errmsg('account ' + username + ' already exists')
     user = User(key_name = username)
     user.identity = identity
     salt = binascii.hexlify(os.urandom(16))
     user.pwsalt = salt
     user.pwhash = hashlib.sha1(salt + passwd).hexdigest()
     invite_salt = 'c1e3d755b19119fb'
     invitecode = self.request.get('invite')
     invite_hash = 'fd88b74e489c03fcfbf799a1b6d1b00169f6f24b'
     if hashlib.sha1(invite_salt + invitecode).hexdigest() == invite_hash:
         user.perms = 'write'
         o.write('<p>Invite code is valid, congratulations!</p>\n')
     user.put()
     o.write('Account ' + username + ' created.\n')
     self.session['uid'] = username
Example #5
0
    def get(self):
        o = self.response.out
        common.header(o, 'Recent changes')
        o.write('<dl>\n')
        sha = self.repo.gethead()
        max_recent = 20
        for i in range(max_recent):
            commitobj = self.repo.getobj(sha)
            commit = self.repo.parse_commit(commitobj)
            committersplit = commit['committer'].rstrip().rsplit(' ', 2)
            committer = committersplit[0]
            committimestamp = int(committersplit[1])
            committime = datetime.datetime.fromtimestamp(committimestamp)
            o.write('<dt>Commit by ' + cgi.escape(committer) + ', ' + str(committime ) + ':</dt>\n')
            if len(commit['parents']) == 0:
                break
            parentsha = commit['parents'][0]
            parentobj = self.repo.getobj(parentsha)
            parent = self.repo.parse_commit(parentobj)
            diff = self.repo.diff_tree(parent['tree'], commit['tree'])
            for fn, change in diff:
                if change == 'add':
                    changehtml = '+'
                elif change == 'delete':
                    changehtml = '-'
                elif change == 'change':
                    changehtml = '+/-'

                url = gitpath_to_url(fn)
                o.write('<dd><a href="' + urllib.quote(url) + '">' + cgi.escape(fn) + '</a> ' + changehtml + '</dd>\n')
            sha = parentsha
Example #6
0
 def serve_createaction(self):
     o = self.response.out
     common.header(o, 'Account creation results')
     username = self.request.get('username')
     passwd = self.request.get('password')
     identity = self.request.get('identity')
     if len(username) < 1: return self.errmsg('username must be nonempty')
     if not self.valid_username.match(username):
         return self.errmsg('username must be alphanumeric with _')
     if len(passwd) < 6:
         return self.errmsg('password must be at least 6 characters')
     if passwd != self.request.get('password2'):
         return self.errmsg('passwords don\'t match')
     if not self.valid_identity.match(identity):
         return self.errmsg(
             'identity must be of the form Name &lt;email&gt;')
     if User.get_by_key_name(username):
         return self.errmsg('account ' + username + ' already exists')
     user = User(key_name=username)
     user.identity = identity
     salt = binascii.hexlify(os.urandom(16))
     user.pwsalt = salt
     user.pwhash = hashlib.sha1(salt + passwd).hexdigest()
     invite_salt = 'c1e3d755b19119fb'
     invitecode = self.request.get('invite')
     invite_hash = 'fd88b74e489c03fcfbf799a1b6d1b00169f6f24b'
     if hashlib.sha1(invite_salt + invitecode).hexdigest() == invite_hash:
         user.perms = 'write'
         o.write('<p>Invite code is valid, congratulations!</p>\n')
     user.put()
     o.write('Account ' + username + ' created.\n')
     self.session['uid'] = username
Example #7
0
    def get(self):
        o = self.response.out
        common.header(o, 'Recent changes')
        o.write('<dl>\n')
        sha = self.repo.gethead()
        max_recent = 20
        for i in range(max_recent):
            commitobj = self.repo.getobj(sha)
            commit = self.repo.parse_commit(commitobj)
            committersplit = commit['committer'].rstrip().rsplit(' ', 2)
            committer = committersplit[0]
            committimestamp = int(committersplit[1])
            committime = datetime.datetime.fromtimestamp(committimestamp)
            o.write('<dt>Commit by ' + cgi.escape(committer) + ', ' +
                    str(committime) + ':</dt>\n')
            if len(commit['parents']) == 0:
                break
            parentsha = commit['parents'][0]
            parentobj = self.repo.getobj(parentsha)
            parent = self.repo.parse_commit(parentobj)
            diff = self.repo.diff_tree(parent['tree'], commit['tree'])
            for fn, change in diff:
                if change == 'add':
                    changehtml = '+'
                elif change == 'delete':
                    changehtml = '-'
                elif change == 'change':
                    changehtml = '+/-'

                url = gitpath_to_url(fn)
                o.write('<dd><a href="' + urllib.quote(url) + '">' +
                        cgi.escape(fn) + '</a> ' + changehtml + '</dd>\n')
            sha = parentsha
Example #8
0
    def get(self, arg):
        o = self.response.out
        style = self.request.get('style', 'interleaved')
        url = '/' + arg
        formatter = ProofFormatter(o, style, url)

        stylesheet = '<link rel=stylesheet href="/static/showthm.css" type="text/css">\n'
        common.header(o, 'List of theorems', stylesheet)
        o.write('<p>List of theorems in ' + cgi.escape(arg) + ':</p>\n')
        urlctx = read.UrlCtx(url)
        runner = ListThmsRunner()
        # We use the standard runner for imports and exports, but our own
        # special one for the topmost context.
        ctx = verify.VerifyCtx(urlctx, verify.run, runner.error_handler)
        try:
            runner.run(urlctx, url, ctx, DevNull())
        except NotFound:
            self.error(404)
            self.response.out.write(url + ' not found')
            return

        logging.debug(`runner.thmlist`)
        for error, thm_name, hypotheses, conclusion, lines in runner.thmlist:
            header = get_header_from_description(lines)
            if header is not None:
                formatter.write_header(header)
            lines = trim_description(lines)
            description = []
            for i in range(len(lines)):
                line = lines[i].strip()
                if line.startswith('#'):
                    description.append(line[1:].lstrip())
                elif len(line) != 0:
                    break
            descstr = ' '.join(description)
            thmurl = urllib.quote(url + '/' + thm_name)
            errstr = ''
            o.write('<div class="listthm">')
            if error:
                errstr = '<a href="/edit' + thmurl + '" class="error_indicator">●</a> '
            o.write('<div class="listthmline" ">%s<a href="%s">%s</a> %s</div>\n' % \
                (errstr, thmurl, cgi.escape(thm_name), cgi.escape(descstr)))
            if len(hypotheses) > 0:
                prefix = ''
                for hypothesis in hypotheses[1::2]:
                    o.write(prefix)
                    o.write('<span class="sexp">%s</span>\n' % cgi.escape(verify.sexp_to_string(hypothesis)))
                    prefix = ', '
                o.write(' ⊢ ')
            o.write('<span class="sexp">%s</span>\n' % cgi.escape(verify.sexp_to_string(conclusion)))
            o.write('</div>')
        o.write(
'''<script src="/js/verify.js" type="text/javascript"></script>
<script src="/js/showthm.js" type="text/javascript"></script>
<script src="/js/typeset.js" type="text/javascript"></script>
<script type="text/javascript">
GH.typeset_intermediates()
</script>
''')
Example #9
0
def q01():
    header(1)
    q1 = [123, 116, 122, 110, 175, 126, 125, 111, 111, 118, 117]
    print("Amostra ordenada:", sorted(q1))
    print("Média:", np.mean(q1), "\t", "Mediana:", np.median(q1))
    print(
        "A diferença se deve à grande variância, especialmente os valores mais altos."
    )
Example #10
0
    def serve_login(self):
        o = self.response.out
        common.header(o, 'Login')
        o.write('''<form method="post" action="/account/login">\n
<div>Username: <input type="text" name="username"></div>
<div>Password: <input type="password" name="password"></div>
<input type="submit" value="Login">
<div>Or <a href="/account/CreateAccount">create an account</a> if you don't have one.</div>
''')
Example #11
0
    def serve_login(self):
        o = self.response.out
        common.header(o, 'Login')
        o.write('''<form method="post" action="/account/login">\n
<div>Username: <input type="text" name="username"></div>
<div>Password: <input type="password" name="password"></div>
<input type="submit" value="Login">
<div>Or <a href="/account/CreateAccount">create an account</a> if you don't have one.</div>
''')
Example #12
0
def select(sg1: common.stargate):
    running = True

    while running:
        common.header(sg1, '3 star verification')

        print('star 1: ' + str(sg1.mytarget.get_star1()) + ' -> ', end='')
        common.print_status(sg1.mytarget.star1_ok)
        print('star 2: ' + str(sg1.mytarget.get_star2()) + ' -> ', end='')
        common.print_status(sg1.mytarget.star2_ok)
        print('star 3: ' + str(sg1.mytarget.get_star3()) + ' -> ', end='')
        common.print_status(sg1.mytarget.star3_ok)
        print('')

        questions = [{
            'type':
            'checkbox',
            'qmark':
            '?',
            'message':
            'please select 3 stars',
            'name':
            'tasks',
            'choices': [
                Separator('= star ='), {
                    'name': sg1.mytarget.get_star1(),
                }, {
                    'name': sg1.mytarget.get_star2(),
                }, {
                    'name': sg1.mytarget.get_star3(),
                },
                Separator('= Options ='), {
                    'name': 'debug mode',
                }, {
                    'name': 'exit'
                }
            ]
        }]

        answers = prompt(questions, style=custom_style_2)
        pprint(answers)
        print(len(answers["tasks"]))
        if (len(answers["tasks"]) > 1) and not 'exit' in answers["tasks"]:
            print('### Please choose 3 stars ###')
        elif (len(answers["tasks"]) < 1) and not 'exit' in answers["tasks"]:
            print('### Please choose 3 stars ###')
        elif not 'exit' in answers["tasks"]:
            print(answers.values())
            A = answers["tasks"][0]
            print(str(A))
            sg1.mytarget.target = (answers["tasks"][0])
            time.sleep(1)
            running = False
            observe.main(sg1, answers["tasks"][0])
        else:
            running = False
Example #13
0
 def get(self):
     o = self.response.out
     common.header(o, 'Ghilbert home')
     userobj = self.userobj
     if userobj is not None:
         template = 'FrontPageLogged'
     else:
         template = 'FrontPage'
     content = gitcontent.get_wiki_html(template)
     if content is None: content = '[wiki template for ' + template + ' is missing]'
     o.write(content)
Example #14
0
 def header(self, thmname):
     o = self.out
     self.thmname = thmname
     common.header(o, "", '<link rel=stylesheet href="/static/showthm.css" type="text/css">\n')
     o.write('<div class="title-container">')
     o.write('  <span class="title">' + cgi.escape(thmname) + "</span>\n")
     url = urllib.quote("/edit" + self.url + "/" + self.thmname)
     o.write('  <input id="show-code" type="checkbox">Show Code</input>')
     o.write('  <a class="edit-entry" href="%s"">edit</a>' % (url))
     o.write("</div>")
     o.write('<div id="proof-body">')
Example #15
0
 def get(self):
     o = self.response.out
     common.header(o, 'Ghilbert home')
     o.write('<div id="text-body">')
     userobj = self.userobj
     if userobj is not None:
         template = 'FrontPageLogged'
     else:
         template = 'FrontPage'
     content = gitcontent.get_wiki_html(template)
     if content is None:
         content = '[wiki template for ' + template + ' is missing]'
     o.write(content)
Example #16
0
 def header(self, thmname):
     o = self.out
     self.thmname = thmname
     common.header(
         o, '',
         '<link rel=stylesheet href="/static/showthm.css" type="text/css">\n'
     )
     o.write('<div class="title-container">')
     o.write('  <span class="title">' + cgi.escape(thmname) + '</span>\n')
     url = urllib.quote('/edit' + self.url + '/' + self.thmname)
     o.write('  <input id="show-code" type="checkbox">Show Code</input>')
     o.write('  <a class="edit-entry" href="%s"">edit</a>' % (url))
     o.write('</div>')
     o.write('<div id="proof-body">')
Example #17
0
 def get_wiki(self, arg):
     editurl = '/wiki/edit/' + arg
     o = self.response.out
     obj = self.repo.traverse(gitcontent.wiki_to_git_path(arg))
     if obj is not None:
         contents = babygit.babygit.obj_contents(obj)
         common.header(o, "Ghilbert wiki: " + arg)
         o.write(ghmarkup.process_ghmarkup(contents, '/'))
         if self.has_write_perm:
             o.write('<div><a href="%s">Edit</a></div>\n' % urllib.quote(editurl))
         else:
             o.write('<div><a href="/account/Login">Login to edit</a></div>\n')
     else:
         o.write('<p>No page yet for ' + cgi.escape(arg) + ', but you can <a href="' + editurl + '">create</a> one.</p>')
Example #18
0
 def serve_loginaction(self):
     o = self.response.out
     common.header(o, 'Login results')
     username = self.request.get('username')
     passwd = self.request.get('password')
     if not self.valid_username.match(username):
         return self.errmsg('username must be alphanumeric with _')
     user = User.get_by_key_name(username)
     if not user:
         return self.errmsg('no such user exists')
     logging.debug( ` (user.pwhash, hashlib.sha1(user.pwsalt + passwd)) `)
     if not check_user_pass(user, passwd):
         return self.errmsg('password doesn\'t match')
     self.session['uid'] = username
     o.write('Login ok!')
Example #19
0
 def serve_loginaction(self):
     o = self.response.out
     common.header(o, 'Login results')
     username = self.request.get('username')
     passwd = self.request.get('password')
     if not self.valid_username.match(username):
         return self.errmsg('username must be alphanumeric with _')
     user = User.get_by_key_name(username)
     if not user:
         return self.errmsg('no such user exists')
     logging.debug(`(user.pwhash, hashlib.sha1(user.pwsalt + passwd))`)
     if not check_user_pass(user, passwd):
         return self.errmsg('password doesn\'t match')
     self.session['uid'] = username
     o.write('Login ok!')
Example #20
0
def checkAndCloseExpiredInstances(results_directory):
    #common = imp.load_module('common', *imp.find_module('common', [os.path.join(os.path.dirname(__file__), '..', 'cassandralauncher')]))
    import common
    config, KEY_PAIR, PEM_HOME, HOST_FILE, PEM_FILE = common.header()
    conn = boto.connect_ec2(config.get('EC2', 'aws_access_key_id'),
                            config.get('EC2', 'aws_secret_access_key'))
    reservations = dict(map(lambda x: (x.id, x), conn.get_all_instances()))
    result_files = glob(os.path.join(results_directory, '*.results'))

    print 'checking %s' % result_files
    for result_file in result_files:
        results = None
        with open(result_file, 'r') as f:
            results = dict(map(lambda l: l.strip().split('='), f.readlines()))

        if time.time() - float(results['launch_time']) > float(
                results['ttl_seconds']):
            res = reservations.get(results['reservation_id'])
            if res != None:
                print 'killing %s' % res.id
                instances = [
                    i.id for i in res.instances if i.state != 'terminated'
                ]
                if len(instances) > 0:
                    conn.terminate_instances(instances)
            else:
                os.rename(result_file, '%s.%s' % (result_file, 'done'))
Example #21
0
        def layout_func():

            counts = get_leaderboard_df(self.series_list)

            counts["Proportion"] = counts["Total"] / counts["Total"].sum()

            table = dbc.Table.from_dataframe(counts,
                                             index=True,
                                             index_label="Method")

            # Apply URLS to index
            for row in table.children[1].children:
                state = urlencode({"methods": [row.children[0].children]},
                                  doseq=True)
                row.children[0].children = html.A(row.children[0].children,
                                                  href=f"/search/?{state}")

            return html.Div(header() + [
                dcc.Location(id="url", refresh=False),
                dbc.Container([
                    breadcrumb_layout([("Home", "/"), (f"{self.title}", "")]),
                    html.H2(self.title),
                    table,
                ] + footer()),
            ])
Example #22
0
def q04():
    header(4)
    q4 = [
        6.72, 6.77, 6.82, 6.70, 6.78, 6.70, 6.62, 6.75, 6.66, 6.66, 6.64, 6.76,
        6.73, 6.80, 6.72, 6.76, 6.76, 6.68, 6.66, 6.62, 6.72, 6.76, 6.70, 6.78,
        6.76, 6.67, 6.70, 6.72, 6.74, 6.81, 6.79, 6.78, 6.66, 6.76, 6.76, 6.72
    ]
    print("Amostra ordenada:", sorted(q4))
    print("Média:", np.mean(q4), "\t", "Mediana:", np.median(q4), "\t",
          "Desvio-padrão:", np.std(q4))
    mia.rel_freq(q4, [6.6, 6.65, 6.7, 6.75, 6.8, 6.85])
    mia.hist_rel_freq(q4,
                      label="Diâmetro",
                      mu=np.median(q4),
                      sigma=np.std(q4),
                      bins=np.arange(6.6, 6.86, 0.05))
Example #23
0
def q05():
    header(5)
    q5 = [
        3.79, 2.99, 2.77, 2.91, 3.10, 1.84, 2.52, 3.22, 2.45, 2.14, 2.67, 2.52,
        2.71, 2.75, 3.57, 3.85, 3.36, 2.05, 2.89, 2.83, 3.13, 2.44, 2.10, 3.71,
        3.14, 3.54, 2.37, 2.68, 3.51, 3.37
    ]
    print("Média:", np.mean(q5), "\t", "Mediana:", np.median(q5), "\t",
          "Desvio-padrão:", np.std(q5))
    mia.rel_freq(q5, [1.5, 2., 2.5, 3., 3.5, 4.])
    mia.hist_rel_freq(q5,
                      label="Valor em US$, por aluno",
                      mu=np.median(q5),
                      sigma=np.std(q5),
                      bins=np.arange(1.5, 4.1, 0.5))
    mia.StemAndLeaf(q5, 2).print(False)
Example #24
0
    def serve_createaccount(self):
        o = self.response.out
        common.header(o, 'Create account')
        invitecode = self.request.get('invite')
        entropy = binascii.b2a_base64(os.urandom(18))
        o.write('''<form method="post" action="/account/create">\n
<div>Username: <input type="text" name="username"></div>
<div>Password: <input type="password" name="password"></div>
<div>Password again: <input type="password" name="password2"></div>
<div>Git identity: <input type="text" name="identity"></div>
<input type="hidden" name="invite" value="%s">
<input type="submit" value="Create">
''' % urllib.quote(invitecode))
        templ = gitcontent.get_wiki_html('CreateAccountTempl')
        if templ is None:
            templ = "[Warning: CreateAccountTempl is missing]"
        o.write(templ.replace('$entropy', entropy))
Example #25
0
    def serve_createaccount(self):
        o = self.response.out
        common.header(o, 'Create account')
        invitecode = self.request.get('invite')
        entropy = binascii.b2a_base64(os.urandom(18))
        o.write('''<form method="post" action="/account/create">\n
<div>Username: <input type="text" name="username"></div>
<div>Password: <input type="password" name="password"></div>
<div>Password again: <input type="password" name="password2"></div>
<div>Git identity: <input type="text" name="identity"></div>
<input type="hidden" name="invite" value="%s">
<input type="submit" value="Create">
''' % urllib.quote(invitecode))
        templ = gitcontent.get_wiki_html('CreateAccountTempl')
        if templ is None:
            templ = "[Warning: CreateAccountTempl is missing]"
        o.write(templ.replace('$entropy', entropy))
Example #26
0
def q06():
    header(6)
    q6 = {
        700: [145, 105, 260, 330],
        1000: [250, 195, 375, 480],
        1300: [150, 180, 420, 750]
    }
    q6mean = {}
    for k, v in q6.items():
        q6mean[k] = np.mean(v)
    plt.plot(list(q6mean.keys()), list(q6mean.values()))
    q6by_spec = {}
    for k, v in q6.items():
        for i in range(1, len(v) + 1):
            if not (i in q6by_spec):
                q6by_spec[i] = []
            q6by_spec[i].append(v[i - 1])
    for i in q6by_spec.keys():
        plt.plot(list(q6.keys()), q6by_spec[i])
Example #27
0
def q03():
    header(3)
    q3 = [
        23, 60, 79, 32, 57, 74, 52, 70, 82, 36, 80, 77, 81, 95, 41, 65, 92, 85,
        55, 76, 52, 10, 64, 75, 78, 25, 80, 98, 81, 67, 41, 71, 83, 54, 64, 72,
        88, 62, 74, 43, 60, 78, 89, 76, 84, 48, 84, 90, 15, 79, 34, 67, 17, 82,
        69, 74, 63, 80, 85, 61
    ]
    print("Amostra ordenada", sorted(q3))
    # Diagrama de ramos e folhas.
    s_l = mia.StemAndLeaf(q3)
    s_l.print()
    # Frequencias.
    mia.rel_freq(q3, [0, 25, 50, 75, 100])
    # Gráfico de Histograma.
    mia.hist_rel_freq(q3,
                      label="Nota",
                      mu=np.median(q3),
                      sigma=np.std(q3),
                      bins=(0, 25, 50, 75, 100))
    print("Média:", np.mean(q3), "\t", "Mediana:", np.median(q3), "\t",
          "Desvio-padrão:", np.std(q3))
Example #28
0
 def get(self, arg):
     o = self.response.out
     obj = self.repo.traverse(arg)
     if obj is None:
         self.error(404)
         self.response.out.write('404 not found')
         return
     elif babygit.babygit.obj_type(obj) == 'blob':
         self.response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
         o.write(babygit.babygit.obj_contents(obj))
     else:
         if len(arg) and not arg.endswith('/'):
             url = self.request.url + '/'
             self.redirect(url)
             return
         common.header(o, cgi.escape('Contents of ' + arg))
         o.write('<ul>')
         for mode, name, sha in self.repo.parse_tree(obj):
             fn = name
             # Todo: get header from file contents
             if mode == '40000': fn += '/'
             o.write('<li><a href="' + urllib.quote(fn) + '">' + cgi.escape(fn) + '</a></li>')
Example #29
0
 def get(self, arg):
     o = self.response.out
     obj = self.repo.traverse(arg)
     if obj is None:
         self.error(404)
         self.response.out.write('404 not found')
         return
     elif babygit.babygit.obj_type(obj) == 'blob':
         self.response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
         o.write(babygit.babygit.obj_contents(obj))
     else:
         if len(arg) and not arg.endswith('/'):
             url = self.request.url + '/'
             self.redirect(url)
             return
         common.header(o, cgi.escape('Contents of ' + arg))
         o.write('<ul>')
         for mode, name, sha in self.repo.parse_tree(obj):
             fn = name
             # Todo: get header from file contents
             if mode == '40000': fn += '/'
             o.write('<li><a href="' + urllib.quote(fn) + '">' +
                     cgi.escape(fn) + '</a></li>')
Example #30
0
 def get(self, arg):
     o = self.response.out
     obj = self.repo.traverse(arg)
     if obj is None:
         self.error(404)
         self.response.out.write("404 not found")
         return
     elif babygit.babygit.obj_type(obj) == "blob":
         self.response.headers["Content-Type"] = "text/plain; charset=UTF-8"
         o.write(babygit.babygit.obj_contents(obj))
     else:
         if len(arg) and not arg.endswith("/"):
             url = self.request.url + "/"
             self.redirect(url)
             return
         common.header(o, cgi.escape("Contents of " + arg))
         o.write("<ul>")
         for mode, name, sha in self.repo.parse_tree(obj):
             fn = name
             # Todo: get header from file contents
             if mode == "40000":
                 fn += "/"
             o.write('<li><a href="' + urllib.quote(fn) + '">' + cgi.escape(fn) + "</a></li>")
Example #31
0
    def prepare(self):
        '''
        Prepare to run test

        Does necessary initialization before attempting to run.
        Must be done before run.

        @return: True if ready to run test, False otherwise
        '''
        # Iterate over each layer
        for layer, layerdata in sorted(self.klljson['Layers'].items()):
            logger.debug(header("Layer {}".format(layer)))
            for trigger, triggerdata in sorted(layerdata.items()):
                logger.debug("Trigger: {}", trigger)
                # Prepare a TriggerResultEval
                evalpair = TriggerResultEval(self, trigger, triggerdata)

                # Prepare TestResult
                testresult = KLLTestUnitResult(self, None, evalpair, layer)
                self.testresults.append(testresult)

        return True
Example #32
0
    def prepare(self):
        '''
        Prepare to run test

        Does necessary initialization before attempting to run.
        Must be done before run.

        @return: True if ready to run test, False otherwise
        '''
        # Iterate over each layer
        for layer, layerdata in sorted(self.klljson['Layers'].items()):
            logger.debug(header("Layer {}".format(layer)))
            for trigger, triggerdata in sorted(layerdata.items()):
                logger.debug("Trigger: {}", trigger)
                # Prepare a TriggerResultEval
                evalpair = TriggerResultEval(self, trigger, triggerdata)

                # Prepare TestResult
                testresult = KLLTestUnitResult(self, None, evalpair, layer)
                self.testresults.append(testresult)

        return True
Example #33
0
def checkAndCloseExpiredInstances(results_directory):
    #common = imp.load_module('common', *imp.find_module('common', [os.path.join(os.path.dirname(__file__), '..', 'cassandralauncher')]))
    import common
    config, KEY_PAIR, PEM_HOME, HOST_FILE, PEM_FILE = common.header()
    conn = boto.connect_ec2(config.get('EC2', 'aws_access_key_id'), config.get('EC2', 'aws_secret_access_key'))
    reservations = dict(map(lambda x: (x.id, x), conn.get_all_instances()))
    result_files = glob(os.path.join(results_directory, '*.results'))
    
    print 'checking %s' % result_files
    for result_file in result_files:
        results = None
        with open(result_file, 'r') as f:
            results = dict(map(lambda l: l.strip().split('='), f.readlines()))

        if time.time() - float(results['launch_time']) > float(results['ttl_seconds']):
            res = reservations.get(results['reservation_id'])
            if res != None:
                print 'killing %s' % res.id
                instances = [i.id for i in res.instances if i.state != 'terminated']
                if len(instances) > 0:
                    conn.terminate_instances(instances)
            else:
                os.rename(result_file, '%s.%s' % (result_file, 'done'))
Example #34
0
def q02():
    header(2)
    print("Sim. ...")
Example #35
0
    def setup(self):

        self.config.suppress_callback_exceptions = True

        # Dynamically load tags
        data_sources_json_file = open("../shared_config/data_sources.json")
        self.series_list = json.load(data_sources_json_file)
        data_sources_json_file.close()

        self.layout = html.Div(header() + [
            dcc.Location(id="url", refresh=False),
            dbc.Container([
                breadcrumb_layout([("Home", "/"), ("Filter", "")]),
                dbc.Row([
                    dbc.Col(id="filter_panel", lg=3, sm=3),
                    dbc.Col(
                        [
                            html.H4("Results"),
                            dcc.Loading(html.Div(id="filter_results")),
                        ],
                        lg=9,
                        sm=9,
                    ),
                ]),
            ] + footer(), ),
        ])

        def filter_panel_children(params, tags, methods):

            children = [
                html.H4("Filters"),
                dbc.FormGroup([
                    dbc.Label("Name"),
                    apply_default_value(params)(dbc.Input)(
                        id="name",
                        placeholder="Name of a series...",
                        type="search",
                        value="",
                    ),
                    dbc.FormText("Type something in the box above"),
                ]),
                dbc.FormGroup([
                    dbc.Label("Tags"),
                    apply_default_value(params)(dbc.Checklist)(
                        options=[{
                            "label": t,
                            "value": t
                        } for t in tags],
                        value=[],
                        id="tags",
                    ),
                ]),
                dbc.FormGroup([
                    dbc.Label("Method"),
                    apply_default_value(params)(dbc.Checklist)(
                        options=[{
                            "label": m,
                            "value": m
                        } for m in methods],
                        value=[],
                        id="methods",
                    ),
                ]),
            ]

            return children

        component_ids = ["name", "tags", "methods"]

        @self.callback(Output("filter_panel", "children"),
                       [Input("url", "href")])
        @location_ignore_null([Input("url", "href")], "url")
        def filter_panel(value):

            parse_result = parse_state(value)

            all_tags = []

            for series_dict in self.series_list:
                all_tags.extend(series_dict["tags"])

            all_tags = sorted(set(all_tags))

            # Dynamically load methods
            stats = get_forecast_data("statistics")
            all_methods = sorted(stats["models_used"])

            return filter_panel_children(parse_result, all_tags, all_methods)

        @self.callback(
            Output("url", "search"),
            inputs=[Input(i, "value") for i in component_ids],
        )
        @dash_kwarg([Input(i, "value") for i in component_ids])
        def update_url_state(**kwargs):

            state = urlencode(kwargs, doseq=True)

            return f"?{state}"

        @self.callback(
            Output("filter_results", "children"),
            [Input(i, "value") for i in component_ids],
        )
        @dash_kwarg([Input(i, "value") for i in component_ids])
        def filter_results(**kwargs):

            # Fix up name
            if type(kwargs["name"]) == list:
                kwargs["name"] = "".join(kwargs["name"])

            # Filtering by AND-ing conditions together

            forecast_series_dicts = {}

            for series_dict in self.series_list:
                try:
                    forecast_series_dicts[
                        series_dict["title"]] = get_forecast_data(
                            series_dict["title"])
                except FileNotFoundError:
                    continue

            filters = {
                "name": match_names,
                "tags": match_tags,
                "methods": match_methods,
            }

            list_filter_matches = []

            for filter_key, filter_fn in filters.items():
                matched_series_names = filter_fn(forecast_series_dicts,
                                                 kwargs[filter_key])
                list_filter_matches.append(matched_series_names)

            unique_series_titles = list(
                sorted(set.intersection(*list_filter_matches)))

            if len(unique_series_titles) > 0:

                results_list = []

                for item_title in unique_series_titles:
                    series_data = forecast_series_dicts[item_title]
                    url_title = urlencode({"title": item_title})
                    thumbnail_figure = get_thumbnail_figure(series_data)

                    results_list.append(
                        html.Div([
                            html.A(
                                [
                                    html.H5(item_title),
                                    dcc.Graph(
                                        figure=thumbnail_figure,
                                        config={"displayModeBar": False},
                                    ),
                                ],
                                href=f"/series?{url_title}",
                            ),
                            html.Hr(),
                        ]))

                results = [
                    html.
                    P(f"{len(unique_series_titles)} result{'s' if len(unique_series_titles) > 1 else ''} found"
                      ),
                    html.Div(results_list),
                ]
            else:
                results = [html.P("No results found")]

            return results
Example #36
0
 def header(self, thmname):
     o = self.out
     self.thmname = thmname
     common.header(o, "Proof of " + thmname,
         '<link rel=stylesheet href="/static/showthm.css" type="text/css">\n')
Example #37
0
    def setup(self):

        self.layout = html.Div(header() + [
            dcc.Location(id="url", refresh=False),
            dbc.Container([
                breadcrumb_layout([("Home", "/"), ("Series", "")]),
                dcc.Loading(dbc.Row([dbc.Col(id="series_graph", lg=12)])),
                dbc.Row([
                    dbc.Col(
                        [
                            dbc.FormGroup([
                                dbc.Label("Forecast Method"),
                                dcc.Dropdown(
                                    id="model_selector",
                                    clearable=False,
                                ),
                            ]),
                            dcc.Loading(html.Div(id="meta_data_list")),
                        ],
                        lg=6,
                    ),
                    dbc.Col(
                        [
                            dbc.FormGroup([
                                dcc.Dropdown(
                                    options=[
                                        {
                                            "label": "Forecast",
                                            "value": "Forecast",
                                        },
                                        {
                                            "label": "50% CI",
                                            "value": "CI_50",
                                        },
                                        {
                                            "label": "75% CI",
                                            "value": "CI_75",
                                        },
                                        {
                                            "label": "95% CI",
                                            "value": "CI_95",
                                        },
                                    ],
                                    value="Forecast",
                                    clearable=False,
                                    id="forecast_table_selector",
                                ),
                            ]),
                            dcc.Loading(html.Div(id="forecast_table")),
                        ],
                        lg=6,
                    ),
                ]),
            ] + footer()),
        ])

        def series_input(inputs, location_id="url"):
            def accept_func(func):
                @wraps(func)
                def wrapper(*args):
                    input_names = [item.component_id for item in inputs]
                    kwargs_dict = dict(zip(input_names, args))

                    parse_result = parse_state(kwargs_dict[location_id])

                    if "title" in parse_result:
                        title = parse_result["title"][0]
                        series_data_dict = get_forecast_data(title)

                        del kwargs_dict[location_id]
                        return func(series_data_dict, **kwargs_dict)
                    else:
                        raise PreventUpdate

                return wrapper

            return accept_func

        inputs = [Input("url", "href")]

        @self.callback(Output("breadcrumb", "children"), inputs)
        @location_ignore_null(inputs, location_id="url")
        @series_input(inputs, location_id="url")
        def update_breadcrumb(series_data_dict):

            return (series_data_dict["data_source_dict"]["short_title"]
                    if "short_title" in series_data_dict["data_source_dict"]
                    else series_data_dict["data_source_dict"]["title"])

        @self.callback(
            Output("series_graph", "children"),
            inputs + [Input("model_selector", "value")],
        )
        @location_ignore_null(inputs, location_id="url")
        @series_input(inputs + [Input("model_selector", "value")],
                      location_id="url")
        def update_series_graph(series_data_dict, **kwargs):

            model_name = kwargs["model_selector"]

            series_figure = get_series_figure(series_data_dict, model_name)

            series_graph = dcc.Graph(
                figure=series_figure,
                config={
                    "modeBarButtonsToRemove": [
                        "sendDataToCloud",
                        "autoScale2d",
                        "hoverClosestCartesian",
                        "hoverCompareCartesian",
                        "lasso2d",
                        "select2d",
                        "toggleSpikelines",
                    ],
                    "displaylogo":
                    False,
                },
            )

            return series_graph

        @self.callback(
            [
                Output("model_selector", "options"),
                Output("model_selector", "value"),
            ],
            inputs,
        )
        @location_ignore_null(inputs, location_id="url")
        @series_input(inputs, location_id="url")
        def update_model_selector(series_data_dict):

            best_model_name = select_best_model(series_data_dict)

            stats = get_forecast_data("statistics")
            all_methods = sorted(stats["models_used"])

            all_methods_dict = dict(zip(all_methods, all_methods))

            all_methods_dict[
                best_model_name] = f"{best_model_name} - Best Model"

            model_select_options = [{
                "label": v,
                "value": k
            } for k, v in all_methods_dict.items()]

            return model_select_options, best_model_name

        @self.callback(
            Output("meta_data_list", "children"),
            inputs + [Input("model_selector", "value")],
        )
        @location_ignore_null(inputs, location_id="url")
        @series_input(inputs + [Input("model_selector", "value")],
                      location_id="url")
        def update_meta_data_list(series_data_dict, **kwargs):

            model_name = kwargs["model_selector"]

            model_description = series_data_dict["all_forecasts"][model_name][
                "model_description"]
            if model_description == model_name:
                model_description = ""

            model_cv_score = series_data_dict["all_forecasts"][model_name][
                "cv_score"]

            return dbc.ListGroup([
                dbc.ListGroupItem([
                    dbc.ListGroupItemHeading("Model Details"),
                    dbc.ListGroupItemText([
                        html.P(model_name),
                        html.P(model_description),
                        html.P("CV score: %f" % model_cv_score),
                    ]),
                ]),
                dbc.ListGroupItem([
                    dbc.ListGroupItemHeading("Forecast Updated At"),
                    dbc.ListGroupItemText(
                        series_data_dict["forecasted_at"].strftime(
                            "%Y-%m-%d %H:%M:%S")),
                ]),
                dbc.ListGroupItem([
                    dbc.ListGroupItemHeading("Data Collected At"),
                    dbc.ListGroupItemText(
                        series_data_dict["downloaded_dict"]
                        ["downloaded_at"].strftime("%Y-%m-%d %H:%M:%S")),
                ]),
                dbc.ListGroupItem([
                    dbc.ListGroupItemHeading("Data Source"),
                    dbc.ListGroupItemText([
                        html.A(
                            series_data_dict["data_source_dict"]["url"],
                            href=series_data_dict["data_source_dict"]["url"],
                        )
                    ]),
                ]),
            ])

        @self.callback(
            Output("forecast_table", "children"),
            inputs + [
                Input("forecast_table_selector", "value"),
                Input("model_selector", "value"),
            ],
        )
        @location_ignore_null(inputs, location_id="url")
        @series_input(
            inputs + [
                Input("forecast_table_selector", "value"),
                Input("model_selector", "value"),
            ],
            location_id="url",
        )
        def update_forecast_table(series_data_dict, **kwargs):

            selected_column_map = {
                "Forecast": ["Forecast"],
                "CI_50": ["LB_50", "UB_50"],
                "CI_75": ["LB_75", "UB_75"],
                "CI_95": ["LB_95", "UB_95"],
            }

            model_name = kwargs["model_selector"]

            dataframe = series_data_dict["all_forecasts"][model_name][
                "forecast_df"]

            column_name_map = {"forecast": "Forecast"}

            dataframe = dataframe.rename(
                column_name_map, axis=1)[selected_column_map[
                    kwargs["forecast_table_selector"]]].round(4)

            dataframe.index = dataframe.index.strftime("%Y-%m-%d %H:%M:%S")

            table = dbc.Table.from_dataframe(dataframe,
                                             index=True,
                                             index_label="Date")

            return table
Example #38
0
# Enabled vote debug mode
i.control.cmd('setVoteDebugMode')(1)

# Enable layer debug mode
i.control.cmd('setLayerDebugMode')(1)

# Enable pending trigger debug mode
i.control.cmd('setTriggerPendingDebugMode')(1)

# Enable output module debug mode
i.control.cmd('setOutputDebugMode')(2)

### Test ###

logger.info(header("-- 1 key test --"))

# Drop to cli, type exit in the displayed terminal to continue
#i.control.cli()

# Read current keyboard state
logger.info(data.usb_keyboard())

# Press key 0x00
i.control.cmd('addScanCode')(0x01)

# Run processing loop
i.control.loop(1)

logger.info(" TPending {}", data.pending_trigger_list())
logger.info(data.usb_keyboard())
Example #39
0
 def serve_logout(self):
     o = self.response.out
     common.header(o, 'Logged out')
     o.write('successfully logged out')
     if 'uid' in self.session:
         del self.session['uid']
Example #40
0
    def setup(self):

        contributors = json.load(open("static_files/profiles.json"))[
            "contributors"
        ]

        research_team = json.load(open("static_files/profiles.json"))[
            "research_team"
        ]

        self.layout = html.Div(
            header()
            + [
                dcc.Location(id="url", refresh=False),
                dbc.Container(
                    [
                        breadcrumb_layout(
                            [("Home", "/"), (f"{self.title}", "")]
                        ),
                        dbc.Row(
                            [
                                dbc.Col(
                                    [
                                        html.H2("About"),
                                        html.P(
                                            [
                                                """
This website is an intuitive tool that makes business forecasting accessible to the wider community. You can easily obtain predictions of commonly used variables together with the uncertainty around them. The website implements classical forecasting models as well as the novel models and methods developed by the members of the Time Series and Forecasting (TSF) research group in the University of Sydney Business School. The website visualizes and summarizes the forecasting results in an easy-to-understand manner. The forecasts are updated daily and include the latest publicly available information. It is an open-source project under the AGPL license, see 
                                                """,
                                                html.A("https://github.com/forecastlab/forecast_dash", href="https://github.com/forecastlab/forecast_dash"
                                                ),
                                                " .",
                                            ]
                                        ),
                                    ],
                                    lg=6,
                                ),
                                dbc.Col(
                                    [
                                        dbc.Jumbotron(
                                            [
                                                html.H1("Our Mission"),
                                                html.Ol(
                                                    [
                                                        html.Li(
                                                            "To make forecasting models accessible to everyone."
                                                        ),
                                                        html.Li(
                                                            "To provide the latest financial and economic forecasts of the commonly used time series."
                                                        ),
                                                    ]
                                                ),
                                            ]
                                        )
                                    ],
                                    lg=6,
                                ),
                            ]
                        ),
                        dbc.Row(
                            dbc.Col(
                                html.H2(
                                    "Powered By",
                                    style={"margin-bottom": "32px"},
                                ),
                                lg=12,
                            )
                        ),
                        dbc.Row(
                            parse_poweredby("static_files/poweredby.json")
                        ),
                        dbc.Row(
                            dbc.Col(
                                html.H2(
                                    "Core Contributors",
                                    style={"margin-bottom": "32px"},
                                ),
                                lg=12,
                            )
                        ),
                        dbc.Row(parse_people(contributors)),
                        dbc.Row(
                            dbc.Col(
                                html.H2(
                                    "Research Group Leaders",
                                    style={"margin-bottom": "32px"},
                                ),
                                lg=12,
                            )
                        ),
                        dbc.Row(parse_people(research_team)),
                    ]
                    + footer(),
                    style={"margin-bottom": "64px"},
                    className="mb-5",
                ),
            ]
        )
Example #41
0
i.control.cmd('setVoteDebugMode')( 1 )

# Enable layer debug mode
i.control.cmd('setLayerDebugMode')(1)

# Enable pending trigger debug mode
i.control.cmd('setTriggerPendingDebugMode')(1)

# Enable output module debug mode
i.control.cmd('setOutputDebugMode')(2)



### Test ###

logger.info(header("-- 1 key test --"))

# Drop to cli, type exit in the displayed terminal to continue
#i.control.cli()

# Read current keyboard state
logger.info(data.usb_keyboard())


# Press key 0x00
i.control.cmd('addScanCode')( 0x01 )

# Run processing loop
i.control.loop(1)

logger.info(" TPending {}", data.pending_trigger_list())
import shlex
import subprocess
import sys
import tempfile
import time
import urllib2

import ec2
import common


# Globals
private_ips = []
public_ips = []

config, KEY_PAIR, PEM_HOME, HOST_FILE, PEM_FILE = common.header()
cli_options = {}


#################################
# Execution and SSH commands


def exe(command, wait=True):
    """Execute a subprocess command"""

    # Open a subprocess to run your command
    process = subprocess.Popen(shlex.split(str(command)), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if wait:
        read = process.communicate()
        return read
Example #43
0
})

f = Figlet(font='slant')

# Storage for all Data
sg1 = common.stargate()


# =============================================================================      
# ==================================== top ====================================
# ============================================================================= 

# list with options
running = True
while running:
    common.header(sg1, 'top')
    questions = [
        {
            'type': 'checkbox',
            'qmark': '?',
            'message': 'Select task',
            'name': 'tasks',
            'choices': [ 
                Separator('= first setup ='),
                {
                    'name': 'nav',
                },
                {
                    'name': 'gps',
                },
                {
Example #44
0
### Setup ###

# Logger (current file and parent directory only)
logger = kiilogger.get_logger(os.path.join(os.path.split(__file__)[0], os.path.basename(__file__)))
logging.root.setLevel(logging.INFO)


# Reference to callback datastructure
data = i.control.data



### Basic CLI test ###

logger.info(header("-- Basic CLI test --"))

# Start background thread to handle cli processing
def background():
    '''
    Drop to cli, type exit in the displayed terminal to continue
    '''
    i.control.cli()

thread = threading.Thread(target=background)
thread.daemon = True
thread.start()

# Wait for interface to initialize
time.sleep(0.5)
Example #45
0
logging.root.setLevel(logging.INFO)


# Reference to callback datastructure
data = i.control.data



### Test ###

# Drop to cli, type exit in the displayed terminal to continue
#i.control.cli()


## Loopback Tests ##
logger.info(header("-- RawIO Loopback tests --"))

i.control.cmd('setRawIOPacketSize')( 64 )
i.control.cmd('setRawIOLoopback')( True )

# Send basic test packet, 1 byte length, payload 0xAC
logger.info(header("- Single byte packet payload -"))
i.control.cmd('HIDIO_test_2_request')( 1, 0xAC )


# A single processing loop (receivves, then sends packets)
i.control.loop(1)

# Check contents of incoming buffer (should be empty in loopback mode)
logger.info("Incoming Buf: {}", data.rawio_incoming_buffer)
check( len( data.rawio_incoming_buffer ) == 0 )
Example #46
0
# Logger (current file and parent directory only)
logger = kiilogger.get_logger(os.path.join(os.path.split(__file__)[0], os.path.basename(__file__)))
logging.root.setLevel(logging.INFO)


# Reference to callback datastructure
data = i.control.data



### Test ###

# Drop to cli, type exit in the displayed terminal to continue
#i.control.cli()

logger.info(header("-Pixel Test-"))

# Read status of animation display buffers
logger.debug(i.control.cmd('animationDisplayBuffers')())
i.control.cmd('rectDisp')()

# Add Animation, index 3, to Stack (testanimation)
i.control.cmd('addAnimation')(name='testanimation')

# Read animation stack info
logger.info("Expecting Stack Size: 1 Got: {}", i.control.cmd('animationStackInfo')().size)
check( i.control.cmd('animationStackInfo')().size == 1 )

# Loop once
i.control.loop(1)
Example #47
0
def main():

    # ma.optimize('returns', 'inc_factor')
    # ma.optimize('risk', 'inc_factor')
    # ma.optimize('returns', 'max_factor')
    # ma.optimize('risk', 'max_factor')
    # ma.stats_inc_factor()
    # sys.exit(0)

    header('Loading Data')
    common.set_nav_data()

    header('Regular SIP')
    regularSip.run()

    header('Flex STP')
    flexStp.run()

    header('Equal Weighted')
    equalWt.run()

    header('Normal MA')
    ma.run('normal', 3)
    ma.run('normal', 6)
    ma.run('normal', 9)
    ma.run('normal', 12)

    header('Inverted MA')
    ma.run('inverted', 3)
    ma.run('inverted', 6)
    ma.run('inverted', 9)
    ma.run('inverted', 12)

    header('Top Ranked')
    ranked.create_out_file()
    ranked.run('top', 1)
    ranked.run('top', 2)
    ranked.run('top', 3)

    header('Bottom Ranked')
    ranked.run('bottom', 3)
    ranked.run('bottom', 2)
    ranked.run('bottom', 1)

    header('Ranked MA')
    rankedMA.create_out_file()
    for rank_type in ['top', 'bottom']:
        for rank_val in [1, 2, 3]:
            for ma_type in ['normal', 'inverted']:
                for ma_val in [3, 6, 9, 12]:
                    rankedMA.run(rank_type, rank_val, ma_type, ma_val)

    # rankedMA.run('top', 2, 'normal', 12)
    # rankedMA.run('top', 1, 'normal', 3)

    header('Timed')
    timed.run()

    header('Summary')
    summary.run()

    print '\n'
Example #48
0
    logger.info("Loop {} - Expecting Stack Size: 1 Got: {}", index, i.control.cmd('animationStackInfo')().size)
    check( i.control.cmd('animationStackInfo')().size == 1 )

    # Loop once
    i.control.cmd('setFrameState')(2)
    i.control.loop(1)

    # Show output
    i.control.cmd('rectDisp')()

#i.control.cmd('removeScanCode')( 0x3C )
i.control.loop(1)

if False:

    logger.info(header("-Rainbow Animation Test-"))

    # Add Animation, index 5, to Stack (z2_rainbow_fill_interp)
    i.control.cmd('addAnimation')(index=2, pfunc=1) # TODO

    # Loop 13 times, displaying each time
    for index in range( 2 ):
        # Read animation stack info
        logger.info("Loop {} - Expecting Stack Size: 1 Got: {}", index, i.control.cmd('animationStackInfo')().size)
        check( i.control.cmd('animationStackInfo')().size == 1 )

        # Loop once
        i.control.cmd('setFrameState')(2)
        i.control.loop(1)

        # Show output
Example #49
0
        def layout_func():

            return html.Div(header() + [
                dcc.Location(id="url", refresh=False),
                # Mission Statement
                dbc.Jumbotron(
                    [
                        dbc.Container([
                            html.H1("Our Mission", className="display-4"),
                            html.Hr(),
                            html.Ul([
                                html.Li(
                                    "To make forecasting models accessible to everyone.",
                                    className="lead",
                                ),
                                html.Li(
                                    "To provide the latest economic and financial forecasts of commonly used time series.",
                                    className="lead",
                                ),
                            ]),
                        ]),
                    ],
                    fluid=True,
                    className="d-none d-md-block",
                ),
                # Main Body
                dbc.Container([
                    # Row 1 - Featured and Latest News
                    dbc.Row(
                        [
                            dbc.Col(
                                [
                                    html.H3(
                                        "Featured Series",
                                        style={"text-align": "center"},
                                    ),
                                    html.A(
                                        [
                                            dcc.Graph(
                                                figure=get_thumbnail_figure(
                                                    get_forecast_data(
                                                        feature_series_title)),
                                                config={
                                                    "displayModeBar": False
                                                },
                                            )
                                        ],
                                        href=
                                        f"/series?{urlencode({'title': feature_series_title})}",
                                    ),
                                ],
                                lg=8,
                                # className="border-right",
                            ),
                            component_news_4col(),
                        ],
                        style={"margin-top": "16px"},
                    ),
                    # Row 2 - US Snapshot
                    component_figs_3col(
                        "US Snapshot 🇺🇸",
                        [
                            "US Unemployment",
                            "US GDP Growth",
                            "US Personal Consumption Expenditures: Chain-type Price Index (% Change, 1 Year)",
                        ],
                    ),
                    # Row 3 - Leaderboard
                    dbc.Row([
                        dbc.Col(
                            [
                                html.H3(
                                    "US Unemployment",
                                    style={"text-align": "center"},
                                ),
                                html.A(
                                    [
                                        dcc.Graph(
                                            figure=get_thumbnail_figure(
                                                get_forecast_data(
                                                    "US Unemployment")),
                                            config={"displayModeBar": False},
                                        )
                                    ],
                                    href=
                                    f"/series?{urlencode({'title': 'US Unemployment'})}",
                                ),
                            ],
                            lg=8,
                            # className="border-right",
                        ),
                        component_leaderboard_4col(series_list),
                    ]),
                    # Row 4 - Australia Snapshot
                    component_figs_3col(
                        "Australia Snapshot 🇦🇺",
                        [
                            "Australian GDP Growth",
                            "Australian Inflation (CPI)",
                            "Australian Unemployment",
                        ],
                    ),
                    # Row 5 - UK Snapshot
                    component_figs_2col(
                        "UK Snapshot 🇬🇧",
                        [
                            "UK Unemployment",
                            "UK Inflation (RPI)",
                        ],
                    ),
                ] + footer()),
            ])
Example #50
0
# Logger (current file and parent directory only)
logger = kiilogger.get_logger(
    os.path.join(os.path.split(__file__)[0], os.path.basename(__file__)))
logging.root.setLevel(logging.INFO)

# Reference to callback datastructure
data = i.control.data

### Test ###

# Drop to cli, type exit in the displayed terminal to continue
#i.control.cli()

## Loopback Tests ##
logger.info(header("-- RawIO Loopback tests --"))

i.control.cmd('setRawIOPacketSize')(64)
i.control.cmd('setRawIOLoopback')(True)

# Send basic test packet, 1 byte length, payload 0xAC
logger.info(header("- Single byte packet payload -"))
i.control.cmd('HIDIO_test_2_request')(1, 0xAC)

# A single processing loop (receivves, then sends packets)
i.control.loop(1)

# Check contents of incoming buffer (should be empty in loopback mode)
logger.info("Incoming Buf: {}", data.rawio_incoming_buffer)
check(len(data.rawio_incoming_buffer) == 0)
Example #51
0
def main():

  # ma.optimize('returns', 'inc_factor')
  # ma.optimize('risk', 'inc_factor')
  # ma.optimize('returns', 'max_factor')
  # ma.optimize('risk', 'max_factor')
  # ma.stats_inc_factor()
  # sys.exit(0)

  header('Loading Data')
  common.set_nav_data()

  header('Regular SIP')
  regularSip.run()
  
  header('Flex STP')
  flexStp.run()
  
  header('Equal Weighted')
  equalWt.run()
  
  header('Normal MA')
  ma.run('normal', 3)
  ma.run('normal', 6)
  ma.run('normal', 9)
  ma.run('normal', 12)
  
  header('Inverted MA')
  ma.run('inverted', 3)
  ma.run('inverted', 6)
  ma.run('inverted', 9)
  ma.run('inverted', 12)
  
  header('Top Ranked')
  ranked.create_out_file()
  ranked.run('top', 1)
  ranked.run('top', 2)
  ranked.run('top', 3)
  
  header('Bottom Ranked')
  ranked.run('bottom', 3)
  ranked.run('bottom', 2)
  ranked.run('bottom', 1)

  header('Ranked MA')
  rankedMA.create_out_file()
  for rank_type in ['top', 'bottom']:
    for rank_val in [1, 2, 3]:
      for ma_type in ['normal', 'inverted']:
        for ma_val in [3, 6, 9, 12]:
          rankedMA.run(rank_type, rank_val, ma_type, ma_val)
  
  # rankedMA.run('top', 2, 'normal', 12)
  # rankedMA.run('top', 1, 'normal', 3)
  
  header('Timed')
  timed.run()
  
  header ('Summary')
  summary.run()
  
  print '\n'