Skip to content
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

visualize_structure for sparse matrices over GF(p) is broken #17341

Closed
jhpalmieri opened this issue Nov 13, 2014 · 13 comments
Closed

visualize_structure for sparse matrices over GF(p) is broken #17341

jhpalmieri opened this issue Nov 13, 2014 · 13 comments

Comments

@jhpalmieri
Copy link
Member

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 2^31.

Component: linear algebra

Author: Jeroen Demeyer

Branch/Commit: 2110b6a

Reviewer: John Palmieri

Issue created by migration from https://trac.sagemath.org/ticket/17341

@jdemeyer
Copy link

comment:1

visualize_structure no longer has a filename argument.

@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link

Author: Jeroen Demeyer

@jdemeyer jdemeyer modified the milestones: sage-6.4, sage-7.1 Feb 11, 2016
@jdemeyer jdemeyer changed the title visualize_structure for matrices: behavior does not match documentation visualize_structure for sparse matrices over GF(p) is broken Feb 11, 2016
@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link

@jdemeyer
Copy link

New commits:

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

@jdemeyer
Copy link

Commit: 2110b6a

@jhpalmieri
Copy link
Member Author

comment:5

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.

@jdemeyer
Copy link

comment:6

The transposed should work if you have sufficient memory:

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

@jhpalmieri
Copy link
Member Author

comment:7

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

@jhpalmieri
Copy link
Member Author

Reviewer: John Palmieri

@jhpalmieri
Copy link
Member Author

comment:8

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

@vbraun
Copy link
Member

vbraun commented Mar 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants