Beispiel #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`.
    """
    assert_close(operators.add(operators.sum(ls1), operators.sum(ls2)),
                 operators.sum(operators.zipWith(operators.add)(ls1, ls2)))
Beispiel #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`.
    """
    # TODO: Implement for Task 0.3.
    return assert_close(operators.sum(ls1) + operators.sum(ls2), operators.sum(operators.zipWith(operators.add)(ls1, ls2)))
Beispiel #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)
Beispiel #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)
Beispiel #5
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.

    sum = operators.add(operators.sum(ls1), operators.sum(ls2))
    elem_sum = operators.sum(operators.addLists(ls1, ls2))

    assert_close(sum, elem_sum)
Beispiel #6
0
def test_sum(ls):
    assert_close(operators.sum(ls), sum(ls))
def test_sum(ls):
    assert_close(op.sum(ls), sum(ls))
def test_property(ls1, ls2):
    assert_close(op.add(op.sum(ls1), op.sum(ls2)),
                 op.sum([op.add(x, y) for x, y in zip(ls1, ls2)]))
 def mean_full_red(a):
     return operators.sum(a) / float(len(a))
 def sum_red(a):
     return operators.sum(a)