pitrou commented on issue #34987:
URL: https://github.com/apache/arrow/issues/34987#issuecomment-3607254128

   I think `__bool__` should return False if the given scalar is null. It's 
already the case for boolean scalars but it should be the case for other 
scalars as well:
   ```python
   >>> bool(pa.scalar(None, type=pa.bool_()))
   False
   >>> bool(pa.scalar(None, type=pa.int8()))
   True
   >>> bool(pa.scalar(None))
   True
   ```
   
   I also think non-null scalars should have similar boolean evaluation as the 
corresponding Python values:
   ```python
   >>> bool(0)
   False
   >>> bool(pa.scalar(0))
   True
   ```
   
   NumPy does this too:
   ```python
   >>> bool(np.int8(0))
   False
   >>> bool(np.float16(0))
   False
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to