[Numpy-discussion] dtype subarray comparison

Pauli Virtanen pav@iki...
Thu Oct 21 13:18:14 CDT 2010


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.

    ***

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.

	Pauli



More information about the NumPy-Discussion mailing list