def test_check_seed(): adobj = AD(lambda x: 2 * x + x**3) adobj.n = 5 adobj.set_seed([2, 1]) with pytest.raises(ValueError): adobj._check_seed(adobj.n)
def test_set_seed_wrong_dim(): adobj = AD(lambda x: x + 5) adobj.set_seed([2, 1]) with pytest.raises(ValueError): adobj._forward(3)
def test_set_seed_nonarray(): adobj = AD(lambda x: x * x) with pytest.raises(ValueError): adobj.set_seed('what')
def test_set_seed(): adobj = AD(lambda x: x + 5) adobj.set_seed(5) adobj.set_seed(0) assert adobj.seed == 0