New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading and saving BinaryMatroids can cause infinite loops #23437
Comments
This comment has been minimized.
This comment has been minimized.
comment:1
I think your guess is probably correct because when you get the bases of the new object (or do not construct them for the old object), then this works.
Also, if you look at the pickling data, there is a difference
I simplified the example to get the code to fail. |
comment:2
Hey all! I managed to hunt down the problem here; I'll get the patch up shortly. The issue is in the method sage: M = matroids.named_matroids.Fano().dual()
sage: _ = list(M.bases())
sage: N = loads(dumps(M))
sage: N.closure(frozenset({'d'})) # !
frozenset({'e'}) The code in
The code which is problematic is the following, at lines 3951 to 3960 in if self._representation is not None:
A = self._representation
gs = self._E
basis = None
else:
A = self._A
for e in self.basis():
basis[self._prow[self._idx[e]]] = e
rows, cols = self._current_rows_cols()
gs = rows + cols When an explicit representation of a matroid hasn't been generated, the existing code in However, the matrix These assumptions and the corresponding issue in the |
Commit: |
Author: Bryan Gillespie |
New commits:
|
comment:5
It is great that you were able to track down the problem (I am not sure I completely understand the issue in full technicality, but I just need to reread what you wrote more carefully). I do have a few little fixes, but otherwise your branch is good.
|
comment:6
Great, I'll make the changes and push the updated branch in a bit. Just for my understanding, what's the advantage of avoiding Also, managed to find appropriate corresponding bugs/tests for the sage: from sage.matroids.advanced import TernaryMatroid
sage: X_bin = matroids.named_matroids.Fano().representation()
sage: X = Matrix(GF(3, 'x'), X_bin)
sage: M = TernaryMatroid(matrix=X).dual()
sage: B = list(M.bases())
sage: N = loads(dumps(M))
sage: N.closure(frozenset({3}))
frozenset({4})
sage: N.is_isomorphic(M) and sage: from sage.matroids.advanced import QuaternaryMatroid
sage: X_bin = matroids.named_matroids.Fano().representation()
sage: X = Matrix(GF(4, 'x'), X_bin)
sage: M = QuaternaryMatroid(matrix=X).dual()
sage: B = list(M.bases())
sage: N = loads(dumps(M))
sage: N.closure(frozenset({3}))
frozenset({4})
sage: N.is_isomorphic(M) both hang on the current development branch, but are fixed by the patch. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:8
Replying to @bgillesp:
It is not really a good variable name, even if it is for something to be discarded. I think it might also not be valid or considered as evil on Python3.
Great. Thank you. Positive review. |
Reviewer: Travis Scrimshaw |
Changed branch from u/bgillespie/loading_and_saving_binarymatroids_can_cause_infinite_loops to |
The following results in an unending loop:
My guess is that
N
thinks some invariant has been computed, when it really hasn't been computed. You need to do something withM
before saving to trigger the behavior.CC: @sagetrac-Rudi @sagetrac-zgershkoff @sagetrac-yomcat @bgillesp
Component: matroid theory
Author: Bryan Gillespie
Branch/Commit:
4075773
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/23437
The text was updated successfully, but these errors were encountered: