[Numpy-svn] [numpy/numpy] 6cbb46: BUG: bool(dtype) is True

GitHub noreply at github.com
Mon Jan 23 14:25:21 EST 2017


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: 6cbb46e45dde71be76ec6c3f4e8e6fccb4227976
      https://github.com/numpy/numpy/commit/6cbb46e45dde71be76ec6c3f4e8e6fccb4227976
  Author: Jim Crist <crist042 at umn.edu>
  Date:   2017-01-23 (Mon, 23 Jan 2017)

  Changed paths:
    M doc/release/1.13.0-notes.rst
    M numpy/core/src/multiarray/descriptor.c
    M numpy/core/tests/test_dtype.py

  Log Message:
  -----------
  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.


  Commit: 81d176e7ead43f819cbe8654c67805fa07c609bd
      https://github.com/numpy/numpy/commit/81d176e7ead43f819cbe8654c67805fa07c609bd
  Author: Charles Harris <charlesr.harris at gmail.com>
  Date:   2017-01-23 (Mon, 23 Jan 2017)

  Changed paths:
    M doc/release/1.13.0-notes.rst
    M numpy/core/src/multiarray/descriptor.c
    M numpy/core/tests/test_dtype.py

  Log Message:
  -----------
  Merge pull request #8279 from jcrist/dtypes-are-true

BUG: bool(dtype) is True


Compare: https://github.com/numpy/numpy/compare/1c8ecc783c43...81d176e7ead4


More information about the Numpy-svn mailing list