diff options
author | Jim Crist <crist042@umn.edu> | 2016-11-15 15:28:12 -0600 |
---|---|---|
committer | Jim Crist <crist042@umn.edu> | 2017-01-23 12:21:18 -0600 |
commit | 6cbb46e45dde71be76ec6c3f4e8e6fccb4227976 (patch) | |
tree | 2bb3621c4b73895476f2347743d8d25134cb116b /doc | |
parent | 1c8ecc783c43269631b1fdc8f9e06355d231aec6 (diff) | |
download | numpy-6cbb46e45dde71be76ec6c3f4e8e6fccb4227976.tar.gz |
BUG: bool(dtype) is True
Previously `bool(dtype(...))` would fallback to the default
implementation of `__nonzero__`, which checks if `len(object) > 0`.
Since `dtype` objects implement `__len__` as the number of record
fields, `bool` of scalar dtypes like `bool(dtype('i8'))` would evaluate
as `False`. This fixes that by implementing `__nonzero__` to always
return True.
Fixes #6294.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/release/1.13.0-notes.rst | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/release/1.13.0-notes.rst b/doc/release/1.13.0-notes.rst index b54e48ba7..69e2a6b5b 100644 --- a/doc/release/1.13.0-notes.rst +++ b/doc/release/1.13.0-notes.rst @@ -56,6 +56,15 @@ See Changes section for more detail. * ``array == None`` and ``array != None`` do element-wise comparison. * ``np.equal, np.not_equal``, object identity doesn't override comparison result. +dtypes are now always true +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Previously ``bool(dtype)`` would fall back to the default python +implementation, which checked if ``len(dtype) > 0``. Since ``dtype`` objects +implement ``__len__`` as the number of record fields, ``bool`` of scalar dtypes +would evaluate to ``False``, which was unintuitive. Now ``bool(dtype) == True`` +for all dtypes. + C API ~~~~~ |