When defining a Fraction based on a numpy array of integers, the numerator is a numpy integer, which causes problems when converting to bool.
Reproducing code example:
import numpy as np
from fractions import Fraction
numerators = np.array([4, 3])
my_fraction = Fraction(numerators[0], 100)
print(repr(my_fraction))
print(bool(my_fraction))
In this example my_fraction is represented as Fraction(4, 100), and one would expect that it converts to True; but it raises an error instead.
Error message:
Traceback (most recent call last):
File "main.py", line 6, in
print(bool(my_fraction))
TypeError: bool should return bool, returned numpy.bool_
Numpy/Python version information:
Numpy 1.17.2
Python 3.7.4