On 3/23/07, Anne Archibald <[EMAIL PROTECTED]> wrote:

On 23/03/07, Charles R Harris <[EMAIL PROTECTED]> wrote:
> Anyone,
>
> What is the easiest way to detect in python/C if an object is a subclass
of
> ndarray?

Um, how about isinstance or issubclass? (if you want strictness you
can look at whether x.__class__ is zeros(1).__class__)


What I am trying to do is figure out the easiest way to fix up matrix
multiplies so they work properly. For instance, the following gives the
wrong result:

In [15]: I = matrix(eye(2))

In [16]: I*ones(2)
Out[16]: matrix([[ 1.,  1.]])

where the output should be a column vector. In order to do that, I need to
reshape the rh multiplicand before __mul__ calls the dot function. There is
also this problem

In [17]: I*[[1],[1]]
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most recent
call last)

/home/charris/<ipython console>

TypeError: can't multiply sequence by non-int

A similar multiplication on the left works just fine.

Chuck
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to