Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Fixes responding to reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Jul 31, 2019
1 parent c8706ee commit fb35c2f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 109 deletions.
2 changes: 1 addition & 1 deletion src/doc/en/reference/coding/index.rst
Expand Up @@ -60,7 +60,7 @@ matrix and has no other a priori knowledge on them:
sage/coding/self_dual_codes
sage/coding/binary_code

Code Constructions
Derived Code Constructions
--------------------------

Sage supports the following derived code constructions. If the constituent code
Expand Down
21 changes: 8 additions & 13 deletions src/sage/coding/decoder.py
Expand Up @@ -222,7 +222,7 @@ def __ne__(self, other):

def decode_to_code(self, r):
r"""
Corrects the errors in ``r`` and returns a codeword.
Correct the errors in ``r`` and returns a codeword.
This is a default implementation which assumes that the method
:meth:`decode_to_message` has been implemented, else it returns an exception.
Expand Down Expand Up @@ -255,14 +255,9 @@ def decode_to_code(self, r):
word = self.decode_to_message(r)
return self.connected_encoder().encode(word)

def connected_encoder(self, *args, **kwargs):
def connected_encoder(self):
r"""
Returns the connected encoder of ``self``.
INPUT:
- ``args``, ``kwargs`` -- all additional arguments are forwarded to the constructor of the encoder
this method will return.
Return the connected encoder of ``self``.
EXAMPLES::
Expand All @@ -272,7 +267,7 @@ def connected_encoder(self, *args, **kwargs):
sage: D.connected_encoder()
Generator matrix-based encoder for [7, 4] linear code over GF(2)
"""
return self.code().encoder(self._connected_encoder_name, *args, **kwargs)
return self.code().encoder(encoder_name=self._connected_encoder_name)

def decode_to_message(self, r):
r"""
Expand Down Expand Up @@ -305,7 +300,7 @@ def decode_to_message(self, r):

def code(self):
r"""
Returns the code for this :class:`Decoder`.
Return the code for this :class:`Decoder`.
EXAMPLES::
Expand All @@ -319,7 +314,7 @@ def code(self):

def message_space(self):
r"""
Returns the message space of ``self``'s :meth:`connected_encoder`.
Return the message space of ``self``'s :meth:`connected_encoder`.
EXAMPLES::
Expand All @@ -333,7 +328,7 @@ def message_space(self):

def input_space(self):
r"""
Returns the input space of ``self``.
Return the input space of ``self``.
EXAMPLES::
Expand All @@ -351,7 +346,7 @@ def input_space(self):
@abstract_method(optional = True)
def decoding_radius(self, **kwargs):
r"""
Returns the maximal number of errors that ``self`` is able to correct.
Return the maximal number of errors that ``self`` is able to correct.
This is an abstract method and it should be implemented in subclasses.
Expand Down
43 changes: 27 additions & 16 deletions src/sage/coding/goppa.py
Expand Up @@ -11,10 +11,10 @@
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: C
[55, 16] Goppa code
[55, 16] Goppa code over GF(2)
sage: E = codes.encoders.GoppaCodeEncoder(C)
sage: E
Encoder for [55, 16] Goppa code
Encoder for [55, 16] Goppa code over GF(2)
AUTHORS:
Expand Down Expand Up @@ -89,7 +89,7 @@ class GoppaCode(AbstractLinearCode):
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: C
[55, 16] Goppa code
[55, 16] Goppa code over GF(2)
"""
_registered_encoders = {}
_registered_decoders = {}
Expand Down Expand Up @@ -135,10 +135,10 @@ def _repr_(self):
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: C
[8, 2] Goppa code
[8, 2] Goppa code over GF(2)
"""
return "[{}, {}] Goppa code".format(self.length(), self.dimension())

return "[{}, {}] Goppa code over GF({})".format(
self.length(), self.dimension(), self.base_field().cardinality())
def _latex_(self):
r"""
Return a latex representation of ``self``.
Expand All @@ -151,14 +151,18 @@ def _latex_(self):
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: latex(C)
[8, 2]\text{ Goppa code}
[8, 2]\text{ Goppa code over }\Bold{F}_{2}
"""
return r"[{}, {}]\text{{ Goppa code}}".format(self.length(), self.dimension())
return r"[{}, {}]\text{{ Goppa code over }}{}".format(self.length(), self.dimension(),
self.base_field()._latex_())

def __eq__(self, other):
"""
Test equality with ``other``.
Two Goppa codes are considered the same when defining sets and
generating polynomials are the same.
EXAMPLES::
sage: F = GF(2^3)
Expand All @@ -169,6 +173,13 @@ def __eq__(self, other):
sage: D = codes.GoppaCode(g, L)
sage: C == D
True
Note that equality check will be false if ``other`` represents the same
linear code as ``self`` but not constructed as a Goppa code::
sage: E = LinearCode(C.generator_matrix())
sage: C == E
False
"""
return (isinstance(other, GoppaCode)
and self.length() == other.length()
Expand All @@ -195,7 +206,7 @@ def parity_check_matrix(self):
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: C
[8, 2] Goppa code
[8, 2] Goppa code over GF(2)
sage: C.parity_check_matrix()
[1 0 0 0 0 0 0 1]
[0 0 1 0 1 1 1 0]
Expand Down Expand Up @@ -245,7 +256,7 @@ def _parity_check_matrix_vandermonde(self):
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: C
[8, 2] Goppa code
[8, 2] Goppa code over GF(2)
sage: C._parity_check_matrix_vandermonde()
[1 0 0 0 0 0 0 1]
[0 0 1 0 1 1 1 0]
Expand Down Expand Up @@ -290,7 +301,7 @@ def distance_bound(self):
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: C
[8, 2] Goppa code
[8, 2] Goppa code over GF(2)
sage: C.distance_bound()
3
sage: C.minimum_distance()
Expand All @@ -316,10 +327,10 @@ class GoppaCodeEncoder(Encoder):
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: C
[8, 2] Goppa code
[8, 2] Goppa code over GF(2)
sage: E = codes.encoders.GoppaCodeEncoder(C)
sage: E
Encoder for [8, 2] Goppa code
Encoder for [8, 2] Goppa code over GF(2)
sage: word = vector(GF(2), (0, 1))
sage: c = E.encode(word)
sage: c
Expand Down Expand Up @@ -356,7 +367,7 @@ def _repr_(self):
sage: C = codes.GoppaCode(g, L)
sage: E = codes.encoders.GoppaCodeEncoder(C)
sage: E
Encoder for [8, 2] Goppa code
Encoder for [8, 2] Goppa code over GF(2)
"""
return "Encoder for {}".format(self.code())

Expand All @@ -373,7 +384,7 @@ def _latex_(self):
sage: C = codes.GoppaCode(g, L)
sage: E = codes.encoders.GoppaCodeEncoder(C)
sage: latex(E)
\text{Encoder for }[8, 2]\text{ Goppa code}
\text{Encoder for }[8, 2]\text{ Goppa code over }\Bold{F}_{2}
"""
return r"\text{{Encoder for }}{}".format(self.code()._latex_())

Expand Down Expand Up @@ -411,7 +422,7 @@ def generator_matrix(self):
sage: L = [a for a in F.list() if g(a) != 0]
sage: C = codes.GoppaCode(g, L)
sage: C
[8, 2] Goppa code
[8, 2] Goppa code over GF(2)
sage: C.generator_matrix()
[1 0 0 1 0 1 1 1]
[0 1 1 1 1 1 1 0]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/coding/grs_code.py
@@ -1,5 +1,5 @@
r"""
Reed-Solomon codes and GRS codes
Reed-Solomon codes and Generalized Reed-Solomon codes
Given `n` different evaluation points `\alpha_1, \dots, \alpha_n` from some
finite field `F`, the corresponding Reed-Solomon code (RS code) of dimension
Expand Down
12 changes: 4 additions & 8 deletions src/sage/coding/hamming_code.py
@@ -1,17 +1,14 @@
r"""
Hamming code
Hamming codes
Given an integer `r` and a field `F`, such that `F=GF(q)`,
the `[n, k, d]` code with length `n=\frac{q^{r}-1}{q-1}`,
dimension `k=\frac{q^{r}-1}{q-1} - r` and minimum distance
`d=3` is called the Hamming Code of order `r`.
Given an integer `r` and a field `F`, such that `F=GF(q)`, the `[n, k, d]` code
with length `n=\frac{q^{r}-1}{q-1}`, dimension `k=\frac{q^{r}-1}{q-1} - r` and
minimum distance `d=3` is called the Hamming Code of order `r`.
REFERENCES:
- [Rot2006]_
"""
from __future__ import absolute_import

# ****************************************************************************
# Copyright (C) 2016 David Lucas <david.lucas@inria.fr>
#
Expand All @@ -21,7 +18,6 @@
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************

from .linear_code import AbstractLinearCode
from sage.matrix.matrix_space import MatrixSpace
from sage.schemes.projective.projective_space import ProjectiveSpace
Expand Down

0 comments on commit fb35c2f

Please sign in to comment.