# HG changeset patch
# User Martin Albrecht <martinralbrecht@googlemail.com>
# Date 1328444479 0
# Node ID 664b72dcc7f05310e6e95491f2153c3631a50d00
# Parent 18620dc67e5765b0f9c259f8011cd1277ca8d247
#12336 fix optional keywords of symbolic_data tests, reformat docs, add to reference manual
diff git a/doc/en/reference/databases.rst b/doc/en/reference/databases.rst
a

b


59  59  sage/databases/sloane 
60  60  sage/databases/conway 
61  61  sage/databases/odlyzko 
 62  sage/databases/symbolic_data 
diff git a/sage/databases/symbolic_data.py b/sage/databases/symbolic_data.py
a

b


1   r""" 
2   Thin wrapper for the optional SymbolicData set of ideals as published 
3   on \url{http://www.symbolicdata.org} . From that website: 
 1  """ 
 2  Ideals from the Symbolic Data project 
 3  
 4  This file implements a thin wrapper for the optional symbolic data set 
 5  of ideals as published on http://www.symbolicdata.org . From the 
 6  project website: 
4  7  
5  8  For different purposes algorithms and implementations are tested 
6  9  on certified and reliable data. The development of tools and data 
… 
… 

29  32  certified data that could be addressed and extended during further 
30  33  development. 
31  34  
32   EXAMPLE: 
33   sage: sd = SymbolicData(); sd # optional requires database_symbolic_data 
 35  EXAMPLES:: 
 36  
 37  sage: sd = SymbolicData(); sd # optional  database_symbolic_data 
34  38  SymbolicData with 372 ideals 
35  39  
36   sage: sd.ZeroDim__example_1 # optional requires database_symbolic_data 
 40  sage: sd.ZeroDim__example_1 # optional  database_symbolic_data 
37  41  Ideal (x1^2 + x2^2  10, x1^2 + x1*x2 + 2*x2^2  16) of Multivariate Polynomial Ring in x1, x2 over Rational Field 
38  42  
39   sage: sd.Katsura_3 # optional requires database_symbolic_data 
40   Ideal (u0 + 2*u1 + 2*u2 + 2*u3  1, 
41   u1^2 + 2*u0*u2 + 2*u1*u3  u2, 
42   2*u0*u1 + 2*u1*u2 + 2*u2*u3  u1, 
 43  sage: sd.Katsura_3 # optional  database_symbolic_data 
 44  Ideal (u0 + 2*u1 + 2*u2 + 2*u3  1, 
 45  u1^2 + 2*u0*u2 + 2*u1*u3  u2, 
 46  2*u0*u1 + 2*u1*u2 + 2*u2*u3  u1, 
43  47  u0^2 + 2*u1^2 + 2*u2^2 + 2*u3^2  u0) of Multivariate Polynomial Ring in u0, u1, u2, u3 over Rational Field 
44  48  
45   sage: sd.get_ideal('Katsura_3',GF(127),'degrevlex') # optional requires database_symbolic_data 
46   Ideal (u0 + 2*u1 + 2*u2 + 2*u3  1, 
 49  sage: sd.get_ideal('Katsura_3',GF(127),'degrevlex') # optional  database_symbolic_data 
 50  Ideal (u0 + 2*u1 + 2*u2 + 2*u3  1, 
47  51  u1^2 + 2*u0*u2 + 2*u1*u3  u2, 
48   2*u0*u1 + 2*u1*u2 + 2*u2*u3  u1, 
 52  2*u0*u1 + 2*u1*u2 + 2*u2*u3  u1, 
49  53  u0^2 + 2*u1^2 + 2*u2^2 + 2*u3^2  u0) of Multivariate Polynomial Ring in u0, u1, u2, u3 over Finite Field of size 127 
50  54  
51   AUTHOR: Martin Albrecht <malb@informatik.unibremen.de> 
 55  AUTHORS: 
 56  
 57   Martin Albrecht <martinralbrecht@googlemail.com> 
52  58  """ 
53  59  import os 
54  60  from xml.dom.minidom import parse 
… 
… 

57  63  
58  64  class SymbolicData: 
59  65  """ 
60   Access to the benchmark and test ideals of the SymbolicData 
61   suite. This class needs the optional databasesymbolicdata package 
62   to be installed. 
 66  Database of ideals as distributed by the The SymbolicData Project 
 67  (http://symbolicdata.org). 
 68  
 69  This class needs the optional ``database_symbolic_data`` package to be 
 70  installed. 
63  71  """ 
64  72  def __init__(self): 
65  73  """ 
66   EXAMPLE: 
67   sage: sd = SymbolicData(); sd # optional requires database_symbolic_data 
 74  EXAMPLES: 
 75  sage: sd = SymbolicData(); sd # optional  database_symbolic_data 
68  76  SymbolicData with 372 ideals 
69  77  """ 
70  78  path=os.environ["SAGE_ROOT"]+"/data/symbolic_data" 
71  79  self.__intpath = path + "/Data/XMLResources/INTPS/" 
72  80  self.__genpath = path + "/Data/XMLResources/GenPS/" 
73   
 81  
74  82  def get_ideal(self, name, base_ring=QQ, term_order="degrevlex"): 
75  83  """ 
76  84  Returns the ideal given by 'name' over the base ring given by 
… 
… 

78  86  'term_order'. 
79  87  
80  88  INPUT: 
81   name  name as in the SymbolicData package 
82   base_ring  base ring for the polynomial ring (default: QQ) 
83   term_order  term order for the polynomial ring (default: degrevlex) 
 89  
 90   ``name``  name as on the symbolic data website 
 91   ``base_ring``  base ring for the polynomial ring (default: ``QQ``) 
 92   ``term_order``  term order for the polynomial ring (default: ``degrevlex``) 
84  93  
85  94  OUTPUT: 
86   ideal as given by name in PolynomialRing(base_ring,vars,term_order) 
87   
88   EXAMPLE: 
89   sage: sd = SymbolicData() # optional requires database_symbolic_data 
90   sage: sd.get_ideal('Katsura_3',GF(127),'degrevlex') # optional requires database_symbolic_data 
91   Ideal (u0 + 2*u1 + 2*u2 + 2*u3  1, 
92   u1^2 + 2*u0*u2 + 2*u1*u3  u2, 
93   2*u0*u1 + 2*u1*u2 + 2*u2*u3  u1, 
 95  
 96  ideal as given by ``name`` in ``PolynomialRing(base_ring,vars,term_order)`` 
 97  
 98  EXAMPLES:: 
 99  
 100  sage: sd = SymbolicData() # optional  database_symbolic_data 
 101  sage: sd.get_ideal('Katsura_3',GF(127),'degrevlex') # optional  database_symbolic_data 
 102  Ideal (u0 + 2*u1 + 2*u2 + 2*u3  1, 
 103  u1^2 + 2*u0*u2 + 2*u1*u3  u2, 
 104  2*u0*u1 + 2*u1*u2 + 2*u2*u3  u1, 
94  105  u0^2 + 2*u1^2 + 2*u2^2 + 2*u3^2  u0) of Multivariate Polynomial Ring in u0, u1, u2, u3 over Finite Field of size 127 
95  106  """ 
96  107  
… 
… 

116  127  
117  128  return l 
118  129  
 130  orig_name = name 
119  131  name = name.replace('__','.') 
120  132  
121  133  try: 
… 
… 

126  138  name = self.__genpath + name + ".xml" 
127  139  open(name) 
128  140  except IOError: 
129   raise AttributeError, "Ideal not found on disk" 
130   
 141  raise AttributeError("No ideal matching '%s' found in database."%orig_name) 
131  142  
132  143  dom = parse(name) 
133  144  res = _dom2ideal(dom) 
134   vars,polys = res[0].replace("_",""),[p.replace("_","") for p in res[1:]] 
 145  variables, polys = res[0].replace("_",""), [p.replace("_","") for p in res[1:]] 
135  146  
136   return PolynomialRing(base_ring, len(vars.split(",")), vars).ideal(polys) 
137   
 147  P = PolynomialRing(base_ring, len(variables.split(",")), variables) 
 148  I = P.ideal([P(f) for f in polys]) 
 149  return I 
 150  
138  151  
139  152  def __repr__(self): 
140  153  """ 
141   EXAMPLE: 
142   sage: sd = SymbolicData(); sd # optional requires database_symbolic_data 
 154  EXAMPLES:: 
 155  
 156  sage: sd = SymbolicData(); sd # optional  database_symbolic_data 
143  157  SymbolicData with 372 ideals 
144  158  """ 
145  159  try: 
… 
… 

150  164  
151  165  def __getattr__(self, name): 
152  166  """ 
153   EXAMPLE: 
154   sage: sd = SymbolicData() # optional requires database_symbolic_data 
155   sage: sd.Cyclic5 # optional requires database_symbolic_data 
 167  EXAMPLES:: 
 168  
 169  sage: sd = SymbolicData() # optional  database_symbolic_data 
 170  sage: sd.Cyclic5 # optional  database_symbolic_data 
156  171  Traceback (most recent call last): 
157  172  ... 
158   AttributeError: Ideal not found on disk 
 173  AttributeError: No ideal matching 'Cyclic5' found in database. 
159  174  
160   sage: sd.Cyclic_5 # optional requires database_symbolic_data 
161   Ideal (v + w + x + y + z, 
162   v*w + w*x + x*y + v*z + y*z, 
163   v*w*x + w*x*y + v*w*z + v*y*z + x*y*z, 
164   v*w*x*y + v*w*x*z + v*w*y*z + v*x*y*z + w*x*y*z, 
 175  sage: sd.Cyclic_5 # optional  database_symbolic_data 
 176  Ideal (v + w + x + y + z, 
 177  v*w + w*x + x*y + v*z + y*z, 
 178  v*w*x + w*x*y + v*w*z + v*y*z + x*y*z, 
 179  v*w*x*y + v*w*x*z + v*w*y*z + v*x*y*z + w*x*y*z, 
165  180  v*w*x*y*z  1) of Multivariate Polynomial Ring in v, w, x, y, z over Rational Field 
166  181  """ 
167  182  return self.get_ideal(name) 
168  183  
169  184  def trait_names(self): 
170  185  """ 
171   EXAMPLE: 
172   sage: sd = SymbolicData() # optional requires database_symbolic_data 
173   sage: sorted(sd.trait_names())[:10]# optional requires database_symbolic_data 
 186  EXAMPLES:: 
 187  
 188  sage: sd = SymbolicData() # optional  database_symbolic_data 
 189  sage: sorted(sd.trait_names())[:10] # optional  database_symbolic_data 
174  190  ['Bjoerk_8', 
175  191  'Bronstein86', 
176  192  'Buchberger87', 