Ask Your Question

Computing minimum_distance of a code on non-prime fields fails ... sometimes.

asked 2015-03-23 15:54:25 +0200

Koji gravatar image

updated 2017-01-08 12:06:18 +0200

FrédéricC gravatar image

Consider the following piece of code:


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?

edit retag flag offensive close merge delete



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()
vdelecroix gravatar imagevdelecroix ( 2015-03-23 23:33:29 +0200 )edit

Yes, 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):

Thanks though for the interest, @vdelecroix

Koji gravatar imageKoji ( 2015-03-24 20:06:02 +0200 )edit

@Koji, all right. Got the error as well!

vdelecroix gravatar imagevdelecroix ( 2015-03-24 21:10:24 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-03-24 21:36:35 +0200

vdelecroix gravatar image

updated 2015-03-24 21:38:15 +0200


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 for that issue.


edit flag offensive delete link more


Thanks a lot for both the quick answer and the ticket. Do I get bragging rights (for my students) for uncovering this, @vdelecroix ? ;)

Koji gravatar imageKoji ( 2015-03-25 09:27:33 +0200 )edit

Hopefully, Peter Bruin came with a solution to fix the bug (you can have a look on the 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. If you are not familiar with that it might be simpler to just wait for sage-6.6 (should be a matter of weeks).

vdelecroix gravatar imagevdelecroix ( 2015-03-25 23:20:10 +0200 )edit

You 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.

Koji gravatar imageKoji ( 2015-03-26 12:57:47 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-03-23 15:54:25 +0200

Seen: 325 times

Last updated: Mar 24 '15