Opened 3 years ago

Closed 3 years ago

#28350 closed enhancement (fixed)

Abstract Linear Code No Metric Class

Reported by: gh-emes4 Owned by: gh-emes4
Priority: major Milestone: sage-9.1
Component: coding theory Keywords: gsoc19
Cc: Dima Pasechnik, Johan Rosenkilde, Xavier Caruso, Durand Amaury Merged in:
Authors: Marketa Slukova, Amaury Durand Reviewers: Dima Pasechnik
Report Upstream: N/A Work issues:
Branch: 158d73f (Commits, GitHub, GitLab) Commit: 158d73fbc655eb05ffe09e8dc735833dbb91221b
Dependencies: Stopgaps:

Status badges

Description

With the changes in the coding component, the classes AbstractLinearCode and AbstractLinearRankMetricCode share a lot of the same code. To avoid this and also make creating new linear codes with different metrics easier, we propose to create a new class, AbstractLinearCodeNoMetric, which will stand between AbstractCode and AbstractLinearCode/AbstractLinearRankMetricCode. This class will contain all the methods relevant for linear codes, which do not depend on a metric. In practice this is mostly methods related to generator matrix.

Change History (29)

comment:1 Changed 3 years ago by gh-emes4

Branch: u/emes4/28073

comment:2 Changed 3 years ago by gh-emes4

Branch: u/emes4/28073u/emes4/28350

comment:3 Changed 3 years ago by gh-emes4

Branch: u/emes4/28350

comment:4 Changed 3 years ago by gh-emes4

Branch: u/gh-emes4/coding/no_metric
Commit: 45cf76ee5da312cf4fc2b737328daeacdd9156cf

Last 10 new commits:

40df01eFinished up documentation.
01135cbMerge branch 'develop' of git://trac.sagemath.org/sage into t/28073/abstract_code
ef7b797Merge branch 'develop' of git://trac.sagemath.org/sage into t/28073/abstract_code
9608a23Documentation and example fixes.
5230b19Merge #27634
318b444Module inheritance. Ambient_space and __call__ changes.
3996761Merge commit '8b01cc5df9e1508250976b08b4d2212aecb02927' of git://trac.sagemath.org/sage into t/28073/abstract_code
a4582a3Merge branch 'develop' of git://trac.sagemath.org/sage into t/28073/abstract_code
4dbc878documentation fix
45cf76eClass linear_code_no_metric. Moved stuff from linear_code.

comment:5 Changed 3 years ago by gh-emes4

I created the class AbstractLinearCodeNoMetric and moved stuff from AbstractLinearCode there, including the category theory set up. I don't understand what the facade does, but when I remove it, the test suite test in LinearCode is unhappy.

The only thing I couldn't get to work was the requirement that the dimension of the code is at most the length. The problem is that the dimension requires a generator matrix (unless it's given) and that causes some issues. I kept the check line commented out in __init__ of AbstractLinearCodeNoMetric.

Unlike AbstractCode, in AbstractLinearCodeNoMetric, it is required that subclasses have default encoders/decoders. This should make sense since we require a generic constructor class.

Last edited 3 years ago by gh-emes4 (previous) (diff)

comment:6 Changed 3 years ago by gh-emes4

Status: newneeds_review

comment:7 Changed 3 years ago by gh-emes4

Owner: set to gh-emes4

comment:8 Changed 3 years ago by git

Commit: 45cf76ee5da312cf4fc2b737328daeacdd9156cf01d9a3d0d6af1995325233e913de98f48baf488c

Branch pushed to git repo; I updated commit sha1. New commits:

01d9a3dMerge branch 'develop' of git://trac.sagemath.org/sage into t/28350/abstract_linear_code_no_metric_class

comment:9 Changed 3 years ago by git

Commit: 01d9a3d0d6af1995325233e913de98f48baf488c226ffbf1baf068c0b01df70543554b2be7cb9d5e

Branch pushed to git repo; I updated commit sha1. New commits:

226ffbfAdded no metric to coding documentation index. Moved zero method from AbstractLinearCode. Changed base_field check.

comment:10 Changed 3 years ago by gh-emes4

Updated Sage.

Added linear_code_no_metric.py to the index of coding module documentation.

Moved zero method from AbstractLinearCode.

Changed base_field check message.

comment:11 Changed 3 years ago by Dima Pasechnik

Status: needs_reviewneeds_work

with python3: (i.e. doing ./configure --with-python=3 && make)

sage -t src/sage/coding/decoder.py
**********************************************************************
File "src/sage/coding/decoder.py", line 197, in sage.coding.decoder.Decoder.__hash__
Failed example:
    hash(D) #random
Exception raised:
    Traceback (most recent call last):
      File "/mnt/opt/Sage/sage-dev/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 681, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/mnt/opt/Sage/sage-dev/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1123, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.coding.decoder.Decoder.__hash__[3]>", line 1, in <module>
        hash(D) #random
      File "/mnt/opt/Sage/sage-dev/local/lib/python3.7/site-packages/sage/coding/linear_code.py", line 2632, in __hash__
        return hash((self.code(), self.maximum_error_weight()))
    TypeError: unhashable type: 'LinearCode_with_category'
**********************************************************************

this causes more errors

sage -t src/sage/coding/decoder.py  # 1 doctest failed
sage -t src/sage/coding/linear_code_no_metric.py  # 2 doctests failed
sage -t src/sage/coding/linear_code.py  # 1 doctest failed

comment:12 Changed 3 years ago by Xavier Caruso

Cc: Xavier Caruso added

comment:13 Changed 3 years ago by Durand Amaury

Cc: Durand Amaury added

comment:14 Changed 3 years ago by Dima Pasechnik

Any chance this could be brought forward - it holds up few more tickets...

comment:15 Changed 3 years ago by Johan Rosenkilde

I unfortunately don't have any time to move on this currently :-(

comment:16 Changed 3 years ago by gh-emes4

I will have a look at it this week!

comment:17 Changed 3 years ago by Erik Bray

Milestone: sage-8.9sage-9.1

Ticket retargeted after milestone closed

comment:18 Changed 3 years ago by Durand Amaury

Branch: u/gh-emes4/coding/no_metricu/gh-Adurand8/coding/no_metric

comment:19 Changed 3 years ago by Xavier Caruso

Commit: 226ffbf1baf068c0b01df70543554b2be7cb9d5edbaaaa1a685e1dbaca57997ce3f0f56882382745

Hello,

I'm not really satisfied with the names of the classes. Instead, I would propose the following hierarchy:

AbstractCode
  AbstractLinearCode
    AbstractLinearMetricCode
      AbstractLinearHammingMetricCode  # if relevant
      AbstractLinearRankMetricCode

Also, through it is not directly related to this ticket, I don't understand the purpose of the class LinearCode...


New commits:

d49390emerged version 9.1.beta1
80ff011Add function hash
dbaaaa1Merge branch 'develop' into t/28350/coding/no_metric

comment:20 Changed 3 years ago by git

Commit: dbaaaa1a685e1dbaca57997ce3f0f56882382745db3b18af01e1527f6d393405945d6d722d9c41b1

Branch pushed to git repo; I updated commit sha1. New commits:

db3b18aError commit on linear_code_no_metric in precedent commit

comment:21 in reply to:  19 Changed 3 years ago by Dima Pasechnik

Replying to caruso:

I'm not really satisfied with the names of the classes.

I'd propose that we complete this ticket and #28209 (which depends on this ticket) with as few chnages as posssible, and then go on with renaming/redesigning.

comment:22 Changed 3 years ago by Dima Pasechnik

Authors: Marketa SlukovaMarketa Slukova, Durand Amaury

tests pass now. Is it ready for review?

comment:23 Changed 3 years ago by Dima Pasechnik

Authors: Marketa Slukova, Durand AmauryMarketa Slukova, Amaury Durand

comment:24 Changed 3 years ago by Dima Pasechnik

Ping?

comment:25 Changed 3 years ago by Johan Rosenkilde

Dima, is there a specific reason you refrain from reviewing yourself? I'm completely swamped right now, so there's no chance I'll do it any time soon, but I remember being fairly happy about the design during GSoC.

@caruso: Concerning your proposed naming, I guess your names are better from a completely general point of view. The current naming is for "historic reasons" centering on classical "linear codes over Hamming metric" being what everyone would expect. So in some sense the names follow the principal of least surprise by specifically pointing out in the name when it differs from the "expected". But I think I could easily be talked into going with your hierarchy.

The purpose of LinearCode btw is to act as a thin wrapper around AbstractLinearCode for constructing "unstructured" codes directly from a generator matrix. That's an essential class for users. The distinction from AbstractLinearCode was created as part of the encoder-framework (long story), but is a typical way to construct a class hierarchy in more strongly typed languages: if I could do so in Python, I would specify on a type level that AbstractLinearCode? is not supposed to be instantiated directly.

comment:26 Changed 3 years ago by Dima Pasechnik

Reviewers: Dima Pasechnik
Status: needs_workpositive_review

I was not reviewing as the ticket is set to needs work. So I've set it to needs review and to positive review now.

comment:27 Changed 3 years ago by Volker Braun

Status: positive_reviewneeds_work

Merge conflit

comment:28 Changed 3 years ago by Dima Pasechnik

Branch: u/gh-Adurand8/coding/no_metricu/dimpase/coding/no_metric
Commit: db3b18af01e1527f6d393405945d6d722d9c41b1158d73fbc655eb05ffe09e8dc735833dbb91221b
Dependencies: #28073
Status: needs_workpositive_review

rebased


New commits:

244f4afClass linear_code_no_metric. Moved stuff from linear_code.
c716526Added no metric to coding documentation index. Moved zero method from AbstractLinearCode. Changed base_field check.
0b5baa0Add function hash
158d73fError commit on linear_code_no_metric in precedent commit

comment:29 Changed 3 years ago by Volker Braun

Branch: u/dimpase/coding/no_metric158d73fbc655eb05ffe09e8dc735833dbb91221b
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.