[Scipy-tickets] [SciPy] #997: scipy.sparse.dok_matrix is not resizable

SciPy Trac scipy-tickets@scipy....
Fri Nov 26 21:32:49 CST 2010


#997: scipy.sparse.dok_matrix is not resizable
--------------------------+-------------------------------------------------
 Reporter:  jap           |       Owner:  wnbell
     Type:  defect        |      Status:  new   
 Priority:  normal        |   Milestone:  0.9.0 
Component:  scipy.sparse  |     Version:  0.7.0 
 Keywords:                |  
--------------------------+-------------------------------------------------

Old description:

> scipy.sparse.dok_matrix is not resizable:
>
> In [24]: a = scipy.sparse.dok_matrix
> In [25]: b = a((10,10))
> In [26]: b.resize
> Out[26]:
> <bound method dok_matrix.resize of <10x10 sparse matrix of type '<type
> 'numpy.float64'>'
>         with 0 stored elements in Dictionary Of Keys format>>
>
> In [27]: b.resize((20,10))
> ---------------------------------------------------------------------------
> NotImplementedError                       Traceback (most recent call
> last)
>
> /home/spaans/projects/<ipython console> in <module>()
>
> /usr/lib/python2.6/dist-packages/scipy/sparse/dok.pyc in resize(self,
> shape)
>     536                 if i >= newM or j >= newN:
>     537                     del self[i, j]
> --> 538         self.shape = shape
>     539
>     540
>
> /usr/lib/python2.6/dist-packages/scipy/sparse/base.pyc in set_shape(self,
> shape)
>      76             except NotImplementedError:
>      77                 raise NotImplementedError("Reshaping not
> implemented for %s." %
> ---> 78
> self.__class__.__name__)
>      79         self._shape = shape
>      80
>
> Easy patch attached:

New description:

 scipy.sparse.dok_matrix is not resizable:
 {{{
 In [24]: a = scipy.sparse.dok_matrix
 In [25]: b = a((10,10))
 In [26]: b.resize
 Out[26]:
 <bound method dok_matrix.resize of <10x10 sparse matrix of type '<type
 'numpy.float64'>'
         with 0 stored elements in Dictionary Of Keys format>>

 In [27]: b.resize((20,10))
 ---------------------------------------------------------------------------
 NotImplementedError                       Traceback (most recent call
 last)

 /home/spaans/projects/<ipython console> in <module>()

 /usr/lib/python2.6/dist-packages/scipy/sparse/dok.pyc in resize(self,
 shape)
     536                 if i >= newM or j >= newN:
     537                     del self[i, j]
 --> 538         self.shape = shape
     539
     540

 /usr/lib/python2.6/dist-packages/scipy/sparse/base.pyc in set_shape(self,
 shape)
      76             except NotImplementedError:
      77                 raise NotImplementedError("Reshaping not
 implemented for %s." %
 ---> 78                                           self.__class__.__name__)
      79         self._shape = shape
      80
 }}}
 Easy patch attached:

--

Comment(by warren.weckesser):

 Added wiki markup for quoting the ipython session.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/997#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list