Пример #1
0
def test_filter():
    df = sn.filter(lambda x: x if x % 2 else None, sn.defer([1, 2, 3, 4, 5]))

    for i, x in sn.enumerate(df, start=1):
        assert 2 * i - 1 == x

    # Alternative testing
    assert [1, 3, 5] == list(sn.evaluate(df))
Пример #2
0
    def test_filter(self):
        df = sn.filter(lambda x: x if x % 2 else None,
                       make_deferrable([1, 2, 3, 4, 5]))

        for i, x in sn.enumerate(df, start=1):
            self.assertEqual(2 * i - 1, x)

        # Alternative testing
        self.assertEqual([1, 3, 5], list(evaluate(df)))