Hi,
I am trying to create an ndarry subclass for vector calculations. The
result is not what I intent:

import numpy as np

class Vector(np.ndarray):
        def __abs__(self):
                return(np.sqrt(sum(self**2)))

V = Vector([1,2,3])

print np.sqrt(sum(self**2))
print abs(V)

I do not understand the docs at http://www.scipy.org/Subclasses but it
is late now.


Martijn


P.S. I know this is not strictly matplotlib related, but since MP uses
numpy so heavily, I felt free to ask.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to