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

2017-08-18 Thread Michael Lamparski
> More importantly though, allowing your proposed semantics would cause a lot of silent bugs in code like `if arr == value`, which would be silently true of array inputs. We already diverge from python on what == means, so I see no reason to match the normal semantics of bool. Eric hits the nail r

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

2017-08-18 Thread Eric Wieser
Defining falseness​ as emptiness in numpy is problematic, as then bool(array(0)) and bool(0) would have different results. 0d arrays are supposed to behave as much like their scalar values as possible, so this is not acceptable. More importantly though, allowing your proposed semantics would cause

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

2017-08-18 Thread Eric Firing
On 2017/08/18 11:45 AM, Michael Lamparski wrote: Greetings, all.  I am troubled. The TL;DR is that `bool(array([])) is False` is misleading, dangerous, and unnecessary. Let's begin with some examples: >>> bool(np.array(1)) True >>> bool(np.array(0)) False >>> bool(np.array([0, 1])) ValueEr

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

2017-08-18 Thread Nathaniel Smith
On Fri, Aug 18, 2017 at 2:45 PM, Michael Lamparski wrote: > Greetings, all. I am troubled. > > The TL;DR is that `bool(array([])) is False` is misleading, dangerous, and > unnecessary. Let's begin with some examples: > bool(np.array(1)) > True bool(np.array(0)) > False bool(np.arra

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

2017-08-18 Thread Eric Wieser
I'm also in favor of fixing this, although we might need a deprecation cycle with a warning advising to use arr.size in future to detect emptiness - just in case anyone is using it. On Sat, Aug 19, 2017, 06:01 Stephan Hoyer wrote: > I agree, this behavior seems actively harmful. Let's fix it. >

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

2017-08-18 Thread Michael Lamparski
> But I would have expected these to raise ValueErrors recommending any() and all(): > >>> bool(np.array([1])) > True > >>> bool(np.array([0])) > False While I can't confess to know the *actual* reason why single-element arrays evaluate the way they do, this is how I understand it: One thing that

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

2017-08-18 Thread Paul Hobson
Maybe I'm missing something. This seems fine to me: >>> bool(np.array([])) False But I would have expected these to raise ValueErrors recommending any() and all(): >>> bool(np.array([1])) True >>> bool(np.array([0])) False On Fri, Aug 18, 2017 at 3:00 PM, Stephan Hoyer wrote: > I agree, this b

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

2017-08-18 Thread Stephan Hoyer
I agree, this behavior seems actively harmful. Let's fix it. On Fri, Aug 18, 2017 at 2:45 PM, Michael Lamparski wrote: > Greetings, all. I am troubled. > > The TL;DR is that `bool(array([])) is False` is misleading, dangerous, and > unnecessary. Let's begin with some examples: > > >>> bool(np.a

[Numpy-discussion] Why are empty arrays False?

2017-08-18 Thread Michael Lamparski
Greetings, all. I am troubled. The TL;DR is that `bool(array([])) is False` is misleading, dangerous, and unnecessary. Let's begin with some examples: >>> bool(np.array(1)) True >>> bool(np.array(0)) False >>> bool(np.array([0, 1])) ValueError: The truth value of an array with more than one elem

[Numpy-discussion] NetworkX 2.0b1 released

2017-08-18 Thread Jarrod Millman
Hi All, I am happy to announce the **beta** release of NetworkX 2.0! NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks. This release supports Python 2.7 and 3.4-3.6 and contains many new features. This release is