Repository: LMFDB/lmfdb

Issue:
Dirchlet character search lists incorrect parity
As reported by Jörg Czeranski, the Dirichlet character search results page does not list the correct parities of the characters matching the search (it appears to always list odd, even for the trivial character!)

> Dear LMFDB developers,
> 
> I searched for Dirichlet characters with modulus 35, but all 24
> characters are shown with parity = odd:
> http://www.lmfdb.org/Character/Dirichlet/?start=0&count=12&modulus=35&parity=All&primitive=All&limit=25&refine=1
> 
> If I restrict the search to even characters, I get 12 characters as
> expected, but the result table still shows parity = odd:
> http://www.lmfdb.org/Character/Dirichlet/?start=0&count=24&modulus=35&parity=Even&primitive=All&limit=25&refine=1
> 
> Best regards
> Jörg Czeranski


Discussion:
I'm looking at this now.

Resolving patch:
diff --git a/lmfdb/characters/ListCharacters.py b/lmfdb/characters/ListCharacters.py
--- a/lmfdb/characters/ListCharacters.py
+++ b/lmfdb/characters/ListCharacters.py
@@ -185,8 +185,8 @@ def __init__(self, query):
         self.modulus = query.get('modulus')
         self.conductor = query.get('conductor')
         self.order = query.get('order')
-        self.parity = None if query.get('parity', 'All') == 'All' else query.get('parity')
-        self.primitive = None if query.get('primitive', 'All') == 'All' else query.get('primitive')
+        self.parity = query.get('parity')
+        self.primitive = query.get('primitive')
         self.limit = parse_limit(query.get('limit'))
         if self.parity and not self.parity in ['Odd','Even']:
             flash(Markup("Error:  <span style='color:black'>%s</span> is not a valid value for parity.  It must be 'Odd', 'Even', or 'All'"),"error")
diff --git a/lmfdb/characters/web_character.py b/lmfdb/characters/web_character.py
--- a/lmfdb/characters/web_character.py
+++ b/lmfdb/characters/web_character.py
@@ -785,6 +785,9 @@ def friends(self):
             url = url_character(type=self.type, number_field=self.nflabel, modulus=self.modlabel, number=self.numlabel)
             if get_lfunction_by_url(url[1:]):
                 f.append( ('L-function', '/L'+ url) )
+            else:
+                if self.conductor == 1:
+                    f.append (('L-function', '/L/Riemann'))
         if self.type == 'Dirichlet':
             f.append( ('Sato-Tate group', '/SatoTateGroup/0.1.%d'%self.order) )
         if len(self.vflabel)>0:
@@ -1147,6 +1150,9 @@ def friends(self):
             )
             if get_lfunction_by_url(url[1:]):
                 friendlist.append( ('L-function', '/L'+ url) )
+            else:
+                if self.conductor == 1:
+                    friendlist.append (('L-function', '/L/Riemann'))
             friendlist.append(
                 ('Sato-Tate group', '/SatoTateGroup/0.1.%d' % self.order)
             )


Test patch:
diff --git a/lmfdb/characters/test_characters.py b/lmfdb/characters/test_characters.py
--- a/lmfdb/characters/test_characters.py
+++ b/lmfdb/characters/test_characters.py
@@ -32,6 +32,11 @@ def test_order(self):
         W = self.tc.get('/Character/Dirichlet/?order=19-23')
         assert '\chi_{25}(2' in W.data
 
+    def test_even_odd(self):
+	W = self.tc.get('/Character/Dirichlet/?modulus=35')
+	assert '>Even</t' in W.data
+	assert '>Odd</t' in W.data
+
     def test_modbrowse(self):
         W = self.tc.get('/Character/Dirichlet/?modbrowse=51-81')
         """