In my python testing script, I want to assert if all elements of numpy array are either very close to 1.0 or equal to 0.0. The array looks like this:
[[0.9999999991268851 1.0000000223517418 0.999999986961484 ...,
0.9999999841675162 1.0000000074505806 0.9999999841675162]
[0.9999999991268851 1.0000000223517418 0.999999986961484 ...,
0.9999999841675162 1.0000000074505806 0.9999999841675162]
[0.9999999991268851 1.0000000223517418 0.999999986961484 ...,
0.9999999841675162 1.0000000074505806 0.9999999841675162]
...,
[1.0000000198488124 1.0000000074505806 1.000000002568413 ...,
0.9999999888241291 0.9999999925494194 0.0]
[1.000000011001248 0.9999999850988388 0.9999999869323801 ...,
1.0000000186264515 0.9999999925494194 0.0]
[1.000000011001248 0.9999999850988388 0.9999999869323801 ...,
1.0000000186264515 0.9999999925494194 0.0]]
I thought of using numpy.allclose or numpy.array_equal, but neither makes sense here. ideally, the function should be able to be used in a testing scenario
assert_almost_equal. See the docs for examples.allclosemake sense? (It broadcasts!)