Skip to content

Commit

Permalink
Trac #33751: random doctest failure in src/sage/matrix/matrix_integer…
Browse files Browse the repository at this point in the history
…_dense_hnf.py

Part of #32544:

{{{#!sage
sage -t --random-seed=47467259736041671371069989299524409608
src/sage/matrix/matrix_integer_dense_hnf.py
**********************************************************************
File "src/sage/matrix/matrix_integer_dense_hnf.py", line 1240, in
sage.matrix.matrix_integer_dense_hnf.?
Failed example:
    matrix_integer_dense_hnf.sanity_checks(times=5,
check_using_magma=False)
Exception raised:
    Traceback (most recent call last):
      File "~/sage/src/sage/doctest/forker.py", line 695, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "~/sage/src/sage/doctest/forker.py", line 1093, in
compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.matrix.matrix_integer_dense_hnf.?[1]>", line
1, in <module>
        matrix_integer_dense_hnf.sanity_checks(times=Integer(5),
check_using_magma=False)
      File "~/sage/src/sage/matrix/matrix_integer_dense_hnf.py", line
1285, in sanity_checks
        __do_check([random_matrix(ZZ, n, m, x=-2**32, y=2**32)
      File "~/sage/src/sage/matrix/matrix_integer_dense_hnf.py", line
1276, in __do_check
        if hnf(a)[0] != a.echelon_form(algorithm='pari'):
      File "~/sage/src/sage/matrix/matrix_integer_dense_hnf.py", line
1106, in hnf
        H, pivots = probable_hnf(A, include_zero_rows=include_zero_rows,
      File "~/sage/src/sage/matrix/matrix_integer_dense_hnf.py", line
926, in probable_hnf
        H = hnf_square(C, proof=proof)
      File "~/sage/src/sage/matrix/matrix_integer_dense_hnf.py", line
568, in hnf_square
        raise ValueError("A must be square.")
    ValueError: A must be square.
**********************************************************************
}}}

(From a patchbot run in #33619.)

URL: https://trac.sagemath.org/33751
Reported by: lorenz
Ticket author(s): Jonathan Kliem
Reviewer(s): Kevin Lui
  • Loading branch information
Release Manager committed May 9, 2022
2 parents fc3cbe0 + 7ac22ad commit a454989
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/sage/matrix/matrix_integer_dense_hnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,13 +1103,18 @@ def hnf(A, include_zero_rows=True, proof=True):
return H.matrix_from_rows(range(len(pivots))), pivots

while True:
H, pivots = probable_hnf(A, include_zero_rows=include_zero_rows,
try:
H, pivots = probable_hnf(A, include_zero_rows=include_zero_rows,
proof=True)
except ValueError:
verbose("The attempt failed since the pivots must have been wrong. We try again.")
continue

if is_in_hnf_form(H, pivots):
if not include_zero_rows and len(pivots) > H.nrows():
H = H.matrix_from_rows(range(len(pivots)))
return H, pivots
verbose("After attempt the return matrix is not in HNF form since pivots must have been wrong. We try again.")
verbose("After attempt the return matrix is not in HNF form since pivots must have been wrong. We try again.")


def hnf_with_transformation(A, proof=True):
Expand Down

0 comments on commit a454989

Please sign in to comment.