Opened 7 years ago
Closed 7 years ago
#20340 closed defect (fixed)
GRS decode_to_code and decode_to_message fail on messages in the code
Reported by:  cprior  Owned by:  

Priority:  major  Milestone:  sage7.2 
Component:  coding theory  Keywords:  
Cc:  dlucas  Merged in:  
Authors:  Julien Lavauzelle  Reviewers:  David Lucas 
Report Upstream:  N/A  Work issues:  
Branch:  d4bbfdd (Commits, GitHub, GitLab)  Commit:  d4bbfddd4682577d0f1e79a1303d7cf07cad8657 
Dependencies:  Stopgaps: 
Description
Currently, the following occurs
sage: F = GF(59) sage: length = 40 sage: dimension = 12 sage: eval_pts = F.list()[:length] sage: col_mults = F.list()[1:length+1] sage: C = codes.GeneralizedReedSolomonCode(eval_pts, dimension, col_mults) sage: msg = random_vector(F, dimension) sage: c = C.encode(msg) sage: c in C True sage: c.decode_to_code(c) 7 # random; first entry of msg (expected c) sage: c.decode_to_message(c) Traceback (most recent call last) ... TypeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object is not iterable
We expect:
... sage: c.decode_to_code(c) == c True sage: c.decode_to_message(c) == msg True
Change History (10)
comment:1 Changed 7 years ago by
comment:2 Changed 7 years ago by
Hi again,
My mistake, I didn't run the most recent version of Sage. Your typo fooled me, but you're completely right, there's indeed an issue with these methods.
Julien
comment:3 Changed 7 years ago by
Branch:  → u/jlavauzelle/fix_decode_methods 

comment:4 Changed 7 years ago by
Commit:  → 4bca107e876219e61793fbfa5e8d7e2cbca1f044 

Hello,
Just a few remarks:
 when you push a fix on a ticket, don't forget to change its state to
needs_review
 you can also put your (full) name on the
Authors
field  and when it's a bug fix, you can add a new doctest which shows the bug has been fixed, e.g.
EXAMPLES: The bug detailed in trac #20340 has been fixed:: sage: C = codes.GeneralizedReedSolomonCode(GF(59).list()[:40], 12) sage: c = C.random_element() sage: D = C.decoder("BerlekampWelch") sage: D.decode_to_code(c) == c True
Otherwise, it seems all good to me!
Best,
David
New commits:
4bca107  Fixed error on _decode_to_code_and_message() methods

comment:5 Changed 7 years ago by
Authors:  → Julien Lavauzelle 

Status:  new → needs_review 
Thanks David,
Following your advice, I added the doctest and some short summaries of the decoders in the top documentation of the grs.py file.
Best,
Julien
comment:6 Changed 7 years ago by
Commit:  4bca107e876219e61793fbfa5e8d7e2cbca1f044 → e4bdd3d561883ffe012fbf23284819f242d72024 

Branch pushed to git repo; I updated commit sha1. New commits:
e4bdd3d  Add a doctest and fix documentation.

comment:7 Changed 7 years ago by
Branch:  u/jlavauzelle/fix_decode_methods → u/dlucas/fix_decode_methods 

comment:8 Changed 7 years ago by
Commit:  e4bdd3d561883ffe012fbf23284819f242d72024 → d4bbfddd4682577d0f1e79a1303d7cf07cad8657 

Reviewers:  → David Lucas 
Hello,
I copied your doctest in every method which was previously impacted by the bug.
If you agree with my changes, set it to positive_review
, on my side, I'm fine with your fix.
David
New commits:
d4bbfdd  Replicated doctest for the fixed bug in every (once) flawed method

comment:10 Changed 7 years ago by
Branch:  u/dlucas/fix_decode_methods → d4bbfddd4682577d0f1e79a1303d7cf07cad8657 

Resolution:  → fixed 
Status:  positive_review → closed 
Hi,
I think you mixed codeword and code in your script. Both
decode_to_code
anddecode_to_message
are methods of the code's class. So the good syntax is:Julien