def test_property(ls1, ls2): """ Write a test that ensures that the sum of `ls1` plus the sum of `ls2` is the same as the sum of each element of `ls1` plus each element of `ls2`. """ # TODO: Implement for Task 0.3. assert_close(operators.addLists(ls1, ls2), operators.addLists(ls2, ls1))
def test_property(ls1, ls2): """ Write a test that ensures that the sum of `ls1` plus the sum of `ls2` is the same as the sum of each element of `ls1` plus each element of `ls2`. """ assert_close(operators.addLists(ls1, ls2), list(map(lambda x, y: x + y, ls1, ls2)))
def test_property(ls1, ls2): """ Write a test that ensures that the sum of `ls1` plus the sum of `ls2` is the same as the sum of each element of `ls1` plus each element of `ls2`. """ a = operators.sum(ls1) + operators.sum(ls2) b = operators.sum(operators.addLists(ls1, ls2)) assert_close(a, b)
def test_property(ls1, ls2): """ Write a test that ensures that the sum of `ls1` plus the sum of `ls2` is the same as the sum of each element of `ls1` plus each element of `ls2`. """ indiv_sum = operators.add(operators.sum(ls1), operators.sum(ls2)) total_sum = operators.sum(operators.addLists(ls1, ls2)) assert_close(indiv_sum, total_sum)
def test_property(ls1, ls2): """ Write a test that ensures that the sum of `ls1` plus the sum of `ls2` is the same as the sum of each element of `ls1` plus each element of `ls2`. """ newList = [] for index in range(0, len(ls1)): newList.append(ls1[index] + ls2[index]) assert_close(operators.addLists(ls1, ls2), newList)
def test_property(ls1, ls2): """ A test that ensures that the sum of `ls1` plus the sum of `ls2` is the same as the sum of each element of `ls1` plus each element of `ls2`. """ ls1 = list(range(1, 4)) ls2 = list(range(1, 4)) assert operators.addLists(ls1, ls2) == [2, 4, 6]
def test_property(ls1, ls2): assert_close(operators.add(math.fsum(ls1), math.fsum(ls2)), math.fsum(operators.addLists(ls1, ls2)))
def test_zip_with(a, b, c, d): assert_close(operators.addLists([a, b], [c, d]), [a + c, b + d])
def test_zip_with(a, b, c, d): x1, x2 = addLists([a, b], [c, d]) y1, y2 = a + c, b + d assert_close(x1, y1) assert_close(x2, y2)