Skip to content

Commit 2d4f69a

Browse files
author
Release Manager
committed
gh-38104: `sage.coding`: Update `# needs` <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> - Cherry-picked from #35095. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #38104 Reported by: Matthias Köppe Reviewer(s): David Coudert, Kwankyu Lee, Matthias Köppe
2 parents e1b2269 + 560b929 commit 2d4f69a

36 files changed

+221
-189
lines changed

src/sage/coding/abstract_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.modules sage.rings.finite_rings
1+
# sage.doctest: needs sage.modules sage.rings.finite_rings
22
r"""
33
Codes
44

src/sage/coding/ag_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.rings.finite_rings sage.schemes
1+
# sage.doctest: needs sage.rings.finite_rings sage.schemes
22
"""
33
AG codes
44

src/sage/coding/ag_code_decoders.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.rings.finite_rings sage.schemes
1+
# sage.doctest: needs sage.rings.finite_rings sage.schemes
22
r"""
33
Decoders for AG codes
44

src/sage/coding/bch_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.modules sage.rings.finite_rings
1+
# sage.doctest: needs sage.modules sage.rings.finite_rings
22
r"""
33
BCH code
44

src/sage/coding/binary_code.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.modules sage.rings.finite_rings
1+
# sage.doctest: needs sage.modules sage.rings.finite_rings
22
r"""
33
Optimized low-level binary code representation
44
@@ -899,6 +899,7 @@ cdef class BinaryCode:
899899
900900
EXAMPLES::
901901
902+
sage: # needs sage.graphs
902903
sage: import sage.coding.binary_code
903904
sage: from sage.coding.binary_code import *
904905
sage: M = Matrix(GF(2), [[1,1,1,1]])
@@ -3977,6 +3978,7 @@ cdef class BinaryCodeClassifier:
39773978
39783979
MORE EXAMPLES::
39793980
3981+
sage: # needs sage.groups
39803982
sage: soc_iter = codes.databases.self_orthogonal_binary_codes(12, 6, 4)
39813983
sage: L = list(soc_iter)
39823984
sage: for n in range(13):

src/sage/coding/channel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.modules sage.rings.finite_rings
1+
# sage.doctest: needs sage.modules sage.rings.finite_rings
22
r"""
33
Channels
44

src/sage/coding/code_bounds.py

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def _check_n_q_d(n, q, d, field_based=True):
199199
200200
TESTS::
201201
202+
sage: # needs sage.libs.pari
202203
sage: from sage.coding.code_bounds import _check_n_q_d
203204
sage: _check_n_q_d(20, 16, 5)
204205
True
@@ -251,26 +252,26 @@ def codesize_upper_bound(n, d, q, algorithm=None):
251252
252253
EXAMPLES::
253254
254-
sage: codes.bounds.codesize_upper_bound(10,3,2)
255+
sage: codes.bounds.codesize_upper_bound(10, 3, 2)
255256
93
256-
sage: codes.bounds.codesize_upper_bound(24,8,2,algorithm="LP")
257+
sage: codes.bounds.codesize_upper_bound(24, 8, 2, algorithm="LP") # needs sage.numerical.mip
257258
4096
258-
sage: codes.bounds.codesize_upper_bound(10,3,2,algorithm="gap") # optional - gap_package_guava
259+
sage: codes.bounds.codesize_upper_bound(10, 3, 2, algorithm="gap") # optional - gap_package_guava
259260
85
260-
sage: codes.bounds.codesize_upper_bound(11,3,4,algorithm=None)
261+
sage: codes.bounds.codesize_upper_bound(11, 3, 4, algorithm=None) # needs sage.symbolic
261262
123361
262-
sage: codes.bounds.codesize_upper_bound(11,3,4,algorithm="gap") # optional - gap_package_guava
263+
sage: codes.bounds.codesize_upper_bound(11, 3, 4, algorithm="gap") # optional - gap_package_guava
263264
123361
264-
sage: codes.bounds.codesize_upper_bound(11,3,4,algorithm="LP")
265+
sage: codes.bounds.codesize_upper_bound(11, 3, 4, algorithm="LP") # needs sage.numerical.mip
265266
109226
266267
267268
TESTS:
268269
269270
Make sure :issue:`22961` is fixed::
270271
271-
sage: codes.bounds.codesize_upper_bound(19,10,2)
272+
sage: codes.bounds.codesize_upper_bound(19, 10, 2)
272273
20
273-
sage: codes.bounds.codesize_upper_bound(19,10,2,algorithm="gap") # optional - gap_package_guava
274+
sage: codes.bounds.codesize_upper_bound(19, 10, 2, algorithm="gap") # optional - gap_package_guava
274275
20
275276
276277
Meaningless parameters are rejected::
@@ -308,18 +309,18 @@ def dimension_upper_bound(n, d, q, algorithm=None):
308309
309310
EXAMPLES::
310311
311-
sage: codes.bounds.dimension_upper_bound(10,3,2)
312+
sage: codes.bounds.dimension_upper_bound(10,3,2) # needs sage.libs.pari sage.symbolic
312313
6
313-
sage: codes.bounds.dimension_upper_bound(30,15,4)
314+
sage: codes.bounds.dimension_upper_bound(30,15,4) # needs sage.libs.pari sage.symbolic
314315
13
315-
sage: codes.bounds.dimension_upper_bound(30,15,4,algorithm="LP")
316+
sage: codes.bounds.dimension_upper_bound(30,15,4,algorithm="LP") # needs sage.libs.pari sage.numerical.mip
316317
12
317318
318319
TESTS:
319320
320321
Meaningless code parameters are rejected::
321322
322-
sage: codes.bounds.dimension_upper_bound(13,3,6)
323+
sage: codes.bounds.dimension_upper_bound(13,3,6) # needs sage.libs.pari
323324
Traceback (most recent call last):
324325
...
325326
ValueError: The alphabet size does not make sense for a code over a field
@@ -421,23 +422,23 @@ def griesmer_upper_bound(n,q,d,algorithm=None):
421422
422423
The bound is reached for the ternary Golay codes::
423424
424-
sage: codes.bounds.griesmer_upper_bound(12,3,6)
425+
sage: codes.bounds.griesmer_upper_bound(12,3,6) # needs sage.libs.pari
425426
729
426-
sage: codes.bounds.griesmer_upper_bound(11,3,5)
427+
sage: codes.bounds.griesmer_upper_bound(11,3,5) # needs sage.libs.pari
427428
729
428429
429430
::
430431
431-
sage: codes.bounds.griesmer_upper_bound(10,2,3)
432+
sage: codes.bounds.griesmer_upper_bound(10,2,3) # needs sage.libs.pari
432433
128
433-
sage: codes.bounds.griesmer_upper_bound(10,2,3,algorithm="gap") # optional - gap_package_guava
434+
sage: codes.bounds.griesmer_upper_bound(10,2,3,algorithm="gap") # optional - gap_package_guava, needs sage.libs.pari
434435
128
435436
436437
TESTS::
437438
438-
sage: codes.bounds.griesmer_upper_bound(11,3,6)
439+
sage: codes.bounds.griesmer_upper_bound(11,3,6) # needs sage.libs.pari
439440
243
440-
sage: codes.bounds.griesmer_upper_bound(11,3,6)
441+
sage: codes.bounds.griesmer_upper_bound(11,3,6) # needs sage.libs.pari
441442
243
442443
"""
443444
_check_n_q_d(n, q, d)
@@ -448,7 +449,7 @@ def griesmer_upper_bound(n,q,d,algorithm=None):
448449
else:
449450
# To compute the bound, we keep summing up the terms on the RHS
450451
# until we start violating the inequality.
451-
from sage.functions.other import ceil
452+
from sage.arith.misc import integer_ceil as ceil
452453
den = 1
453454
s = 0
454455
k = 0
@@ -570,7 +571,7 @@ def gv_info_rate(n, delta, q):
570571
571572
EXAMPLES::
572573
573-
sage: RDF(codes.bounds.gv_info_rate(100,1/4,3)) # abs tol 1e-15
574+
sage: RDF(codes.bounds.gv_info_rate(100,1/4,3)) # abs tol 1e-15 # needs sage.libs.pari sage.symbolic
574575
0.36704992608261894
575576
"""
576577
q = ZZ(q)
@@ -592,9 +593,9 @@ def entropy(x, q=2):
592593
593594
sage: codes.bounds.entropy(0, 2)
594595
0
595-
sage: codes.bounds.entropy(1/5,4).factor() # optional - sage.symbolic
596+
sage: codes.bounds.entropy(1/5,4).factor() # needs sage.symbolic
596597
1/10*(log(3) - 4*log(4/5) - log(1/5))/log(2)
597-
sage: codes.bounds.entropy(1, 3) # optional - sage.symbolic
598+
sage: codes.bounds.entropy(1, 3) # needs sage.symbolic
598599
log(2)/log(3)
599600
600601
Check that values not within the limits are properly handled::
@@ -641,8 +642,9 @@ def entropy_inverse(x, q=2):
641642
642643
EXAMPLES::
643644
645+
sage: # needs sage.symbolic
644646
sage: from sage.coding.code_bounds import entropy_inverse
645-
sage: entropy_inverse(0.1)
647+
sage: entropy_inverse(0.1) # needs scipy
646648
0.012986862055...
647649
sage: entropy_inverse(1)
648650
1/2
@@ -678,10 +680,11 @@ def gv_bound_asymp(delta, q):
678680
679681
EXAMPLES::
680682
681-
sage: RDF(codes.bounds.gv_bound_asymp(1/4,2))
683+
sage: # needs sage.symbolic
684+
sage: RDF(codes.bounds.gv_bound_asymp(1/4,2)) # needs sage.libs.pari
682685
0.18872187554086...
683686
sage: f = lambda x: codes.bounds.gv_bound_asymp(x,2)
684-
sage: plot(f,0,1)
687+
sage: plot(f,0,1) # needs sage.libs.pari sage.plot
685688
Graphics object consisting of 1 graphics primitive
686689
"""
687690
return 1 - entropy(delta, q)
@@ -693,10 +696,11 @@ def hamming_bound_asymp(delta, q):
693696
694697
EXAMPLES::
695698
696-
sage: RDF(codes.bounds.hamming_bound_asymp(1/4,2))
699+
sage: # needs sage.symbolic
700+
sage: RDF(codes.bounds.hamming_bound_asymp(1/4,2)) # needs sage.libs.pari
697701
0.456435556800...
698702
sage: f = lambda x: codes.bounds.hamming_bound_asymp(x,2)
699-
sage: plot(f,0,1)
703+
sage: plot(f,0,1) # needs sage.libs.pari sage.plot
700704
Graphics object consisting of 1 graphics primitive
701705
"""
702706
return 1 - entropy(delta / 2, q)
@@ -711,7 +715,7 @@ def singleton_bound_asymp(delta, q):
711715
sage: codes.bounds.singleton_bound_asymp(1/4,2)
712716
3/4
713717
sage: f = lambda x: codes.bounds.singleton_bound_asymp(x,2)
714-
sage: plot(f,0,1)
718+
sage: plot(f,0,1) # needs sage.plot
715719
Graphics object consisting of 1 graphics primitive
716720
"""
717721
return 1 - delta
@@ -740,7 +744,7 @@ def elias_bound_asymp(delta, q):
740744
741745
EXAMPLES::
742746
743-
sage: codes.bounds.elias_bound_asymp(1/4,2)
747+
sage: codes.bounds.elias_bound_asymp(1/4,2) # needs sage.symbolic
744748
0.39912396330...
745749
"""
746750
r = 1 - 1 / q
@@ -755,7 +759,7 @@ def mrrw1_bound_asymp(delta, q):
755759
756760
EXAMPLES::
757761
758-
sage: codes.bounds.mrrw1_bound_asymp(1/4,2) # abs tol 4e-16
762+
sage: codes.bounds.mrrw1_bound_asymp(1/4,2) # abs tol 4e-16 # needs sage.symbolic
759763
0.3545789026652697
760764
"""
761765
return RDF(entropy((q-1-delta*(q-2)-2*sqrt((q-1)*delta*(1-delta)))/q,q))

src/sage/coding/code_constructions.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.modules sage.rings.finite_rings
1+
# sage.doctest: needs sage.modules sage.rings.finite_rings
22
r"""
33
Linear code constructors that do not preserve the structural information
44
@@ -227,47 +227,49 @@ def permutation_action(g, v):
227227
228228
EXAMPLES::
229229
230+
sage: # needs sage.groups
230231
sage: V = VectorSpace(GF(3),5)
231232
sage: v = V([0,1,2,0,1])
232-
sage: G = SymmetricGroup(5) # optional - sage.groups
233-
sage: g = G([(1,2,3)]) # optional - sage.groups
234-
sage: permutation_action(g,v) # optional - sage.groups
233+
sage: G = SymmetricGroup(5)
234+
sage: g = G([(1,2,3)])
235+
sage: permutation_action(g,v)
235236
(1, 2, 0, 0, 1)
236-
sage: g = G([()]) # optional - sage.groups
237-
sage: permutation_action(g,v) # optional - sage.groups
237+
sage: g = G([()])
238+
sage: permutation_action(g,v)
238239
(0, 1, 2, 0, 1)
239-
sage: g = G([(1,2,3,4,5)]) # optional - sage.groups
240-
sage: permutation_action(g,v) # optional - sage.groups
240+
sage: g = G([(1,2,3,4,5)])
241+
sage: permutation_action(g,v)
241242
(1, 2, 0, 1, 0)
242243
sage: L = Sequence([1,2,3,4,5])
243-
sage: permutation_action(g,L) # optional - sage.groups
244+
sage: permutation_action(g,L)
244245
[2, 3, 4, 5, 1]
245246
sage: MS = MatrixSpace(GF(3),3,7)
246247
sage: A = MS([[1,0,0,0,1,1,0],[0,1,0,1,0,1,0],[0,0,0,0,0,0,1]])
247-
sage: S5 = SymmetricGroup(5) # optional - sage.groups
248-
sage: g = S5([(1,2,3)]) # optional - sage.groups
248+
sage: S5 = SymmetricGroup(5)
249+
sage: g = S5([(1,2,3)])
249250
sage: A
250251
[1 0 0 0 1 1 0]
251252
[0 1 0 1 0 1 0]
252253
[0 0 0 0 0 0 1]
253-
sage: permutation_action(g,A) # optional - sage.groups
254+
sage: permutation_action(g,A)
254255
[0 1 0 1 0 1 0]
255256
[0 0 0 0 0 0 1]
256257
[1 0 0 0 1 1 0]
257258
258259
It also works on lists and is a "left action"::
259260
261+
sage: # needs sage.groups
260262
sage: v = [0,1,2,0,1]
261-
sage: G = SymmetricGroup(5) # optional - sage.groups
262-
sage: g = G([(1,2,3)]) # optional - sage.groups
263-
sage: gv = permutation_action(g,v); gv # optional - sage.groups
263+
sage: G = SymmetricGroup(5)
264+
sage: g = G([(1,2,3)])
265+
sage: gv = permutation_action(g,v); gv
264266
[1, 2, 0, 0, 1]
265-
sage: permutation_action(g,v) == g(v) # optional - sage.groups
267+
sage: permutation_action(g,v) == g(v)
266268
True
267-
sage: h = G([(3,4)]) # optional - sage.groups
268-
sage: gv = permutation_action(g,v) # optional - sage.groups
269-
sage: hgv = permutation_action(h,gv) # optional - sage.groups
270-
sage: hgv == permutation_action(h*g,v) # optional - sage.groups
269+
sage: h = G([(3,4)])
270+
sage: gv = permutation_action(g,v)
271+
sage: hgv = permutation_action(h,gv)
272+
sage: hgv == permutation_action(h*g,v)
271273
True
272274
273275
AUTHORS:
@@ -729,15 +731,15 @@ def ToricCode(P,F):
729731
sage: C = codes.ToricCode([[0,0],[1,0],[2,0],[0,1],[1,1]], GF(7))
730732
sage: C
731733
[36, 5] linear code over GF(7)
732-
sage: C.minimum_distance()
734+
sage: C.minimum_distance() # needs sage.groups
733735
24
734736
sage: C.minimum_distance(algorithm="guava") # optional - gap_package_guava
735737
...24
736738
sage: C = codes.ToricCode([[-2,-2],[-1,-2],[-1,-1],[-1,0],
737739
....: [0,-1],[0,0],[0,1],[1,-1],[1,0]], GF(5))
738740
sage: C
739741
[16, 9] linear code over GF(5)
740-
sage: C.minimum_distance()
742+
sage: C.minimum_distance() # needs sage.groups
741743
6
742744
sage: C.minimum_distance(algorithm="guava") # optional - gap_package_guava
743745
6
@@ -786,9 +788,9 @@ def WalshCode(m):
786788
[8, 3] linear code over GF(2)
787789
sage: C.spectrum()
788790
[1, 0, 0, 0, 7, 0, 0, 0, 0]
789-
sage: C.minimum_distance()
791+
sage: C.minimum_distance() # needs sage.libs.gap
790792
4
791-
sage: C.minimum_distance(algorithm='gap') # check d=2^(m-1)
793+
sage: C.minimum_distance(algorithm='gap') # check d=2^(m-1) # needs sage.libs.gap
792794
4
793795
794796
REFERENCES:

src/sage/coding/codecan/codecan.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs sage.libs.pari
12
r"""
23
Canonical forms and automorphism group computation for linear codes over finite fields
34

src/sage/coding/cyclic_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.modules sage.rings.finite_rings
1+
# sage.doctest: needs sage.modules sage.rings.finite_rings
22
r"""
33
Cyclic code
44
@@ -977,7 +977,7 @@ def message_space(self):
977977
sage: g = x ** 3 + x + 1
978978
sage: C = codes.CyclicCode(generator_pol=g, length=n)
979979
sage: E = codes.encoders.CyclicCodePolynomialEncoder(C)
980-
sage: E.message_space()
980+
sage: E.message_space() # needs sage.libs.ntl
981981
Univariate Polynomial Ring in x over Finite Field of size 2 (using GF2X)
982982
"""
983983
return self._polynomial_ring

0 commit comments

Comments
 (0)