[Numpy-discussion] FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
njs at pobox.com
Wed Apr 8 14:30:11 EDT 2015
On Apr 8, 2015 2:16 PM, "Andreas Hilboll" <lists at hilboll.de> wrote:
> Hi all,
> I'm commonly using function signatures like
> def myfunc(a, b, c=None):
> if c is None:
> # do something ...
> where c is an optional array argument. For some time now, I'm getting a
> FutureWarning: comparison to `None` will result in an elementwise
> object comparison in the future
> from the "c is None" comparison. I'm wondering what would be the best
> way to do this check in a future-proof way?
As far as I know, you should be getting the warning when you write
c == None
and the fix should be to write
c is None
instead. (And this is definitely an important fix -- it's basically a bug
in numpy that the == form ever worked.) Are you certain that you're getting
warnings from 'c is None'?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion