def test_sqrt1(): x = AD(-1, 1, 'x') with pytest.raises(ValueError): y = x.sqrt()
def test_sqrt2(): x = AD(10, 3, 'x') y = x.sqrt() assert y.val == np.sqrt(10) assert y.der == 0.5 * 3 * 10**(-0.5)
def test_sqrt(): x = AD(0, 1, 'x') with pytest.raises(ZeroDivisionError): y = x.sqrt()