Ejemplo n.º 1
0
def seifert_corr(stringdata, use_multi=False):
    '''Parse Seifert data, output correction terms.'''
    try:
        if stringdata == '':
            raise ValueError('empty string')
        data = parse_seifert(stringdata) # parse data
    except:
        print traceback.print_exc()            
        return
    if not correct_form(data, gui=False):
        print traceback.print_exc()
        return
    else:
        # compute quadratic form and correction terms
        quad = s_quad_form(data)
        print quad
        quadform = NDQF(quad[0])
        print 'H_1(Y) ~ %s' % quadform.group.struct()        
        if use_multi:
            corr = quadform.correction_terms_threaded()
        else:
            corr = quadform.correction_terms_ugly()
        if quad[1]: # reversed orientation
            corr = map(lambda n: -n, corr)
        corr = quadform.pretty_print(corr) # make Fractions pretty
    return corr
Ejemplo n.º 2
0
 def get_seifert(self):
     '''Parse Seifert data, output correction terms.'''
     stringdata = self.entry.get()
     try:
         if stringdata == '':
             raise ValueError('empty string')
         data = parse_seifert(stringdata) # parse data
     except:
         tkMessageBox.showwarning('Failed to parse data.',
                 'Data should be [e, (p1,q1), (p2,q2), ... , (pr,qr)],' +\
                 'where e and the pi,qi are ints, pi > 1, and gcd(pi,qi) ' +\
                 '= 1.')
         print traceback.print_exc()            
         return
     if not correct_form(data, gui=True):
         tkMessageBox.showwarning('Invalid data form.',
                 'Data should be [e, (p1,q1), (p2,q2), ... , (pr,qr)],' +\
                 'where e and the pi,qi are ints, pi > 1, and gcd(pi,qi) ' +\
                 '= 1.')
         print traceback.print_exc()
         return
     else:
         print '\n%s' %data
         # compute quadratic form and correction terms
         quad = s_quad_form(data)
         print quad
         quadform = NDQF(quad[0])
         struct = quadform.group.struct()
         print struct
         if self.use_multi.get():
             corr = quadform.correction_terms_threaded()
         else:
             corr = quadform.correction_terms_ugly()
         if quad[1]: # reversed orientation
             corr = map(lambda n: -n, corr)
         corr = quadform.pretty_print(corr) # make Fractions pretty
         print corr
         if self.save_file.get():
             self.save(data)
         OutputWindow(self.master, corr, struct, quad[0], data,\
                          showhom=self.show_hom.get(),
                          showquad=self.show_quad.get(), 
                          condense=self.condense.get(),
                          showseifert=self.show_seifert.get(),
                          seifertdata=alter_data(data))
         if self.show_weighted.get():
             s_draw(data)