[Numpy-discussion] patch for structured array comparison bug

Pauli Virtanen pav@iki...
Tue Oct 19 04:24:52 CDT 2010

Tue, 19 Oct 2010 01:09:54 -0600, Charles R Harris wrote:
> Just a quick look. I wasn't able to add comments to the code, maybe a
> pull request would allow that or maybe you need to enable something.

I think you can only add comments on commits, not in Github's compare 

> Also, it is best to work in a branch, see the new
> notes<%20%20%20%20http://docs.scipy.org/doc/numpy/dev/gitwash/
development_workflow.html> on
> the GIT workflow. 

That work is in a separate branch, called `fix_structured_compare` :)

But perhaps we should just recommend people filing pull requests right 

> I'm not sure how broadcasting is supposed to work for
> structured arrays so I will leave that to someone else. ISTR that the
> SUN compiler is persnickety about the initialization of structures,
> only accepts constants or some such. I'll try to track that down or
> maybe someone here who is familiar with that compiler can comment.

I suspect that this comparison code should refuse to compare arrays with 
shape(a) != shape(b), even if `a` and `b` are broadcastable to one 
another. The issue is that the broadcasting semantics work on the array 
level, but here the boolean sub-array is implicitly reduced to a single 

You can also initialize

	dimensions = shape(self) + (-1,)

and let PyArray_Newshape do the size calculation for you.

I guess it's best to not initialize structures directly, if there is some 
suspicion that obscure compilers don't like it.

Pauli Virtanen

More information about the NumPy-Discussion mailing list