Testing numpy array
I tried to test below. But 4th assertion could not be passed.
import numpy as np def test__sigmoid(): assert round(sigmoid(-5), 7) == (0.0066929) assert round(sigmoid(0), 5) == (0.5000000) assert round(sigmoid(5), 5) == (0.99331) assert (sigmoid([4, 5, 6])).round(5) == np.array([0.98201, 0.99331, 0.99753])
The reason of its failure assertion line returns array with boolean like below.
sigmoid([4, 5, 6]).round(5) == np.array([0.98201, 0.99331, 0.99753]) # array([ True, True, True])
Then I found a testing module in numpy.
Then I revised test code like below and it worked well.
def test__sigmoid(): assert round(sigmoid(-5), 7) == (0.0066929) assert round(sigmoid(0), 5) == (0.5000000) assert round(sigmoid(5), 5) == (0.99331) np.testing.assert_almost_equal(sigmoid([4, 5, 6]).round(5), np.array([0.98201, 0.99331, 0.99753]))
But if you unnoticed about decimal. this test will be failed.