import numpy as np
a = np.array([1/3, 2, None])
a
Out[11]: array([0.3333333333333333, 2, None], dtype=object)
b = np.array(a)
b
Out[13]: array([0.3333333333333333, 2, None], dtype=object)
np.testing.assert_almost_equal(a, b)
outputs
Traceback (most recent call last): File "C:\code\EPMD\Kodex\EPD_Prerequisite\python_3.7.6\lib\site-packages\IPython\core\interactiveshell.py", line 3319, in run_code
exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-14-f86262d61654>", line 1, in <module>
np.testing.assert_almost_equal(a, b) File "C:\code\EPMD\Kodex\EPD_Prerequisite\python_3.7.6\lib\site-packages\numpy\testing\_private\utils.py", line 585, in assert_almost_equal
return assert_array_almost_equal(actual, desired, decimal, err_msg) File "C:\code\EPMD\Kodex\EPD_Prerequisite\python_3.7.6\lib\site-packages\numpy\testing\_private\utils.py", line 1047, in assert_array_almost_equal
precision=decimal) File "C:\code\EPMD\Kodex\EPD_Prerequisite\python_3.7.6\lib\site-packages\numpy\testing\_private\utils.py", line 794, in assert_array_compare
val = comparison(x, y) File "C:\code\EPMD\Kodex\EPD_Prerequisite\python_3.7.6\lib\site-packages\numpy\testing\_private\utils.py", line 1038, in compare
z = abs(x - y) TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
How do I avoid for loops here?
Aucun commentaire:
Enregistrer un commentaire