Hi, I am trying to make a large sparse matrix - the values are all integers (in fact all non-zeros will be 1) so it would save me a lot of memory if I could use dtype=byte. However: In [23]: test=sparse.lil_matrix((10,10),dtype=byte) In [24]: test.dtype Out[24]: dtype('float64') Is this correct or is there something up here? Thanks Robin
On 10/9/07, Robin <robince@gmail.com> wrote:
I am trying to make a large sparse matrix - the values are all integers (in fact all non-zeros will be 1) so it would save me a lot of memory if I could use dtype=byte.
I added 'b' to the string of allowed dtypes in getdtype() on line 2791 of sparse.py. It now seems to behave as I would expect (hope), but it can't be that simple can it? Is it likely that doing this will break something else? Why are the dtypes restricted in the first place. Thanks Robin
On Tue, Oct 09, 2007 at 03:03:20PM +0100, Robin wrote:
On 10/9/07, Robin <robince@gmail.com> wrote:
I am trying to make a large sparse matrix - the values are all integers (in fact all non-zeros will be 1) so it would save me a lot of memory if I could use dtype=byte.
I added 'b' to the string of allowed dtypes in getdtype() on line 2791 of sparse.py.
It now seems to behave as I would expect (hope), but it can't be that simple can it?
Is it likely that doing this will break something else? Why are the dtypes restricted in the first place.
Like I mentioned before, this is on the TODO list: http://projects.scipy.org/scipy/scipy/ticket/225 For most situations, changing the line you did should work. I haven't looked into what effect it will have on the routines implemented in C++. Stéfan
Robin <robince <at> gmail.com> writes:
On 10/9/07, Robin <robince <at> gmail.com> wrote: I am trying to make a large sparse matrix - the values are all integers (in
fact all non-zeros will be 1) so it would save me a lot of memory if I could use dtype=byte.
I added 'b' to the string of allowed dtypes in getdtype() on line 2791 of sparse.py.It now seems to behave as I would expect (hope), but it can't be
that simple can it?Is it likely that doing this will break something else? Why are the dtypes restricted in the first place.ThanksRobin
FWIW integer dtypes are supported in the next release (and the current SVN) http://projects.scipy.org/scipy/scipy/ticket/225 The problem before was not on the python side. It was the backend code (sparse.sparsetools) that didn't support integer types.
participants (3)
-
Nathan Bell
-
Robin
-
Stefan van der Walt