<br><br><div class="gmail_quote">2011/12/27 Jordi Gutiérrez Hermoso <span dir="ltr"><<a href="mailto:jordigh@octave.org">jordigh@octave.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 26 December 2011 14:56, Ralf Gommers <<a href="mailto:ralf.gommers@googlemail.com">ralf.gommers@googlemail.com</a>> wrote:<br>
><br>
><br>
> On Mon, Dec 26, 2011 at 8:50 PM, <<a href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a>> wrote:<br>
</div><div class="im">>> I have a hard time thinking through empty 2-dim arrays, and don't know<br>
>> what rules should apply.<br>
>> However, in my code I might want to catch these cases rather early<br>
>> than late and then having to work my way backwards to find out where<br>
>> the content disappeared.<br>
><br>
><br>
> Same here. Almost always, my empty arrays are either due to bugs or they<br>
> signal that I do need to special-case something. Silent passing through of<br>
> empty arrays to all numpy functions is not what I would want.<br>
<br>
</div>I find it quite annoying to treat the empty set with special<br>
deference. "All of my great-grandkids live in Antarctica" should be<br>
true for me (I'm only 30 years old). If you decide that is not true<br>
for me, it leads to a bunch of other logical annoyances up there<br></blockquote><div><br>Guess you don't mean true/false, because it's neither. But I understand you want an empty array back instead of an error.<br>
<br>Currently the problem is that when you do get that empty array back, you'll then use that for something else and it will probably still crash. Many numpy functions do not check for empty input and will still give exceptions. My impression is that you're better off handling these where you create the empty array, rather than in some random place later on. The alternative is to have consistent rules for empty arrays, and handle them explicitly in all functions. Can be done, but is of course a lot of work and has some overhead.<br>
<br>Finally, I note that your exception only occurs for empty arrays with shape (N, 0). It's not obvious to me if the same rules should apply to shape (0,) and other shapes, or why those shapes are even useful. <br><br>
Ralf<br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
The rule that shouldn't be special cased is what I described: x[idx1,<br>
idx2] should be a valid construction if it's true that all elements of<br>
idx1 and idx2 are integers in the correct range. The sizes of the<br>
empty matrices are also somewhat obvious.<br>
<br>
Special-casing vacuous truth makes me write annoying special cases.<br>
Octave doesn't error out for those special cases, and I think it's a<br>
good thing it doesn't. It's logically consistent.<br>
<br>
- Jordi G. H.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br>