コード例 #1
0
    def test_inplace(self):
        as_ = [2, 3, 5]
        bs = [2, 3, 6]

        zipped_transform(lambda a, b: (a + b, a - b), as_, bs, inplace=True)

        assert as_ == [4, 6, 11]
        assert bs == [0, 0, -1]
コード例 #2
0
    def test_three_iterables(self):
        as_ = [1, 1, 1]
        bs = [2, 2, 2]
        cs = [3, 3, 3]

        ras, rbs, rcs = zipped_transform(lambda a, b, c: (a + 1, b + 2, c + 3), as_, bs, cs)

        assert ras == [2, 2, 2]
        assert rbs == [4, 4, 4]
        assert rcs == [6, 6, 6]
コード例 #3
0
    def test_two_iterables(self):
        as_ = [2, 3, 5]
        bs = [2, 3, 6]

        ras, rbs = zipped_transform(lambda a, b: (a + b, a - b), as_, bs)

        assert ras == [4, 6, 11]
        assert rbs == [0, 0, -1]
        assert as_ == [2, 3, 5]
        assert bs == [2, 3, 6]
コード例 #4
0
 def test_none_function(self):
     xs = [1, 1, 1]
     ys = [1, 1, 1]
     zipped_transform(lambda a, b: None, xs, ys)