コード例 #1
0
    def test__tool_dct(self):

        ma = MATools()
        ma2 = MATools()

        # watch out to not use the default file name
        # otherwise it might take long to load the data
        test_fname = 'test_tools'
        key = 'test__tool_dct'

        dct = ma.get_tool_dct(fname=test_fname)
        dct[key] = True
        ma.save_tool_dct(fname=test_fname)

        assert key in ma.get_tool_dct(fname=test_fname)
        assert key in ma2.get_tool_dct(fname=test_fname)

        ma.set_enable_tool_dct(False)
        assert key not in ma.get_tool_dct(fname=test_fname)
        assert key not in ma2.get_tool_dct(fname=test_fname)

        ma.set_enable_tool_dct(True)
        assert key in ma.get_tool_dct(fname=test_fname)
        assert key in ma2.get_tool_dct(fname=test_fname)
コード例 #2
0
ファイル: __main__.py プロジェクト: niels-lubbes/moebius_aut
def usecase__classification(cache=True):
    '''
    Prints a classification of quadratic forms
    that contain some fixed double Segre surface S
    in projective 8-space, such that the quadratic
    form is invariant under subgroup of Aut(S).
    We consider subgroups equivalent, if they are
    real conjugate in Aut(P^1xP^1).
    
    Parameters
    ----------
    cache : bool
        If True, then the cached result is used,
        otherwise the output is recomputed. The 
        computation may take about 9 hours.
    '''
    key = 'usecase__classification'
    if cache and key in MATools.get_tool_dct():
        MATools.p(MATools.get_tool_dct()[key])
        return

    out = ''
    for involution in ['identity', 'leftright', 'rotate']:

        for c_lst_lst in DSegre.get_c_lst_lst_lst():

            #
            # compute invariant quadratic forms
            #
            iq_lst = DSegre.get_invariant_qf(c_lst_lst)
            iq_lst = DSegre.change_basis(iq_lst, involution)
            iq_lst = MARing.replace_conj_pairs(iq_lst)

            #
            # computes signatures of random quadrics in
            # the vector space of invariant quadratic forms.
            #
            sig_lst = []
            if 'I' not in str(iq_lst):
                sig_lst = MARing.get_rand_sigs(iq_lst, 10)

            tmp = ''
            tmp += '\n\t' + 10 * '-'
            tmp += '\n\t involution        =' + involution
            tmp += '\n\t group             =' + DSegre.to_str(c_lst_lst)
            tmp += '\n\t invariant ideal   = <'
            for iq in iq_lst:
                sig = ''
                if 'I' not in str(iq):
                    sig = MARing.get_sig(iq)
                tmp += '\n\t\t' + str(iq) + '\t\t' + str(sig)
            tmp += '\n\t\t >'
            tmp += '\n\t random signatures ='
            tmp += '\n\t\t ' + str(sig_lst)
            for sig in sig_lst:
                if 1 in sig:
                    tmp += '\n\t\t' + str(sig)
            tmp += '\n\t' + 10 * '-'

            # output obtained info to screen
            MATools.p(tmp)

            # add to output string
            out += tmp

    # cache output string
    MATools.get_tool_dct()[key] = out
    MATools.save_tool_dct()