为什么我没有看到 Numpy 的 DeprecationWarning?

Why am I not seeing Numpy's DeprecationWarning?

我最近在我的一台机器上更新了 Python 的 Numpy 包,显然我已经依赖 a deprecated feature of numpy 一段时间了:

>>> np.__version__
'1.10.4'
>>> a = np.ones(10, dtype=np.uint16)
>>> a /= 0.5
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ufunc 'true_divide' output (typecode 'd') could not be coerced to provided output parameter (typecode 'H') according to the casting rule ''same_kind''

上面的一位评论者link指出:

Probably means you didn't see the deprecation warnings since forever ;)

...这是正确的,我没有。

但是为什么?我是如何设法错过弃用警告的?

the documentation 一致,同样的代码在我以前的 numpy 版本中的工作方式不同:

>>> np.__version__
'1.9.2'
>>> a = np.ones(10, dtype=np.uint16)
>>> a /= 0.5
>>> a
array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2], dtype=uint16)

...但是这不应该触发警告吗?我是否误解了 numpy 如何处理弃用警告? 如何确定我没有遗漏其他弃用警告

我的python环境:

Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32

DeprecationWarnings 是 ignored by default. You need to enable them, either by running Python with the -Wd flag:

python -Wd my_source_file.py

或者通过安装一个新的警告过滤器规范来覆盖忽略 DeprecationWarning 的规范:

import warnings

# Print any warning the first time a given source line issues them,
# overriding built-in filters that ignore some warning types.
warnings.filterwarnings("default")