コード例 #1
0
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))
コード例 #2
0
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)))
コード例 #3
0
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)
コード例 #4
0
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)
コード例 #5
0
ファイル: test_operators.py プロジェクト: arp95/Module-0
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)
コード例 #6
0
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]
コード例 #7
0
ファイル: test_operators.py プロジェクト: bamyers2/Module-0
def test_property(ls1, ls2):
    assert_close(operators.add(math.fsum(ls1), math.fsum(ls2)),
                 math.fsum(operators.addLists(ls1, ls2)))
コード例 #8
0
ファイル: test_operators.py プロジェクト: bamyers2/Module-0
def test_zip_with(a, b, c, d):
    assert_close(operators.addLists([a, b], [c, d]), [a + c, b + d])
コード例 #9
0
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)