Opened 6 years ago

Closed 5 years ago

#17341 closed defect (fixed)

visualize_structure for sparse matrices over GF(p) is broken

Reported by: jhpalmieri Owned by:
Priority: minor Milestone: sage-7.1
Component: linear algebra Keywords:
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: John Palmieri
Report Upstream: N/A Work issues:
Branch: 2110b6a (Commits, GitHub, GitLab) Commit: 2110b6a1ec388a7d0e5c9123a0df20fba2312db4
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

sage: random_matrix(GF(2), 8, 586, sparse=True).visualize_structure()
IndexError: image index out of range

Solution: remove this specialized implementation, since the general one from Matrix works just fine.

In the generic visualize_structure() method, we change int -> Py_ssize_t to support matrices larger than 231.

Change History (9)

comment:1 Changed 5 years ago by jdemeyer

  • Authors set to Jeroen Demeyer
  • Description modified (diff)
  • Milestone changed from sage-6.4 to sage-7.1
  • Summary changed from visualize_structure for matrices: behavior does not match documentation to visualize_structure for sparse matrices over GF(p) is broken

visualize_structure no longer has a filename argument.

comment:2 Changed 5 years ago by jdemeyer

  • Description modified (diff)

comment:3 Changed 5 years ago by jdemeyer

  • Branch set to u/jdemeyer/visualize_structure_for_sparse_matrices_over_gf_p__is_broken

comment:4 Changed 5 years ago by jdemeyer

  • Commit set to 2110b6a1ec388a7d0e5c9123a0df20fba2312db4
  • Status changed from new to needs_review

New commits:

2bc5dbcRemove broken visualize_structure() for matrix_modn_sparse
2110b6avisualize_structure() for matrix dimensions >= 2^31

comment:5 Changed 5 years ago by jhpalmieri

I can't even create a matrix with a dimension >= 2^31:

sage: m = matrix(GF(2), 2**30, 1, {})
Killed: 9

So I can't test the second part of this. The first part looks good.

comment:6 Changed 5 years ago by jdemeyer

The transposed should work if you have sufficient memory:

M = matrix(GF(2), 1, 2^32, sparse=True)

comment:7 Changed 5 years ago by jhpalmieri

The changes make sense, but I'm still stuck trying to find an example that used to be broken and now works. I get something like this with or without the change:

sage: M = matrix(GF(2), 1, 2^32, sparse=True)
sage: M.visualize_structure(maxsize=None)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-3-f258198422bd> in <module>()
----> 1 M.visualize_structure(maxsize=None)

/Users/jpalmier/Desktop/Sage_stuff/git/sage/src/sage/matrix/matrix2.pyx in sage.matrix.matrix2.Matrix.visualize_structure (build/cythonized/sage/matrix/matrix2.c:64652)()
   8534         fct = 255.0/bisq
   8535         from sage.repl.image import Image
-> 8536         img = Image('RGB', (ir, ic))
   8537         pixel = img.pixels()
   8538         for x in range(ic):

/Users/jpalmier/Desktop/Sage_stuff/git/sage/local/lib/python2.7/site-packages/sage/repl/image.pyc in __init__(self, mode, size, color)
     95             16x16px 8-bit Color image
     96         """
---> 97         self._pil = PIL.Image.new(mode, size, color)
     98 
     99     @property

/Users/jpalmier/Desktop/Sage_stuff/git/sage/local/lib/python2.7/site-packages/PIL/Image.pyc in new(mode, size, color)
   2020         color = ImageColor.getcolor(color, mode)
   2021 
-> 2022     return Image()._new(core.fill(mode, size, color))
   2023 
   2024 

OverflowError: signed integer is greater than maximum

comment:8 Changed 5 years ago by jhpalmieri

  • Reviewers set to John Palmieri
  • Status changed from needs_review to positive_review

As I said before, the second batch of changes make sense, whether they have any immediate benefit or not. So let's merge them.

comment:9 Changed 5 years ago by vbraun

  • Branch changed from u/jdemeyer/visualize_structure_for_sparse_matrices_over_gf_p__is_broken to 2110b6a1ec388a7d0e5c9123a0df20fba2312db4
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.