ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 26 Mar 2015 12:57:47 +0100Computing minimum_distance of a code on non-prime fields fails ... sometimes.https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/ Consider the following piece of code:
C=codes.RandomLinearCode(4,2,GF(16,'b'))
C.minimum_distance()
About half of the time, it fails with error
TypeError: unable to coerce from a finite field other than the prime subfield
I'd understand if SAGE could only compute the minimum distance for codes over primes fields, what has me confused is the fact that sometimes it can, sometimes it can't. Any clues as to what is going on here?Mon, 23 Mar 2015 15:54:25 +0100https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/Comment by vdelecroix for <p>Consider the following piece of code:</p>
<pre><code>C=codes.RandomLinearCode(4,2,GF(16,'b'))
C.minimum_distance()
</code></pre>
<p>About half of the time, it fails with error </p>
<pre><code>TypeError: unable to coerce from a finite field other than the prime subfield
</code></pre>
<p>I'd understand if SAGE could only compute the minimum distance for codes over primes fields, what has me confused is the fact that sometimes it can, sometimes it can't. Any clues as to what is going on here?</p>
https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26290#post-id-26290Hello,
Which version are you using? On both sage-6.5 and sage-6.6.rc0 I got
sage: C=codes.RandomLinearCode(4,2,GF(16,'b'))
sage: C.minimum_distance()
3Mon, 23 Mar 2015 23:33:29 +0100https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26290#post-id-26290Comment by Koji for <p>Consider the following piece of code:</p>
<pre><code>C=codes.RandomLinearCode(4,2,GF(16,'b'))
C.minimum_distance()
</code></pre>
<p>About half of the time, it fails with error </p>
<pre><code>TypeError: unable to coerce from a finite field other than the prime subfield
</code></pre>
<p>I'd understand if SAGE could only compute the minimum distance for codes over primes fields, what has me confused is the fact that sometimes it can, sometimes it can't. Any clues as to what is going on here?</p>
https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26313#post-id-26313Yes, it may work for a few times; but if you keep evaluating, after a couple of successful evaluations you'll come up with a TypeError. You can try it this way, which certainly fails:
for i in range(100):
C=codes.RandomLinearCode(4,2,GF(16,'b'))
C.minimum_distance()
Thanks though for the interest, @vdelecroixTue, 24 Mar 2015 20:06:02 +0100https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26313#post-id-26313Comment by vdelecroix for <p>Consider the following piece of code:</p>
<pre><code>C=codes.RandomLinearCode(4,2,GF(16,'b'))
C.minimum_distance()
</code></pre>
<p>About half of the time, it fails with error </p>
<pre><code>TypeError: unable to coerce from a finite field other than the prime subfield
</code></pre>
<p>I'd understand if SAGE could only compute the minimum distance for codes over primes fields, what has me confused is the fact that sometimes it can, sometimes it can't. Any clues as to what is going on here?</p>
https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26314#post-id-26314@Koji, all right. Got the error as well!Tue, 24 Mar 2015 21:10:24 +0100https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26314#post-id-26314Answer by vdelecroix for <p>Consider the following piece of code:</p>
<pre><code>C=codes.RandomLinearCode(4,2,GF(16,'b'))
C.minimum_distance()
</code></pre>
<p>About half of the time, it fails with error </p>
<pre><code>TypeError: unable to coerce from a finite field other than the prime subfield
</code></pre>
<p>I'd understand if SAGE could only compute the minimum distance for codes over primes fields, what has me confused is the fact that sometimes it can, sometimes it can't. Any clues as to what is going on here?</p>
https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?answer=26315#post-id-26315Hello,
Indeed there is a bug in Sage/GAP code conversion. It works for $GF(2^3)$ but not $GF(2^4)$
sage: K = GF(8,'a')
sage: for x in K:
....: print x == K(x._gap_()),
True True True True True True True True
sage: K = GF(16,'a')
sage: for x in K:
....: print x == K(x._gap_()),
True True True True True
Traceback (most recent call last):
...
TypeError: unable to coerce from a finite field other than the prime subfield
I opened the [trac ticket #18048](http://trac.sagemath.org/ticket/18048) for that issue.
VincentTue, 24 Mar 2015 21:36:35 +0100https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?answer=26315#post-id-26315Comment by Koji for <p>Hello,</p>
<p>Indeed there is a bug in Sage/GAP code conversion. It works for $GF(2^3)$ but not $GF(2^4)$</p>
<pre><code>sage: K = GF(8,'a')
sage: for x in K:
....: print x == K(x._gap_()),
True True True True True True True True
sage: K = GF(16,'a')
sage: for x in K:
....: print x == K(x._gap_()),
True True True True True
Traceback (most recent call last):
...
TypeError: unable to coerce from a finite field other than the prime subfield
</code></pre>
<p>I opened the <a href="http://trac.sagemath.org/ticket/18048">trac ticket #18048</a> for that issue.</p>
<p>Vincent</p>
https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26341#post-id-26341You guys rock! I can git my way, if my life depends on it, but since it's not "mission critical", I'll wait for 6.6.Thu, 26 Mar 2015 12:57:47 +0100https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26341#post-id-26341Comment by Koji for <p>Hello,</p>
<p>Indeed there is a bug in Sage/GAP code conversion. It works for $GF(2^3)$ but not $GF(2^4)$</p>
<pre><code>sage: K = GF(8,'a')
sage: for x in K:
....: print x == K(x._gap_()),
True True True True True True True True
sage: K = GF(16,'a')
sage: for x in K:
....: print x == K(x._gap_()),
True True True True True
Traceback (most recent call last):
...
TypeError: unable to coerce from a finite field other than the prime subfield
</code></pre>
<p>I opened the <a href="http://trac.sagemath.org/ticket/18048">trac ticket #18048</a> for that issue.</p>
<p>Vincent</p>
https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26324#post-id-26324Thanks a lot for both the quick answer and the ticket. Do I get bragging rights (for my students) for uncovering this, @vdelecroix ? ;)Wed, 25 Mar 2015 09:27:33 +0100https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26324#post-id-26324Comment by vdelecroix for <p>Hello,</p>
<p>Indeed there is a bug in Sage/GAP code conversion. It works for $GF(2^3)$ but not $GF(2^4)$</p>
<pre><code>sage: K = GF(8,'a')
sage: for x in K:
....: print x == K(x._gap_()),
True True True True True True True True
sage: K = GF(16,'a')
sage: for x in K:
....: print x == K(x._gap_()),
True True True True True
Traceback (most recent call last):
...
TypeError: unable to coerce from a finite field other than the prime subfield
</code></pre>
<p>I opened the <a href="http://trac.sagemath.org/ticket/18048">trac ticket #18048</a> for that issue.</p>
<p>Vincent</p>
https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26334#post-id-26334Hopefully, Peter Bruin came with a solution to fix the bug (you can have a look on [the ticket #18048](http://trac.sagemath.org/ticket/18048). So it should be fixed in sage-6.6. In the mean time, the only solution I see is to use git to get his modifications on your computer (you do have explanations in the [Developer Guide](http://sagemath.org/doc/developer/). If you are not familiar with that it might be simpler to just wait for sage-6.6 (should be a matter of weeks).Wed, 25 Mar 2015 23:20:10 +0100https://ask.sagemath.org/question/26283/computing-minimum_distance-of-a-code-on-non-prime-fields-fails-sometimes/?comment=26334#post-id-26334