Ticket #12340: trac_12340.patch
File trac_12340.patch, 8.7 KB (added by , 8 years ago) 


sage/geometry/polytope.py
# HG changeset patch # User Benjamin Jones <benjaminfjones@gmail.com> # Date 1338014241 25200 # Node ID 35ad5b415f3eeaad10dbe8341b6237dcba5c7fd9 # Parent 9ab4ab6e12d0ce97566db069205815303514de4d Trac 12340: mark doctests that require polymake correctly diff git a/sage/geometry/polytope.py b/sage/geometry/polytope.py
a b 16 16 If you have trouble with this module do:: 17 17 18 18 sage: !polymake reconfigure # not tested 19 20 at the command line. 19 20 at the command line. 21 21 22 22 AUTHORS: 23 23 … … 55 55 class Polytope(SageObject): 56 56 """ 57 57 Create a polytope. 58 58 59 59 EXAMPLES:: 60 61 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional : needspolymake62 60 61 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional  polymake 62 63 63 .. note:: 64 64 65 If you have trouble with this module do:: 66 65 If you have trouble with this module do:: 66 67 67 sage: !polymake reconfigure # not tested 68 68 69 69 at the command line. … … 84 84 except AttributeError: 85 85 pass 86 86 return s 87 87 88 88 89 89 90 90 def __add__(self, other): 91 """92 93 """94 91 if not isinstance(other, Polytope): 95 92 raise TypeError, "other (=%s) must be a polytope"%other 96 93 output_file = tmp_filename() 97 94 infile1 = tmp_filename() 98 95 open(infile1,'w').write(self.__data) 99 96 infile2 = tmp_filename() 100 open(infile2,'w').write(other.__data) 97 open(infile2,'w').write(other.__data) 101 98 cmd = "minkowski_sum %s 1 %s 1 %s"%(output_file, infile1, 102 99 infile2) 103 100 stdin, stdout, stderr = os.popen3(cmd) … … 111 108 os.unlink(infile2) 112 109 os.unlink(output_file) 113 110 return S 114 115 111 112 116 113 def data(self): 117 114 return self.__data 118 115 … … 133 130 else: 134 131 j += i 135 132 return D[i+len(cmd2)1:j] 136 133 137 134 F = tmp_file 138 135 open(F,'w').write(self.__data) 139 136 c = '%s %s %s'%(polymake_command, F, cmd) … … 146 143 err,cmd) 147 144 self.__data = open(F).read() 148 145 return ans 149 146 150 147 151 148 def facets(self): 152 149 """ 153 150 EXAMPLES:: 154 155 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional : needspolymake156 sage: P.facets() # optional 151 152 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional  polymake 153 sage: P.facets() # optional  polymake 157 154 [(0, 0, 0, 1), (0, 1, 0, 0), (0, 0, 1, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 1, 0, 0)] 158 155 """ 159 156 try: … … 174 171 def vertices(self): 175 172 """ 176 173 EXAMPLES:: 177 178 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional : needspolymake179 sage: P.vertices() # optional 174 175 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional  polymake 176 sage: P.vertices() # optional  polymake 180 177 [(1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)] 181 178 """ 182 179 try: … … 211 208 def is_simple(self): 212 209 r""" 213 210 Return True if this polytope is simple. 214 211 215 212 A polytope is *simple* if the degree of each vertex equals the 216 213 dimension of the polytope. 217 214 218 215 EXAMPLES:: 219 220 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional : needspolymake221 sage: P.is_simple() # optional 216 217 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional  polymake 218 sage: P.is_simple() # optional  polymake 222 219 True 223 220 224 221 AUTHORS: 225 222 226 223  Edwin O'Shea (20060502): Definition of simple. … … 233 230 i = s.find('\n') 234 231 self.__is_simple = bool(int(s[i:])) 235 232 return self.__is_simple 236 237 238 233 234 235 239 236 def n_facets(self): 240 237 """ 241 238 EXAMPLES:: 242 243 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional : needspolymake244 sage: P.n_facets() # optional 239 240 sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional  polymake 241 sage: P.n_facets() # optional  polymake 245 242 6 246 243 """ 247 244 try: … … 268 265 def reconfigure(self): 269 266 """ 270 267 Reconfigure polymake. 271 268 272 269 Remember to run polymake.reconfigure() as soon as you have changed 273 270 the customization file and/or installed missing software! 274 271 """ … … 276 273 277 274 def associahedron(self, dimension): 278 275 return self.__make('associahedron %s %s'%(tmp_file, dimension), 279 '%sdimensional associahedron'%dimension) 280 276 '%sdimensional associahedron'%dimension) 277 281 278 def birkhoff(self, n): 282 279 return self.__make('birkhoff %s %s'%(tmp_file, n), 283 280 'Birkhoff %s'%n) 284 281 285 282 286 283 def cell24(self): 287 284 """ 288 285 EXAMPLES:: 289 290 sage: polymake.cell24() # optional : needspolymake286 287 sage: polymake.cell24() # optional  polymake 291 288 The 24cell 292 289 """ 293 290 return self.__make('24cell %s'%tmp_file, 294 291 'The 24cell') 295 292 296 293 def convex_hull(self, points=[]): 297 294 r""" 298 295 EXAMPLES:: 299 296 300 297 sage: R.<x,y,z> = PolynomialRing(QQ,3) 301 298 sage: f = x^3 + y^3 + z^3 + x*y*z 302 299 sage: e = f.exponents() 303 300 sage: a = [[1] + list(v) for v in e] 304 301 sage: a 305 302 [[1, 3, 0, 0], [1, 0, 3, 0], [1, 1, 1, 1], [1, 0, 0, 3]] 306 sage: n = polymake.convex_hull(a) # optional : needspolymake307 sage: n # optional 303 sage: n = polymake.convex_hull(a) # optional  polymake 304 sage: n # optional  polymake 308 305 Convex hull of points [[1, 0, 0, 3], [1, 0, 3, 0], [1, 1, 1, 1], [1, 3, 0, 0]] 309 sage: n.facets() # optional 306 sage: n.facets() # optional  polymake 310 307 [(0, 1, 0, 0), (3, 1, 1, 0), (0, 0, 1, 0)] 311 sage: n.is_simple() # optional 308 sage: n.is_simple() # optional  polymake 312 309 True 313 sage: n.graph() # optional 310 sage: n.graph() # optional  polymake 314 311 'GRAPH\n{1 2}\n{0 2}\n{0 1}\n\n' 315 """ 312 """ 316 313 f = 'POINTS\n' 317 314 points.sort() 318 315 for p in points: … … 333 330 cmd += ' seed %s'%seed 334 331 return self.__make(cmd, 335 332 '%sdimensional 0/1polytope with %s random vertices (uniform distribution)'%(d, n)) 336 333 337 334 338 335 339 336 polymake = Polymake() 
sage/rings/polynomial/multi_polynomial.pyx
diff git a/sage/rings/polynomial/multi_polynomial.pyx b/sage/rings/polynomial/multi_polynomial.pyx
a b 856 856 """ 857 857 Return the Newton polytope of this polynomial. 858 858 859 You should have the optional polymake package installed.860 861 859 EXAMPLES:: 862 860 863 861 sage: R.<x,y> = QQ[] … … 875 873 The empty polyhedron in QQ^0 876 874 sage: R(1).newton_polytope() 877 875 A 0dimensional polyhedron in QQ^2 defined as the convex hull of 1 vertex 878 876 879 877 """ 880 878 from sage.geometry.polyhedron.constructor import Polyhedron 881 879 e = self.exponents()