[Numpy-discussion] dtype subarray comparison

Charles R Harris charlesr.harris@gmail....
Thu Oct 21 14:22:24 CDT 2010


On Thu, Oct 21, 2010 at 12:18 PM, Pauli Virtanen <pav@iki.fi> wrote:

> Thu, 21 Oct 2010 11:03:52 -0600, Charles R Harris wrote:
> [clip]
> > I think the important thing to settle here is just how dtype comparisons
> > are supposed to work. The current implementation might well be intended
> > and if so we need to know why it is so. I'd like Travis to weigh in
> > here.
>
> To me it seems that sub-arrays were not considered in the initial
> implementation for `==`.
>
> I do not see reasons why one would want to have
>
>        a = dtype([('a', 'i1', (3, 3))])
>        b = dtype([('a', 'i1', 9)])
>        a == b
>
> In any case the current implementation is inconsistent, since currently
>
>        hash(a) != hash(b)
>
> However, I can see why one would want to have CanCastSafely to be true
> between these types.
>
>
Checking the shape seems like the right thing to do, I just want to be sure
that we aren't overlooking something. If we make the change will we need to
fix CanCastSafely?


>    ***
>
> The other issue of allowing broadcasting in sub-arrays --- it does not
> seem very useful to me. Unlike arrays, the dimensions of sub-arrays
> cannot be manipulated easily, and so many use-cases of broadcasting just
> disappear.
>
> Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101021/12654423/attachment.html 


More information about the NumPy-Discussion mailing list