Re: [Numpy-discussion] subclassing matrix

2008-01-12 Thread Basilisk96
iating a new Vector instance is cheaper? Now I can add more unit tests. Cheers, -Basilisk96 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] subclassing matrix

2008-01-12 Thread Basilisk96
print traces, I can see it's called every time an array is modified in any way i.e., reshaped, transposed, etc., and also during operations like u+v, u-v, A*u. But it's not called during the call to numpy.cross. Why? Cheers, -Basilisk96 ___ Nu

Re: [Numpy-discussion] subclassing matrix

2008-01-11 Thread Basilisk96
ses the first condition: isinstance(other,(N.ndarray)) is true; and so the return value becomes a matrix. Bummer. Do I also need to override a few overloaded methods like __mul__, __rmul__, etc. to make this work? Cheers, -Basilisk96 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] subclassing matrix

2008-01-10 Thread Basilisk96
things like: >>> from vector import Vector >>> u = Vector('1 2 3') >>> v = Vector('3 2 1') >>> w = u.cross(v) >>> print w (-4.0, +8.0, -4.0) >>> alpha = u.angle(w) >>> print alph

[Numpy-discussion] subclassing matrix

2008-01-09 Thread Basilisk96
) ret.Format = FMT_VECTOR_DEFAULT return ret def __str__(self): fmt = getattr(self, "Format", FMT_VECTOR_DEFAULT) fmt = ', '.join([fmt]*3) return ''.join(["(", fmt, ")"]) % (self.X, self.Y, self

[Numpy-discussion] problem converting to matrix from Unicode input string

2007-10-18 Thread Basilisk96
-0.5, 0.5], [-0.5, -0.5, 0.5, 0.5]]) Any suggestions on how to improve my code? Is this a Unicode issue, numpy issue, or both? The input string can come from an ASCII file or a GUI text control. In the case of a GUI, the control returns a Unicode string, so for now I am casting it to str(), but it seems like a hack.. BTW, the reason that I am using the astype() method of numpy.matrix is that I get a "ValueError: setting an array element with a sequence" when trying to use return numpy.mat(data, numpy.float64) in the above function. Thank you, -Basilisk96 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion