In projects, we commonly need a trait that stores an optional array. Up until now, a good way of spelling that has been Either(None, Array(dtype=..., shape=...)).
However, with NumPy 1.9, the construction above gives the following warning:
>>> import numpy as np
>>> from traits.api import *
>>> class A(HasTraits):
... foo = Either(None, Array)
...
>>> a = A()
>>> a.foo = np.arange(3)
__main__:1: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
We've worked around this in Mayavi and other projects by adding a custom ArrayOrNone trait type: see enthought/mayavi#146. It would be useful to have that ArrayOrNone trait directly available in Traits.
In projects, we commonly need a trait that stores an optional array. Up until now, a good way of spelling that has been
Either(None, Array(dtype=..., shape=...)).However, with NumPy 1.9, the construction above gives the following warning:
We've worked around this in Mayavi and other projects by adding a custom
ArrayOrNonetrait type: see enthought/mayavi#146. It would be useful to have thatArrayOrNonetrait directly available in Traits.ArrayOrNoneis exported intraits.api.