def test_dirichletgroup(self): W = self.tc.get('/Character/Dirichlet/23', follow_redirects=True) assert bool_string(True) in W.get_data(as_text=True) assert 'DirichletGroup(23)' in W.get_data(as_text=True) assert 'e\\left(\\frac{7}{11}\\right)' in W.get_data(as_text=True) assert '/Character/Dirichlet/23/10' in W.get_data(as_text=True) W = self.tc.get('/Character/Dirichlet/91', follow_redirects=True) assert bool_string(True) in W.get_data(as_text=True) assert 'Properties' in W.get_data(as_text=True), "properties box" assert 'DirichletGroup(91)' in W.get_data( as_text=True), "sage code example" assert r'\chi_{91}(15,' in W.get_data( as_text=True) and r'\chi_{91}(66' in W.get_data( as_text=True), "generators" assert r'e\left(\frac{7}{12}\right)' in W.get_data( as_text=True), "contents table" assert '/Character/Dirichlet/91/6' in W.get_data( as_text=True), "link in contents table" W = self.tc.get('/Character/Dirichlet/999999999', follow_redirects=True) assert 'Properties' in W.get_data(as_text=True), "properties box" assert '648646704' in W.get_data(as_text=True), "order" assert 'C_{333666}' in W.get_data(as_text=True), "structure" assert r'\chi_{999999999}(234567902,' in W.get_data( as_text=True) and r'\chi_{999999999}(432432433,' in W.get_data( as_text=True) and r'\chi_{999999999}(332999668,' in W.get_data( as_text=True)
def test_dirichletgalorbs(self): W = self.tc.get('/Character/Dirichlet/289/j') assert r'→ <a href="/Character/Dirichlet/289/j"> j</a>' in W.get_data( as_text=True) table_row = ( r'<td class="center">\(-1\)</td> ' r'<td class="center">\(1\)</td> ' r'<td class="center">\(e\left(\frac{57}{136}\right)\)</td> ' r'<td class="center">\(e\left(\frac{191}{272}\right)\)</td> ' r'<td class="center">\(e\left(\frac{57}{68}\right)\)</td> ' r'<td class="center">\(e\left(\frac{219}{272}\right)\)</td> ' r'<td class="center">\(e\left(\frac{33}{272}\right)\)</td> ' r'<td class="center">\(e\left(\frac{229}{272}\right)\)</td> ' r'<td class="center">\(e\left(\frac{35}{136}\right)\)</td> ' r'<td class="center">\(e\left(\frac{55}{136}\right)\)</td> ' r'<td class="center">\(e\left(\frac{61}{272}\right)\)</td> ' r'<td class="center">\(e\left(\frac{41}{272}\right)\)</td>') assert table_row in W.get_data(as_text=True) W = self.tc.get('/Character/Dirichlet/7145/da') assert r'→ <a href="/Character/Dirichlet/7145/da"> da</a>' in W.get_data( as_text=True) table_row = ( r'<td class="center">\(-1\)</td> ' r'<td class="center">\(1\)</td> ' r'<td class="center">\(e\left(\frac{19}{84}\right)\)</td> ' r'<td class="center">\(e\left(\frac{481}{714}\right)\)</td> ' r'<td class="center">\(e\left(\frac{19}{42}\right)\)</td> ' r'<td class="center">\(e\left(\frac{1285}{1428}\right)\)</td> ' r'<td class="center">\(e\left(\frac{341}{357}\right)\)</td> ' r'<td class="center">\(e\left(\frac{19}{28}\right)\)</td> ' r'<td class="center">\(e\left(\frac{124}{357}\right)\)</td> ' r'<td class="center">\(e\left(\frac{779}{1428}\right)\)</td> ' r'<td class="center">\(e\left(\frac{15}{119}\right)\)</td> ' r'<td class="center">\(e\left(\frac{115}{714}\right)\)</td>') assert table_row in W.get_data(as_text=True) # Tests for URL behaviour of characters W = self.tc.get('/Character/Dirichlet/5489/banana/100', follow_redirects=True) #import pdb; pdb.set_trace() assert bool_string(True) in W.get_data(as_text=True) assert r"The URL has been duly corrected." in W.get_data(as_text=True) W = self.tc.get('/Character/Dirichlet/254/banana', follow_redirects=True) assert 'Error: No Galois orbit of Dirichlet characters with' in W.get_data( as_text=True) W = self.tc.get('/Character/Dirichlet/10001/banana/100', follow_redirects=True) assert r'labels have not been computed for this modulus' in W.get_data( as_text=True) W = self.tc.get('/Character/Dirichlet/9999999999/banana', follow_redirects=True) assert 'Error: Galois orbits have only been computed for modulus up to 10,000' in W.get_data( as_text=True)
def __init__(self, query): self.modulus = query.get('modulus') self.conductor = query.get('conductor') self.order = query.get('order') self.parity = query.get('parity') if self.parity in ["Odd","odd"]: self.parity = parity_string(-1) if self.parity in ["Even","even"]: self.parity = parity_string(1) self.limit = parse_limit(query.get('limit')) if self.parity and not self.parity in [parity_string(-1),parity_string(1)]: flash_error("%s is not a valid value for parity. It must be '%s' or '%s'", self.parity, parity_string(-1), parity_string(1)) raise ValueError('parity') self.primitive = query.get('primitive') if self.primitive in ["Yes","yes"]: self.primitive = bool_string(True) if self.primitive in ["No","no"]: self.primitive = bool_string(False) if self.primitive and not self.primitive in [bool_string(True),bool_string(False)]: flash_error("%s is not a valid value for primitive. It must be %s or %s", self.primitive, bool_string(True), bool_string(False)) raise ValueError('primitive') self.mmin, self.mmax = parse_interval(self.modulus,'modulus') if self.modulus else (1, 9999) if self.mmax > 9999: flash_error("Searching is limited to characters of modulus less than $10^4$") raise ValueError('modulus') if self.order and self.mmin > 999: flash_error("For order searching the minimum modulus needs to be less than $10^3$") raise ValueError('modulus') self.cmin, self.cmax = parse_interval(self.conductor, 'conductor') if self.conductor else (1, self.mmax) self.omin, self.omax = parse_interval(self.order, 'order') if self.order else (1, self.cmax) self.cmax = min(self.cmax,self.mmax) self.omax = min(self.omax,self.cmax) if self.primitive == bool_string(True): self.cmin = max([self.cmin,self.mmin]) self.cmin += 1 if self.cmin%4 == 2 else 0 self.cmax -= 1 if self.cmax%4 == 2 else 0 if self.primitive == bool_string(True): self.mmin = max([self.cmin,self.mmin]) self.mmax = min([self.cmax,self.mmax]) self.cmin,self.cmax = self.mmin,self.mmax if self.parity == parity_string(-1): self.omin += 1 if self.omin%2 else 0 self.omax -= 1 if self.omax%2 else 0 self.mmin = max(self.mmin,self.cmin,self.omin) if self.parity: self.is_odd = True if self.parity == parity_string(-1) else False if self.primitive: self.is_primitive = True if self.primitive == bool_string(True) else False self.start = int(query.get('start', '0'))