Opened 8 years ago

Last modified 6 years ago

#14546 new defect

random_matrix fails with variable reference error

Reported by: jason Owned by: jason, was
Priority: major Milestone: sage-6.4
Component: linear algebra Keywords:
Cc: rbeezer Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by jason)

sage: random_matrix(QQ,5,algorithm='echelonizable', rank=1,upper_bound=10)
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-23-e4c44e36a25b> in <module>()
----> 1 random_matrix(QQ,Integer(5),algorithm='echelonizable', rank=randint(Integer(1),Integer(5)),upper_bound=Integer(10))

/Users/grout/sage-trees/sage-5.9/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in random_matrix(ring, nrows, ncols, algorithm, *args, **kwds)
   1348         return random_rref_matrix(parent, *args, **kwds)
   1349     elif algorithm == 'echelonizable':
-> 1350         return random_echelonizable_matrix(parent, *args, **kwds)
   1351     elif algorithm == 'diagonalizable':
   1352         return random_diagonalizable_matrix(parent, *args, **kwds)

/Users/grout/sage-trees/sage-5.9/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in random_echelonizable_matrix(parent, rank, upper_bound)
   3320                         matrix_copy=matrix.with_added_multiple_of_row(row_index,matrix.pivot_rows()[pivots],randint(-5,5))
   3321                         # Range for scalar multiples determined experimentally.
-> 3322                     if max(map(abs,matrix_copy.list()))<upper_bound:
   3323                     # Continue if the the largest entry after a row operation is within the bound.
   3324                         matrix=matrix_copy

UnboundLocalError: local variable 'matrix_copy' referenced before assignment

Change History (6)

comment:1 Changed 8 years ago by jason

  • Description modified (diff)

comment:2 Changed 7 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:3 Changed 7 years ago by rbeezer

Rank 1 case (which is subject of report) is fixed as part of current patches up at #11772.

comment:4 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:5 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:6 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.