You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using NumPy >= 1.9, we're seeing a good number of FutureWarning messages arising from the test suite of a large-ish Chaco-using application.
The warnings appear to be mostly (perhaps entirely) caused by traits that accept either an array or None: assigning the array to such a trait that previously had the value None results in one of these warnings. For example:
Python 2.7.3 |Master 2.0.0.dev1463-a1bb912 (64-bit)| (default, Nov 8 2014, 06:08:11)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> from traits.api import *
>>> from chaco.base import ImageTrait
>>> class MyImagePlot(HasTraits):
... image = ImageTrait
...
>>> plot = MyImagePlot()
>>> plot.image = np.zeros((3, 5))
__main__:1: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
The ImageTrait and related traits (PointTrait, CubeTrait, etc.) are one source of these warnings. Another source is use of Any traits where the trait might store either None or an array, for example in PlotAxis._tick_positions.
There's a new ArrayOrNone trait type in Traits master that might help with fixing this issue. (enthought/traits#219)
One fun aspect: trying to detect the warnings with e.g. python -Werror::FutureWarning -m unittest discover ... doesn't entirely work, because many of those warnings are coming from the ctraits comparison machinery, and that machinery swallows exceptions. On the other hand, because the comparison machinery swallows exceptions, these warnings are mostly harmless: in the future, a comparison with None will return a broadcast array result, then an attempt to interpret that array in a boolean context will raise a ValueError, which will be swallowed harmlessly by the machinery (and result in Traits always issuing related events).
The text was updated successfully, but these errors were encountered:
When using NumPy >= 1.9, we're seeing a good number of
FutureWarning
messages arising from the test suite of a large-ish Chaco-using application.The warnings appear to be mostly (perhaps entirely) caused by traits that accept either an array or
None
: assigning the array to such a trait that previously had the valueNone
results in one of these warnings. For example:The
ImageTrait
and related traits (PointTrait
,CubeTrait
, etc.) are one source of these warnings. Another source is use ofAny
traits where the trait might store eitherNone
or an array, for example inPlotAxis._tick_positions
.There's a new
ArrayOrNone
trait type in Traits master that might help with fixing this issue. (enthought/traits#219)One fun aspect: trying to detect the warnings with e.g.
python -Werror::FutureWarning -m unittest discover ...
doesn't entirely work, because many of those warnings are coming from thectraits
comparison machinery, and that machinery swallows exceptions. On the other hand, because the comparison machinery swallows exceptions, these warnings are mostly harmless: in the future, a comparison withNone
will return a broadcast array result, then an attempt to interpret that array in a boolean context will raise aValueError
, which will be swallowed harmlessly by the machinery (and result in Traits always issuing related events).The text was updated successfully, but these errors were encountered: