microsoft / pybryt

Python library for pedagogical auto-assessment
https://microsoft.github.io/pybryt
MIT License
63 stars 19 forks source link

np.allclose causing issues in check_values_equal #142

Closed chrispyles closed 2 years ago

chrispyles commented 2 years ago

I think np.allclose is causing issues related to overflow when comparing very large integers. In a recent project, I was trying to compare Fibonacci numbers and started experiencing issues around fib(94), which throws a TypeError when compared with numpy and thus results in check_values_equal returning False.

>>> np.isclose(19740274219868223167, 19740274219868223167)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<__array_function__ internals>", line 5, in isclose
  File "C:\Users\v-chpyles\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\numpy\core\numeric.py", line 2355, in isclose
    xfin = isfinite(x)
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

image