![](https://secure.gravatar.com/avatar/242ff9f31f6fd94d69a65573c45e04ac.jpg?s=120&d=mm&r=g)
On Fri, Dec 2, 2011 at 8:39 AM, Bruce Southey <bsouthey@gmail.com> wrote:
** On 12/01/2011 04:36 PM, Aronne Merrelli wrote:
On Wed, Nov 30, 2011 at 3:01 AM, Per Nielsen <evilper@gmail.com> wrote:
Hi all
I am trying to create a subclass of the sparse matrix class in scipy, to add some extra methods I need.
I have tried to follow the guide on: http://www.scipy.org/Subclasses but without much luck, the view method does not exist for the sparse matrix class. Below is a script I have created
Hi,
It appears that sparse matrices do not inherit from numpy.ndarray:
Surely you did notice that sparse is part of scipy not numpy or even the c++ usage when looking at the code? :-) As far as I know (which is not much) scipy.sparse is essentially self-contained in scipy/sparse directory. So you are better off just working with those files directly.
Well, not exactly - it looks the actual values and indices defining the sparse matrix are stored inside numpy ndarrays in separate object attributes, even though the sparse matrix itself is just a "plain" python object. So it is not quite "self-contained". I'm sure there are good reasons for implementing it that way, but it isn't obvious without knowing those reasons why it couldn't be a direct subclass of ndarray. Aronne