[issue39274] Conversion from fractions.Fraction to bool

2020-01-09 Thread François Durand

New submission from François Durand :

As of now, fractions.Fraction.__bool__ is implemented as: ``return a._numerator 
!= 0``. However, this does not necessary return a bool (which would be 
desired). In particular, when the numerator is a numpy integer, this returns a 
numpy bool instead. Another solution would be to implement 
fractions.Fraction.__bool__ as: ``return bool(numerator)``. What do you think?

This message follows a thread here: https://github.com/numpy/numpy/issues/15277 
.

--
messages: 359673
nosy: francois-durand
priority: normal
severity: normal
status: open
title: Conversion from fractions.Fraction to bool
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue39274>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39274] Conversion from fractions.Fraction to bool

2020-01-09 Thread François Durand

François Durand  added the comment:

As of now, fractions.Fraction.__bool__ is implemented as: ``return a._numerator 
!= 0``. However, this does not necessary return a bool (which would be 
desired). In particular, when the numerator is a numpy integer, this returns a 
numpy bool instead. Another solution would be to implement 
fractions.Fraction.__bool__ as: ``return bool(a._numerator)``. What do you 
think?

This message follows a thread here: https://github.com/numpy/numpy/issues/15277 
.

--

___
Python tracker 
<https://bugs.python.org/issue39274>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com