That being said, I do wonder about related situations where the lhs of the equal sign might be an array, or it might be a None and you are comparing against another numpy array. In those situations, you aren't trying to compare against None, you are just checking if two objects are equivalent.

When is this change planned?On Sun, Sep 21, 2014 at 5:19 PM, Eric Firing <efiring@hawaii.edu> wrote:

On 2014/09/21, 11:10 AM, Demitri Muna wrote:

> Hi,

>

> I just encountered the following in my code:

>

> FutureWarning: comparison to `None` will result in an elementwise object

> comparison in the future.

>

> I'm very concerned about this. This is a very common programming pattern

> (lazy loading):

>

> class A(object):

> def __init__(self):

> self._some_array = None

>

> @property

> def some_array(self):

> if self._some_array == None:

> # perform some expensive setup of array

> return self._some_array

>

> It seems to me that the new behavior will break this pattern. I think

> that redefining the "==" operator is a little too aggressive here. It

> strikes me as very nonstandard and not at all obvious to someone reading

> the code that the comparison is a very special case for numpy objects.

> Unless there's some aspect I'm missing here, I think an element-wise

> comparator should be more explicit.

I think what you are missing is that the standard Python idiom for this

use case is "if self._some_array is None:". This will continue to work,

regardless of whether the object being checked is an ndarray or any

other Python object.

Eric

>

> Cheers,

> Demitri

>

> _________________________________________

> Demitri Muna

>

> Department of Astronomy

> Le Ohio State University

>

> http://trillianverse.org

> http://scicoder.org

>

>

>

>

>

> _______________________________________________

> NumPy-Discussion mailing list

> NumPy-Discussion@scipy.org

> http://mail.scipy.org/mailman/listinfo/numpy-discussion

>

_______________________________________________

NumPy-Discussion mailing list

NumPy-Discussion@scipy.org

http://mail.scipy.org/mailman/listinfo/numpy-discussion