[Numpy-discussion] Why am I getting a FutureWarning with this code?

Nathaniel Smith njs at pobox.com
Mon Dec 22 10:37:58 EST 2014


On Mon, Dec 22, 2014 at 7:35 AM, Steve Spicklemire <steve at spvi.com> wrote:
> I’m working on visual python (http://vpython.org) which lists numpy among its dependencies.
>
> I recently updated my numpy installation to 1.9.1 and I’m now encountering this error:
>
> /usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/VPython-6.10-py2.7-macosx-10.10-x86_64.egg/visual_common/materials.py:70: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
>   self.__setattr__(key, value)
>
> Oddly, the code in question looks like this:
>
>
>      62 from . import cvisual
>      63 from numpy import array, reshape, fromstring, ubyte, ndarray, zeros, asarray
>      64 import os.path, math
>      65
>      66 class raw_texture(cvisual.texture):
>      67     def __init__(self, **kwargs):
>      68         cvisual.texture.__init__(self)
>      69         for key, value in kwargs.items():
>      70             self.__setattr__(key, value)
>      71
>      72 class shader_material(cvisual.material):
>      73     def __init__(self, **kwargs):
>      74         cvisual.material.__init__(self)
>      75         for key, value in kwargs.items():
>      76             self.__setattr__(key, value)
>
> I’m not clear on how __setattr__ is being called out as an array comparison.

Is your key an array? dict get/set operations do == tests on keys.

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org



More information about the NumPy-Discussion mailing list