Skip to content

Commit 93427fd

Browse files
committed
fix some doctests
1 parent acf5319 commit 93427fd

File tree

3 files changed

+66
-99
lines changed

3 files changed

+66
-99
lines changed

2011-01-27-how-to-contribute.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
How to contribute to Sage
55
=========================
66

7-
.. This file can be compiled using the following command ``rst2s5.py``
7+
.. This file can be compiled using the following command: rst2s5.py
88
9-
.. We include <s5defs.txt> for colors and other predefined roles like text size
9+
.. We include s5defs.txt for colors and other predefined roles like text size
1010
and others
1111
1212
.. include:: <s5defs.txt>

2011-05-23-SMAI.rst

+26-58
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ petits.
3939
Une expression::
4040

4141
sage: f = cos(x)^6 + sin(x)^6 + 3 * sin(x)^2 * cos(x)^2; f
42-
sin(x)^6 + cos(x)^6 + 3*sin(x)^2*cos(x)^2
42+
cos(x)^6 + sin(x)^6 + 3*cos(x)^2*sin(x)^2
4343

4444
Simplifions-la::
4545

@@ -55,7 +55,7 @@ Une sommation définie::
5555
1/2*sqrt(pi)/factorial(n + 1/2)
5656

5757
sage: pretty_print(_)
58-
<html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{\sqrt{\pi}}{2 \, \left(n + \frac{1}{2}\right)!}</span></html>
58+
1/2*sqrt(pi)/factorial(n + 1/2)
5959

6060
Calcul de `\lim\limits_{x\rightarrow \frac{\pi}{4} }\dfrac{\cos\left(\frac{\pi}{4}-x \right)-\tan x }{1-\sin\left(\frac{\pi}{4}+x \right)}`::
6161

@@ -88,17 +88,17 @@ des constructions algébriques plus avancées::
8888
sage: Z2 = GF(2); Z2
8989
Finite Field of size 2
9090
sage: P = Z2['x']; P
91-
Univariate Polynomial Ring in x over Finite Field of size 2 (using NTL)
91+
Univariate Polynomial Ring in x over Finite Field of size 2 (using GF2X)
9292
sage: M = MatrixSpace(P, 3); M
93-
Full MatrixSpace of 3 by 3 dense matrices over Univariate Polynomial Ring in x over Finite Field of size 2 (using NTL)
93+
Full MatrixSpace of 3 by 3 dense matrices over Univariate Polynomial Ring in x over Finite Field of size 2 (using GF2X)
9494

9595
sage: m = M.random_element(); m # random
9696
[ x + 1 x^2 x^2]
9797
[ x x^2 + x x + 1]
9898
[ x^2 + 1 x^2 + x + 1 x^2]
9999

100100
sage: m.parent()
101-
Full MatrixSpace of 3 by 3 dense matrices over Univariate Polynomial Ring in x over Finite Field of size 2 (using NTL)
101+
Full MatrixSpace of 3 by 3 dense matrices over Univariate Polynomial Ring in x over Finite Field of size 2 (using GF2X)
102102

103103
sage: m * (m-1) # random
104104
[ x^4 + x^3 + x x^3 + x^2 x^4 + x^2]
@@ -113,7 +113,7 @@ factorisation::
113113

114114
sage: p = 54*x^4+36*x^3-102*x^2-72*x-12
115115
sage: p.factor()
116-
6*(3*x + 1)^2*(x^2 - 2)
116+
6*(x^2 - 2)*(3*x + 1)^2
117117

118118
sage: for A in [ZZ, QQ, ComplexField(16), QQ[sqrt(2)], GF(5)]:
119119
....: print(A, ":"); print(A['x'](p).factor())
@@ -123,7 +123,7 @@ factorisation::
123123
(54) * (x + 1/3)^2 * (x^2 - 2)
124124
Complex Field with 16 bits of precision :
125125
(54.00) * (x - 1.414) * (x + 0.3333)^2 * (x + 1.414)
126-
Number Field in sqrt2 with defining polynomial x^2 - 2 :
126+
Number Field in sqrt2 with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095? :
127127
(54) * (x - sqrt2) * (x + sqrt2) * (x + 1/3)^2
128128
Finite Field of size 5 :
129129
(4) * (x + 2)^2 * (x^2 + 3)
@@ -265,7 +265,7 @@ Voire faire des calculs avec::
265265
On veut maintenant manipuler `A` comme un morphisme sur `V`::
266266

267267
sage: phi = End(V)(A); phi
268-
Free module morphism defined by the matrix
268+
Vector space morphism represented by the matrix:
269269
[5 5 4 3]
270270
[0 3 3 4]
271271
[0 1 5 4]
@@ -288,7 +288,7 @@ On veut maintenant manipuler `A` comme un morphisme sur `V`::
288288
::
289289

290290
sage: phi^4 + 5*phi^3 + 6*phi + 2
291-
Free module morphism defined by the matrix
291+
Vector space morphism represented by the matrix:
292292
[0 0 0 0]
293293
[0 0 0 0]
294294
[0 0 0 0]
@@ -307,7 +307,7 @@ On veut maintenant manipuler `A` comme un morphisme sur `V`::
307307
True
308308

309309
sage: phi.restrict(E[2])
310-
Free module morphism defined by the matrix
310+
Vector space morphism represented by the matrix:
311311
[2 0]
312312
[0 2]
313313
Domain: Vector space of degree 4 and dimension 2 over Finite Field of ...
@@ -349,8 +349,8 @@ cinq cartes à jouer::
349349

350350
sage: Symboles = Set(["Coeur", "Carreau", "Pique", "Trefle"])
351351
sage: Valeurs = Set([2, 3, 4, 5, 6, 7, 8, 9, 10, "Valet", "Dame", "Roi", "As"])
352-
sage: Cartes = CartesianProduct(Valeurs, Symboles).map(tuple)
353-
sage: Mains = Subsets(Cartes, 5)
352+
sage: Cartes = cartesian_product([Valeurs, Symboles])
353+
sage: Mains = Subsets(Cartes, 5)
354354
sage: Mains.cardinality()
355355
2598960
356356
sage: Mains.random_element() # random
@@ -391,11 +391,11 @@ Combinatoire algébrique
391391
Et pour faire joli, un système de racine affine et un groupe de Weyl::
392392

393393
sage: L = RootSystem(['A',2,1]).weight_space()
394-
sage: L.plot(size=[[-1..1],[-1..1]], alcovewalks=[[0,2,0,1,2,1,2,0,2,1]])
394+
sage: L.plot()
395395

396396
sage: W = WeylGroup(["B", 3])
397-
sage: W.cayley_graph(side = "left").plot3d(color_by_label = True)
398-
397+
sage: W.cayley_graph(side = "left").plot3d(color_by_label=True)
398+
Graphics3d Object
399399

400400
Graphes
401401
=======
@@ -407,21 +407,21 @@ graphes::
407407
sage: g.show()
408408

409409
sage: c = g.hamiltonian_cycle()
410-
sage: g.show(edge_colors = {"red": c.edges()} )
410+
sage: g.show(edge_colors={"red": c.edges(sort=False)})
411411

412412
Grâce à GAP et à (un port de) Nauty, on peut étudier de près les
413413
questions de symétries et d'isomorphisme dans les graphes. Voici tous
414414
les graphes simples sur cinq sommets avec moins de quatre arêtes::
415415

416-
sage: show(graphs(5, lambda G: G.size() <= 4))
416+
sage: show(next(graphs(5, lambda G: G.size() <= 4)))
417417

418418
Le groupe de symétries (automorphismes) du graphe de Petersen::
419419

420420
sage: petersen = graphs.PetersenGraph()
421421
sage: petersen.show()
422422

423423
sage: group = petersen.automorphism_group(); group
424-
Permutation Group with generators [(3,7)(4,5)(8,9), (2,6)(3,8)(4,5)(7,9), (1,4,5)(2,3,8,6,9,7), (1,10)(2,4,6,5)(3,9,8,7)]
424+
Permutation Group with generators [(3,7)(4,5)(8,9), (2,6)(3,8)(4,5)(7,9), ...]
425425

426426
Et quelques-unes de ses propriétés::
427427

@@ -513,7 +513,7 @@ Ce qui en Sage donne::
513513
sage: LP = MixedIntegerLinearProgram(maximization=True)
514514
sage: b = LP.new_variable()
515515
sage: LP.set_objective(sum([b[v] for v in petersen]))
516-
sage: for (u,v) in petersen.edges(labels=None): # For any edge, we define a constraint
516+
sage: for (u,v) in petersen.edges(labels=None, sort=False): # For any edge, we define a constraint
517517
....: LP.add_constraint(b[u]+b[v],max=1)
518518
sage: LP.set_binary(b)
519519

@@ -526,13 +526,13 @@ On trouve alors un indépendant de taille quatre::
526526
sage: print(b_sol)
527527
{0: 0.0, 1: 1.0, 2: 0.0, 3: 0.0, 4: 1.0, 5: 0.0, 6: 0.0, 7: 1.0, 8: 1.0, 9: 0.0}
528528

529-
sage: I = [ v for v in petersen.vertices() if b_sol[v] ]; I
529+
sage: I = [v for v in petersen.vertices(sort=False) if b_sol[v]]; I
530530
[1, 4, 7, 8]
531531
sage: petersen.show(vertex_colors = {'red' : I})
532532

533533
Pour finir, on manipule l'ensemble de tous les points entiers d'un polytope::
534534

535-
sage: A = random_matrix(ZZ,3,6,x=7)
535+
sage: A = random_matrix(ZZ,6,3,x=7)
536536
sage: L = LatticePolytope(A)
537537
sage: L.plot3d()
538538

@@ -562,7 +562,7 @@ Toujours dans l'idée de modéliser les mathématiques au plus près, Sage
562562
a des informations sur la *structure mathématique* de `K`::
563563

564564
sage: K.category()
565-
Category of finite fields
565+
Join of Category of finite enumerated fields and Category of subquotients of monoids and Category of quotients of semigroups
566566

567567
Voilà ce qu'il peut en déduire:
568568

@@ -594,7 +594,7 @@ En quoi est-ce utile?
594594

595595
2. Partage de code générique::
596596

597-
sage: K.multiplication_table(names = 'elements')
597+
sage: K.multiplication_table(names='elements')
598598
* 0 1 2 3 4 5 6
599599
+--------------
600600
0| 0 0 0 0 0 0 0
@@ -615,47 +615,15 @@ En quoi est-ce utile?
615615
....: print(cls)
616616
<class 'sage.rings.finite_rings.finite_field_prime_modn.FiniteField_prime_modn_with_category'>
617617
...
618-
<class 'sage.categories.finite_fields.FiniteFields.parent_class'>
619-
<class 'sage.categories.fields.Fields.parent_class'>
620-
<class 'sage.categories.euclidean_domains.EuclideanDomains.parent_class'>
621-
<class 'sage.categories.principal_ideal_domains.PrincipalIdealDomains.parent_class'>
622-
<class 'sage.categories.unique_factorization_domains.UniqueFactorizationDomains.parent_class'>
623-
<class 'sage.categories.gcd_domains.GcdDomains.parent_class'>
624-
...
625-
<class 'sage.categories.magmas.Magmas.parent_class'>
626-
...
627-
<class 'sage.categories.finite_sets.FiniteSets.parent_class'>
628-
...
629-
<type 'object'>
618+
<class 'object'>
630619

631620

632621
3. Partage de tests génériques::
633622

634623
sage: TestSuite(K).run(verbose=True)
635624
running ._test_additive_associativity() . . . pass
636-
running ._test_an_element() . . . pass
637-
running ._test_associativity() . . . pass
638-
running ._test_category() . . . pass
639-
running ._test_distributivity() . . . pass
640-
running ._test_elements() . . .
641-
Running the test suite of self.an_element()
642-
running ._test_category() . . . pass
643-
running ._test_eq() . . . pass
644-
running ._test_not_implemented_methods() . . . pass
645-
running ._test_pickling() . . . pass
646-
pass
647-
running ._test_elements_eq() . . . pass
648-
running ._test_enumerated_set_contains() . . . pass
649-
running ._test_enumerated_set_iter_cardinality() . . . pass
650-
running ._test_enumerated_set_iter_list() . . . pass
651-
running ._test_eq() . . . pass
652-
running ._test_len() . . . pass
653-
running ._test_not_implemented_methods() . . . pass
654-
running ._test_one() . . . pass
655-
running ._test_pickling() . . . pass
656-
running ._test_prod() . . . pass
657-
running ._test_some_elements() . . . pass
658-
running ._test_zero() . . . pass
625+
...
626+
running ._test_zero_divisors() . . . pass
659627

660628

661629
A demonstration of Sage + GAP4 + GAP3 + Chevie + Semigroupe

0 commit comments

Comments
 (0)