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
The text was updated successfully, but these errors were encountered:
david-cortes
changed the title
'char' Array entries always evaluate to 'True'
C 'char' Array entries always evaluate to 'True'
Jul 13, 2019
david-cortes
changed the title
C 'char' Array entries always evaluate to 'True'
Array entries of type C 'char' always evaluate to 'True'
Jul 13, 2019
david-cortes
changed the title
Array entries of type C 'char' always evaluate to 'True'
Value of zero in array with dtype C char evaluates to 'True'
Jul 19, 2019
Note that arr_char[0] is a numpy.bytes_ object with length 1:
In [36]: arr_char
Out[36]: array([b'0', b'0', b'1'], dtype='|S1')
In [37]: arr_char[0]
Out[37]: b'0'
The "truthiness" of a Python bytes object or a NumPy bytes_ object depends only on its length, not on the characters stored in the object; bytes objects with length 0 are False:
In [51]: bool(b'')
Out[51]: False
In [52]: bool(b'0')
Out[52]: True
In [53]: bool(np.bytes_(b''))
Out[53]: False
In [54]: bool(np.bytes_(b'0'))
Out[54]: True
Agreed with Warren, just an addendum that while this one makes sense, there are a lot of corner cases that we badly need to align with Python strings: gh-9875
Uh oh!
There was an error while loading. Please reload this page.
Steps to reproduce:
False
.char
.Expected behavior: values corresponding to zero should be taken as
False
.Actual behavior: all values are taken as
True
.Example
The text was updated successfully, but these errors were encountered: