Opened 14 months ago

Closed 7 months 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: dimpase, jsrn, caruso, gh-Adurand8 Merged in:
Authors: Marketa Slukova, Amaury Durand Reviewers: Dima Pasechnik
Report Upstream: N/A Work issues:
Branch: 158d73f (Commits) Commit: 158d73fbc655eb05ffe09e8dc735833dbb91221b
Dependencies: Stopgaps:

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 14 months ago by gh-emes4

  • Branch set to u/emes4/28073

comment:2 Changed 14 months ago by gh-emes4

  • Branch changed from u/emes4/28073 to u/emes4/28350

comment:3 Changed 14 months ago by gh-emes4

  • Branch u/emes4/28350 deleted

comment:4 Changed 14 months ago by gh-emes4

  • Branch set to u/gh-emes4/coding/no_metric
  • Commit set to 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 14 months 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 14 months ago by gh-emes4 (previous) (diff)

comment:6 Changed 14 months ago by gh-emes4

  • Status changed from new to needs_review

comment:7 Changed 14 months ago by gh-emes4

  • Owner changed from (none) to gh-emes4

comment:8 Changed 13 months ago by git

  • Commit changed from 45cf76ee5da312cf4fc2b737328daeacdd9156cf to 01d9a3d0d6af1995325233e913de98f48baf488c

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 13 months ago by git

  • Commit changed from 01d9a3d0d6af1995325233e913de98f48baf488c to 226ffbf1baf068c0b01df70543554b2be7cb9d5e

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 13 months 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 13 months ago by dimpase

  • Status changed from needs_review to needs_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 12 months ago by caruso

  • Cc caruso added

comment:13 Changed 12 months ago by gh-Adurand8

  • Cc gh-Adurand8 added

comment:14 Changed 11 months ago by dimpase

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

comment:15 Changed 11 months ago by jsrn

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

comment:16 Changed 11 months ago by gh-emes4

I will have a look at it this week!

comment:17 Changed 9 months ago by embray

  • Milestone changed from sage-8.9 to sage-9.1

Ticket retargeted after milestone closed

comment:18 Changed 8 months ago by gh-Adurand8

  • Branch changed from u/gh-emes4/coding/no_metric to u/gh-Adurand8/coding/no_metric

comment:19 follow-up: Changed 8 months ago by caruso

  • Commit changed from 226ffbf1baf068c0b01df70543554b2be7cb9d5e to dbaaaa1a685e1dbaca57997ce3f0f56882382745

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 8 months ago by git

  • Commit changed from dbaaaa1a685e1dbaca57997ce3f0f56882382745 to db3b18af01e1527f6d393405945d6d722d9c41b1

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 8 months ago by dimpase

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 8 months ago by dimpase

  • Authors changed from Marketa Slukova to Marketa Slukova, Durand Amaury

tests pass now. Is it ready for review?

comment:23 Changed 8 months ago by dimpase

  • Authors changed from Marketa Slukova, Durand Amaury to Marketa Slukova, Amaury Durand

comment:24 Changed 7 months ago by dimpase

Ping?

comment:25 Changed 7 months ago by jsrn

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 7 months ago by dimpase

  • Reviewers set to Dima Pasechnik
  • Status changed from needs_work to positive_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 7 months ago by vbraun

  • Status changed from positive_review to needs_work

Merge conflit

comment:28 Changed 7 months ago by dimpase

  • Branch changed from u/gh-Adurand8/coding/no_metric to u/dimpase/coding/no_metric
  • Commit changed from db3b18af01e1527f6d393405945d6d722d9c41b1 to 158d73fbc655eb05ffe09e8dc735833dbb91221b
  • Dependencies #28073 deleted
  • Status changed from needs_work to positive_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 7 months ago by vbraun

  • Branch changed from u/dimpase/coding/no_metric to 158d73fbc655eb05ffe09e8dc735833dbb91221b
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.