Exemplo n.º 1
0
def sample_abs_state_list(A, system_params, abs_state_list):

    # ##!!##logger.debug(U.decorate('sampling begins'))

    # List to store reachble concrete states:
    # stores number of samples in the same order as abstract states in
    # abs_state_list and of course
    # len(abs_state_list) =  abs_state2samples_list

    abs_state2samples_list = []

    consolidated_samples = SaMpLe.Samples()

    for abs_state in abs_state_list:

        # scatter the continuous states

        # ##!!##logger.debug('sampling({})'.format(abs_state))

        samples = system_params.sampler.sample(abs_state, A, system_params, A.num_samples)

        # ##!!##logger.debug('{}'.format(samples))

        abs_state2samples_list.append(samples.n)
        consolidated_samples.append(samples)

#    # ##!!##logger.debug('{}'.format(consolidated_samples))

    #total_num_samples = consolidated_samples.n

    # ##!!##logger.debug('num_samples = {}'.format(total_num_samples))
    # ##!!##logger.debug('samples = \n{}'.format(samples))
    # ##!!##logger.debug(U.decorate('sampling done'))

    return (abs_state2samples_list, consolidated_samples)
Exemplo n.º 2
0
def prepare_main_page( bread):
    info = { 'number_of_collections': len(COLNS),
             'number_of_samples': len(sample.Samples( {})),
             'cols': COLNS.values(),
             'cols_with_forms': [COLNS[c] for c in COLNS if len(COLNS[c].members()) > 0],
             'cols_comp_dims': [COLNS[c] for c in COLNS if COLNS[c].computes_dimensions()]
             }
    return render_template( 'ModularForm_GSp4_Q_index.html',
                            title='Siegel Modular Forms',
                            bread=bread,
                            **info)
Exemplo n.º 3
0
 def members(self):
     """
     Return a list of members by name.
     """
     if not self.__members:
         import sample
         self.__members = sample.Samples({'collection': self.__name})
         # # retrieve the members from db and set them
         # docs = find_all( { 'collection': self.__name})
         # self.__members = [s['name'] for s in docs]
     return self.__members
Exemplo n.º 4
0
def prepare_search_results_page( args, bread):

    info = {'all':args}
    query = args.get('query')
    try:
        query = json.loads( query)
        results = sample.Samples( query)
        info.update( {'results': results})
    except Exception as e:
        info.update( {'error': '%s %s' % (str(e),query)})

    bread.append( ('search results', 'search_results'))
    return render_template( "ModularForm_GSp4_Q_search_results.html",
                            title='Siegel modular forms search results',
                            bread=bread, **info)
Exemplo n.º 5
0
def by_label(label):
    bread = [("Modular Forms", url_for('modular_forms')),
             ('Siegel Modular Forms', url_for('.index'))]
    slabel = label.split('.')
    family = get_smf_family (slabel[0])
    if family:
        if len(slabel) == 1:
            return render_family_page(family, request.args, bread)
        if len(slabel) == 2:
            sam = sample.Samples({ 'collection': {'$contains': [slabel[0]]}, 'name': slabel[1]})
            if len(sam) > 0:
                bread.append(('$'+family.latex_name+'$', url_for('.by_label',label=slabel[0])))
                return render_sample_page(family, sam[0], request.args, bread)
    flash_error("No Siegel modular form data for %s was found in the database.", label)
    return redirect(url_for(".index"))
Exemplo n.º 6
0
def render_search_results_page(args, bread):
    if args.get("table"):
        return render_dimension_table_page(args, bread)
    if args.get("lookup"):
        return redirect(url_for('.by_label',label=args['label']))
    info = { 'args': to_dict(args) }
    query = {}
    try:
        parse_ints (info['args'], query, 'deg', 'degree')
        parse_ints (info['args'], query, 'wt', '$k$')
        parse_ints (info['args'], query, 'fdeg', 'field degree')
    except ValueError:
        info['error'] = True
    if not info.get('error'):
        info['results'] = sample.Samples(query)
    bread.append(('Search Results', ''))
    return render_template( "ModularForm_GSp4_Q_search_results.html", title='Siegel Modular Forms Search Results', bread=bread, info=info)
Exemplo n.º 7
0
def ModularForm_GSp4_Q_top_level(page=None):

    if request.args.get('empty_cache') or not COLNS:
        # we trigger a (re)scan for available collections
        rescan_collection()

    bread = [("Modular Forms", url_for('mf.modular_form_main_page')),
             ('Siegel modular forms', url_for('ModularForm_GSp4_Q_top_level'))]

    # info = dict(args); info['args'] =  request.args
    #info['learnmore'] = []

    # parse the request
    if not page:
        name = request.args.get('download')
        if name:
            a, b = name.split('.')
            f = StringIO.StringIO(sample.export(a, b))
            #            print f.getvalue()
            f.seek(0)
            return send_file(f,
                             attachment_filename=name + '.json',
                             as_attachment=True)

        else:
            return prepare_main_page(bread)
    if page in COLNS:
        return prepare_collection_page(COLNS[page], request.args, bread)
    if 'dimensions' == page:
        return prepare_dimension_page(request.args, bread)
    if 'search_results' == page:
        return prepare_search_results_page(request.args, bread)
    # check whether there is a sample called page
    try:
        a, b = page.split('.')
    except:
        a = b = None
    sam = sample.Samples({'collection': a, 'name': b})
    if len(sam) > 0:
        return prepare_sample_page(sam[0], request.args, bread)

    # return an error: better emit a 500
    info = {'error': 'Requested page does not exist'}
    return render_template("None.html", **info)