<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Sep 21, 2014, at 5:19 PM, Eric Firing <<a href="mailto:efiring@hawaii.edu">efiring@hawaii.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I think what you are missing is that the standard Python idiom for this<span class="Apple-converted-space"> </span><br>use case is "if self._some_array is None:".  This will continue to work,<span class="Apple-converted-space"> </span><br>regardless of whether the object being checked is an ndarray or any<span class="Apple-converted-space"> </span><br>other Python object.<br></div></blockquote></div><div><br></div><div>That's an alternative, but I think it's a subtle distinction that will be lost on many users. I still think that this is something that can easily trip up many people; it's not clear from looking at the code that this is the behavior; it's "hidden". At the very least, I strongly suggest that the warning point this out, e.g.</div><div><br></div><div>"FutureWarning: comparison to `None` will result in an elementwise object comparison in the future; use  'value is None' as an alternative."</div><div><br></div><div>Assume:</div><div><br></div><div>a = np.array([1, 2, 3, 4])</div><div>b = np.array([None, None, None, None])</div><div><br></div><div>What is the result of "a == None"? Is it "np.array([False, False, False, False])"?</div><div><br></div><div>What about the second case? Is the result of "b == None" -> np.array([True, True, True, True])? If so, then</div><div><br></div><div>if (b == None):</div><div>    ...</div><div><br></div><div>will always evaluate to "True" if b is "None" or *any* Numpy array, and that's clearly unexpected behavior.</div><div><br></div><div><div>On Sep 21, 2014, at 9:30 PM, Benjamin Root <<a href="mailto:ben.root@ou.edu">ben.root@ou.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span style="font-family: GillSans;">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.</span><br style="font-family: GillSans;"></blockquote></div><div><span style="font-family: GillSans;"><br></span></div><div><font face="GillSans">Right. With this change, using "==" with numpy arrays now sometimes means "are these equivalent" and other times "element-wise comparison". The potential for inadvertent bugs is far greater than what convenience this redefinition of a very basic operator might offer. Any scenario where</font></div><div><font face="GillSans"><br></font></div><div><font face="GillSans">(a == b) != (b == a)</font></div><div><font face="GillSans"><br></font></div><div><font face="GillSans">is asking for trouble.</font></div><div><font face="GillSans"><br></font></div><div><font face="GillSans">Cheers,</font></div><div><font face="GillSans">Demitri</font></div><br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); font-family: 'Gill Sans'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">_________________________________________<br>Demitri Muna<br><br>Department of Astronomy<br>An Ohio State University<br><br><a href="http://trillianverse.org">http://trillianverse.org</a><br><span style="text-align: -webkit-auto;">http://scicoder.org</span><br><br><br></div></div></div>
</div>
<br></body></html>