Skip to content

Commit 596189a

Browse files
committed
some fixes in py files
1 parent 911c9bc commit 596189a

File tree

9 files changed

+37
-30
lines changed

9 files changed

+37
-30
lines changed

agregation-option-calcul-formel/media/GroupeSymetrique-correction.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def type_cyclique(sigma):
3333
EXAMPLES::
3434
3535
sage: for sigma in DihedralGroup(6):
36-
... print sigma, type_cyclique(sigma)
36+
....: print(sigma, type_cyclique(sigma))
3737
() [1, 1, 1, 1, 1, 1]
3838
(2,6)(3,5) [2, 2, 1, 1]
3939
(1,2)(3,6)(4,5) [2, 2, 2]
@@ -109,8 +109,8 @@ def taille_groupe(sgf):
109109
110110
sage: S = SymmetricGroup(3)
111111
sage: sgf = [ {1: S([(1,1)])},
112-
... {1: S([(1,2)]), 2: S([(2,2)])},
113-
... {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
112+
....: {1: S([(1,2)]), 2: S([(2,2)])},
113+
....: {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
114114
sage: taille_groupe(sgf)
115115
6
116116
@@ -131,8 +131,8 @@ def liste_groupe(sgf):
131131
132132
sage: S = SymmetricGroup(3)
133133
sage: sgf = [ {1: S([(1,1)])},
134-
... {1: S([(1,2)]), 2: S([(2,2)])},
135-
... {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
134+
....: {1: S([(1,2)]), 2: S([(2,2)])},
135+
....: {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
136136
sage: liste_groupe(sgf)
137137
[(1,2,3), (1,3,2), (1,2), (1,3), (2,3), ()]
138138
@@ -159,8 +159,8 @@ def est_dans_groupe(sigma, sgf):
159159
160160
sage: S = SymmetricGroup(3)
161161
sage: sgf = [ {1: S([(1,1)])},
162-
... {1: S([(1,2)]), 2: S([(2,2)])},
163-
... {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
162+
....: {1: S([(1,2)]), 2: S([(2,2)])},
163+
....: {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
164164
sage: est_dans_groupe(S([2,3,1]), sgf)
165165
True
166166
sage: all(est_dans_groupe(sigma, sgf) for sigma in S)

agregation-option-calcul-formel/media/GroupeSymetrique.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def type_cyclique(sigma):
3030
EXAMPLES::
3131
3232
sage: for sigma in DihedralGroup(6):
33-
... print sigma, type_cyclique(sigma)
33+
....: print(sigma, type_cyclique(sigma))
3434
() [1, 1, 1, 1, 1, 1]
3535
(2,6)(3,5) [2, 2, 1, 1]
3636
(1,2)(3,6)(4,5) [2, 2, 2]
@@ -90,8 +90,8 @@ def taille_groupe(sgf):
9090
9191
sage: S = SymmetricGroup(3)
9292
sage: sgf = [ {1: S([(1,1)])},
93-
... {1: S([(1,2)]), 2: S([(2,2)])},
94-
... {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
93+
....: {1: S([(1,2)]), 2: S([(2,2)])},
94+
....: {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
9595
sage: taille_groupe(sgf)
9696
6
9797
@@ -111,8 +111,8 @@ def liste_groupe(sgf):
111111
112112
sage: S = SymmetricGroup(3)
113113
sage: sgf = [ {1: S([(1,1)])},
114-
... {1: S([(1,2)]), 2: S([(2,2)])},
115-
... {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
114+
....: {1: S([(1,2)]), 2: S([(2,2)])},
115+
....: {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
116116
sage: liste_groupe(sgf)
117117
[(1,2,3), (1,3,2), (1,2), (1,3), (2,3), ()]
118118
@@ -133,8 +133,8 @@ def est_dans_groupe(sigma, sgf):
133133
134134
sage: S = SymmetricGroup(3)
135135
sage: sgf = [ {1: S([(1,1)])},
136-
... {1: S([(1,2)]), 2: S([(2,2)])},
137-
... {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
136+
....: {1: S([(1,2)]), 2: S([(2,2)])},
137+
....: {1: S([(1,3)]), 2: S([(2,3)]), 3: S([(3,3)])} ]
138138
sage: est_dans_groupe(S([2,3,1]), sgf)
139139
True
140140
sage: all(est_dans_groupe(sigma, sgf) for sigma in S)

agregation-option-calcul-formel/media/algebre_lineaire_anneaux.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ def nb_steps(A):
1111
1212
EXAMPLES::
1313
14-
sage: M = random_matrix(ZZ, 5) # random
15-
sage: M
16-
14+
sage: M = random_matrix(ZZ, 5); M # random
1715
[ 1 -7 2 0 -3]
1816
[ -1 2 2 -5 -2]
1917
[ -1 2 7 2 -1]
2018
[ 1 0 -10 0 1]
2119
[ 1 1 1 -1 -2]
2220
sage: nb_steps(M)
2321
2
24-
2522
"""
2623
s = 0
2724
newA = echelon_gauche(A)

agregation-option-calcul-formel/media/bleachermark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
('stupid benchmark', 'zero', 1, 0.0, 0)]
5656
"""
5757

58-
from time import clock
58+
from time import time as clock
5959
from copy import copy
6060
from functools import reduce
6161

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
m = matrix([[2,1,3],[1,4,9],[1,8,27]])
1+
from copy import copy
2+
from sage.all import matrix
3+
4+
m = matrix([[2, 1, 3], [1, 4, 9], [1, 8, 27]])
5+
6+
27
def gauss_bareiss(m):
38
m = copy(m)
49
n = m.nrows()
510
a = 1
611
for i in range(n):
7-
print m
8-
print
9-
assert m[i,i]!=0
10-
for j in range(i+1, n):
11-
m[j] = (m[i,i] * m[j] - m[j,i]*m[i]) / a
12-
a = m[i,i]
12+
print(m)
13+
print()
14+
assert m[i, i] != 0
15+
for j in range(i + 1, n):
16+
m[j] = (m[i, i] * m[j] - m[j, i] * m[i]) / a
17+
a = m[i, i]
1318
return m

agregation-option-calcul-formel/media/programmation_lineaire.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# -*- coding: utf-8 -*-
22
from copy import copy
33

4-
from sage.matrix.constructor import block_matrix, matrix, vector
5-
from sage.symbolic.ring import SR
64
from sage.rings.integer_ring import ZZ
5+
from sage.matrix.constructor import matrix
6+
from sage.matrix.special import block_matrix
7+
from sage.modules.free_module_element import vector
8+
from sage.symbolic.ring import SR
79

810

911
NonNegative = "NonNegative"
@@ -36,7 +38,7 @@ def matrice_systeme(systeme, variables):
3638
[ 0| 0 0 1| 3 4 2| 8]
3739
"""
3840
def liste_coeffs(expression):
39-
return [expression.coeff(v) for v in variables]
41+
return [expression.coefficient(v) for v in variables]
4042

4143
inequations = systeme[0]
4244
m = matrix([liste_coeffs(ineq.lhs()) for ineq in inequations])

agregation-option-calcul-formel/media/recherche.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def recherche(liste,val):
1616
sage: recherche([2,1], 2)
1717
True
1818
sage: recherche([3,1], 2)
19+
False
1920
"""
2021
for i in liste:
2122
if i == val:

agregation-option-calcul-formel/media/tris.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def tri_bulle(liste):
1010
1111
EXAMPLES::
1212
13-
sage: tri_bulle([2,1])
13+
sage: tri_bulle([2,1]) # not tested
1414
[1, 2]
1515
1616
.. TODO: rajouter des tests!

agregation-option-calcul-formel/media/wiedemann.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def check_massey(sequence, connection, L=None):
3131
"""
3232
if L is None:
3333
L = connection.degree()
34+
sequence = list(sequence)
3435
for n in range(L + 1, len(sequence)):
3536
if sum(connection[i] * sequence[n - i]
3637
for i in range(connection.degree() + 1)):
@@ -80,6 +81,7 @@ def massey(sequence, P=QQ['x']):
8081
# valid starting from position L+1 (in particular L >= connection.degree())
8182
connection = P.one()
8283
L = 0
84+
sequence = list(sequence)
8385

8486
# old_connection is a previous value of connection at step m
8587
# It connects sequence[1..m-1] but not sequence[1..m],

0 commit comments

Comments
 (0)