def test_preprocess(): inputs_1 = [1, 2] seed_1 = [[1, 1], [2, 2]] inputs_2 = [[1], (2)] assert preprocess(inputs_1)[0].value == np.array( [1]), 'preprocess is mishandling seed = []' assert preprocess(inputs_1)[1].value == np.array( [2]), 'preprocess is mishandling seed = []' assert (preprocess(inputs_1)[0].gradients == np.array( [1, 0])).all(), 'preprocess is mishandling seed = []' assert (preprocess(inputs_1)[1].gradients == np.array( [0, 1])).all(), 'preprocess is mishandling seed = []' assert preprocess(inputs_2)[0].value == np.array( [1]), 'preprocess is mishandling seed = []' assert preprocess(inputs_2)[1].value == np.array( [2]), 'preprocess is mishandling seed = []' assert preprocess(inputs_1, seed_1)[0].value == np.array( [1]), 'preprocess is not creating correct gradients' assert preprocess(inputs_1, seed_1)[1].value == np.array( [2]), 'preprocess is not creating correct gradients' assert (preprocess(inputs_1, seed_1)[0].gradients == np.array( [1, 1])).all(), 'preprocess is not creating correct gradients' assert (preprocess(inputs_1, seed_1)[1].gradients == np.array( [2, 2])).all(), 'preprocess is not creating correct gradients'
def test_preprocess_bad_seed3(): with pytest.raises(TypeError): inputs_1 = [1, 2] seed_1 = [[1, 1], [2, '2']] preprocess(inputs_1, seed_1)
def test_preprocess_bad_seed2(): with pytest.raises(ValueError): inputs_1 = [1, 2] seed_1 = [[1], [1, 2]] preprocess(inputs_1, seed_1)
def test_preprocess_string_input(): with pytest.raises(TypeError): inputs_1 = [1, '2'] seed_1 = [[1, 1], [2, 2]] preprocess(inputs_1)