Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Andrew Nelson
> I think the consistency between bool([]) and bool(array([])) is worth preserving I'm with Eric Firing on this one. Empty sequences are False in Python. ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listin

Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Eric Wieser
Andrew, that can only be useful if you also require that all non-empty arrays are True - else code looking for empty arrays gets false positives on arrays of zeros. But as I mention above, that is not acceptable, as it produces silent traps for new users, or functions not written with numpy in min

Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Pauli Virtanen
Michael Lamparski kirjoitti 19.08.2017 klo 07:04: >> I'd be tentatively in favor of deprecating bool(array([1]) with a > warning asking for `.squeeze()` to be used, since this also hides a > (smaller) class of bugs. > > I can get behind this as well, though I just keep wondering in the back > of m

Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Michael Lamparski
On Sat, Aug 19, 2017 at 9:22 AM, Pauli Virtanen wrote: > While the intention of making it harder to write code with bugs > is good, it should not come at the cost of having everyone fix > their old scripts, which worked correctly previously, but then > suddenly stop working. This is a good point.

Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Eric Firing
On 2017/08/19 7:18 AM, Michael Lamparski wrote: While there's no way to really reach out to the silent majority, I am going to at least make a github issue and summarize the points from this discussion there.  I'm glad to see that the general response so far has been that this seems actionable

Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Michael Lamparski
On Sat, Aug 19, 2017 at 2:00 PM, Eric Firing wrote: > On 2017/08/19 7:18 AM, Michael Lamparski wrote: > >> While there's no way to really reach out to the silent majority, I am >> going to at least make a github issue and summarize the points from this >> discussion there. I'm glad to see that t

Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Eric Firing
On 2017/08/19 10:26 AM, Michael Lamparski wrote: There will be opportunity for others to do the same on Github. Please; I live for discussions about pitfalls in language and library design! Thank you for your thoughtful discussion. Eric ___ NumPy-Di

Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Nathaniel Smith
On Fri, Aug 18, 2017 at 7:34 PM, Eric Firing wrote: > I don't agree. I think the consistency between bool([]) and bool(array([])) > is worth preserving. Nothing you have shown is inconsistent with "Falseness > is emptiness", which is quite fundamental in Python. The inconsistency is > in distin

Re: [Numpy-discussion] Why are empty arrays False?

2017-08-19 Thread Marten van Kerkwijk
Agreed with Eric Wieser here have an empty array test as `False` is less than useless, since a non-empty array either returns something based on its contents or an error. This means that one cannot write statements like `if array:`. Does this leave any use case? It seems to me it just shows there i