Opened 11 years ago

Closed 11 years ago

Last modified 7 years ago

#12893 closed enhancement (fixed)

Increase doctest coverage in sage/coding/linear_code.py to 100%

Reported by: Benjamin Jones Owned by: Minh Van Nguyen
Priority: minor Milestone: sage-5.1
Component: documentation Keywords: linear code doctest coverage
Cc: Merged in: sage-5.1.beta0
Authors: Benjamin Jones Reviewers: William Stein
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Frédéric Chapoton)

As the summary states. As of sage-5.0.beta14 coverage is:

linear_code.py
SCORE linear_code.py: 82% (52 of 63)

Missing documentation:
 * __init__(self, gen_mat):
 * _repr_(self):
 * ambient_space(self):
 * basis(self):
 * __contains__(self,v):
 * characteristic(self):
 * __cmp__(self, right):

Missing doctests:
 * bounds_minimum_distance(n, k, F):
 * sd_duursma_data(C, i):
 * sd_duursma_q(C,i,d0):
 * LinearCodeFromVectorSpace(self):

Possibly wrong (function name doesn't occur in doctests):
 * _magma_init_(self, magma):

Apply trac_12893_linear_code_doctests.patch to the Sage library.

Attachments (1)

trac_12893_linear_code_doctests.patch (81.0 KB) - added by Benjamin Jones 11 years ago.
increase doctest coverage to 100%, remove trailing whitespace, and fix bug in sd_duursma_q function

Download all attachments as: .zip

Change History (11)

Changed 11 years ago by Benjamin Jones

increase doctest coverage to 100%, remove trailing whitespace, and fix bug in sd_duursma_q function

comment:1 Changed 11 years ago by Benjamin Jones

Note the bugfix in sd_duursma_q, the syntax T^2 was changed to T**2. This would have been discovered if doctests has been included with the code originally.

After the patch:

> mysage -coverage linear_code.py 
----------------------------------------------------------------------
linear_code.py
SCORE linear_code.py: 100% (63 of 63)
----------------------------------------------------------------------

> mysage -t linear_code.py 
sage -t  "devel/sage-test/sage/coding/linear_code.py"       
	 [18.9 s]
 
----------------------------------------------------------------------
All tests passed!
Total time for all tests: 18.9 seconds

comment:2 Changed 11 years ago by Benjamin Jones

Status: newneeds_review

comment:3 Changed 11 years ago by Benjamin Jones

Description: modified (diff)

comment:4 Changed 11 years ago by William Stein

Could you fix these errors (possibly not caused by you)?

wstein@sage:sage-5.0.beta15-boxen-x86_64-Linux$ ./sage -t --optional devel/sage/sage/coding/linear_code.py sage -t --optional "devel/sage/sage/coding/linear_code.py"  
**********************************************************************
File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/devel/sage/sage/coding/linear_code.py", line 1992:
    sage: C.permutation_automorphism_group(algorithm="gap")  # requires optional GAP package Guava
Exception raised:
    Traceback (most recent call last):
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_49[21]>", line 1, in <module>
        C.permutation_automorphism_group(algorithm="gap")  # requires optional GAP package Guava###line 1992:
    sage: C.permutation_automorphism_group(algorithm="gap")  # requires optional GAP package Guava
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/lib/python/site-packages/sage/misc/decorators.py", line 687, in wrapper
        return func(*args, **kwds)
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/lib/python/site-packages/sage/coding/linear_code.py", line 2033, in permutation_automorphism_group
        A = gap("MatrixAutomorphisms(matCwt)")
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/lib/python/site-packages/sage/interfaces/interface.py", line 198, in __call__
        return cls(self, x, name=name)
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/lib/python/site-packages/sage/interfaces/expect.py", line 1331, in __init__
        raise TypeError, x
    TypeError: Gap produced error output
    Error, no 1st choice method found for `MatrixAutomorphisms' on 1 arguments

       executing $sage24:=MatrixAutomorphisms(matCwt);;
**********************************************************************
File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/devel/sage/sage/coding/linear_code.py", line 1995:
    sage: C.permutation_automorphism_group(algorithm="gap")  # requires optional GAP package Guava
Exception raised:
    Traceback (most recent call last):
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_49[23]>", line 1, in <module>
        C.permutation_automorphism_group(algorithm="gap")  # requires optional GAP package Guava###line 1995:
    sage: C.permutation_automorphism_group(algorithm="gap")  # requires optional GAP package Guava
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/lib/python/site-packages/sage/misc/decorators.py", line 687, in wrapper
        return func(*args, **kwds)
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/lib/python/site-packages/sage/coding/linear_code.py", line 2033, in permutation_automorphism_group
        A = gap("MatrixAutomorphisms(matCwt)")
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/lib/python/site-packages/sage/interfaces/interface.py", line 198, in __call__
        return cls(self, x, name=name)
      File "/scratch/wstein/ref/sage-5.0.beta15-boxen-x86_64-Linux/local/lib/python/site-packages/sage/interfaces/expect.py", line 1331, in __init__
        raise TypeError, x
    TypeError: Gap produced error output
    Error, no 1st choice method found for `MatrixAutomorphisms' on 1 arguments

       executing $sage26:=MatrixAutomorphisms(matCwt);;
**********************************************************************
1 items had failures:
   2 of  25 in __main__.example_49
***Test Failed*** 2 failures.
For whitespace errors, see the file /home/wstein/.sage//tmp/linear_code_4858.py
         [14.8 s]
 
----------------------------------------------------------------------
The following tests failed:


        sage -t --optional "devel/sage/sage/coding/linear_code.py"
Total time for all tests: 14.9 seconds
(sage-sh) wstein@sage:sage-5.0.beta15-boxen-x86_64-Linux$ 

comment:5 Changed 11 years ago by Benjamin Jones

I can try.. the same problem occurs on vanilla sage-4.8 after installing the gap_packages optional spkg.

It looks like GAP is throwing an error when an empty matrix is passed to MatrixAutomorphisms. I'll look into it further. It seems like the weights either aren't being handled correctly or aren't being computed correctly in the algorithm=gap part of the code.

comment:6 Changed 11 years ago by William Stein

Status: needs_reviewpositive_review

I'll give this ticket a positive review. Fixing those other failures can be for another ticket.

comment:7 Changed 11 years ago by Benjamin Jones

Thanks, the algorithm=gap bug is now #12901.

comment:8 Changed 11 years ago by Jeroen Demeyer

Reviewers: William Stein

comment:9 Changed 11 years ago by Jeroen Demeyer

Merged in: sage-5.1.beta0
Resolution: fixed
Status: positive_reviewclosed

comment:10 Changed 7 years ago by Frédéric Chapoton

Description: modified (diff)
Note: See TracTickets for help on using tickets.