Back to index

python3.2  3.2.2
Public Member Functions
test.test_itertools.TestExamples Class Reference

List of all members.

Public Member Functions

def test_accumlate
def test_chain
def test_chain_from_iterable
def test_combinations
def test_combinations_with_replacement
def test_compress
def test_count
def test_cycle
def test_dropwhile
def test_groupby
def test_filter
def test_filterfalse
def test_map
def test_islice
def test_zip
def test_zip_longest
def test_permutations
def test_product
def test_repeat
def test_stapmap
def test_takewhile

Detailed Description

Definition at line 956 of file test_itertools.py.


Member Function Documentation

Definition at line 958 of file test_itertools.py.

00958 
00959     def test_accumlate(self):
00960         self.assertEqual(list(accumulate([1,2,3,4,5])), [1, 3, 6, 10, 15])

Here is the call graph for this function:

Definition at line 961 of file test_itertools.py.

00961 
00962     def test_chain(self):
00963         self.assertEqual(''.join(chain('ABC', 'DEF')), 'ABCDEF')

Here is the call graph for this function:

Definition at line 964 of file test_itertools.py.

00964 
00965     def test_chain_from_iterable(self):
00966         self.assertEqual(''.join(chain.from_iterable(['ABC', 'DEF'])), 'ABCDEF')

Here is the call graph for this function:

Definition at line 967 of file test_itertools.py.

00967 
00968     def test_combinations(self):
00969         self.assertEqual(list(combinations('ABCD', 2)),
00970                          [('A','B'), ('A','C'), ('A','D'), ('B','C'), ('B','D'), ('C','D')])
00971         self.assertEqual(list(combinations(range(4), 3)),
00972                          [(0,1,2), (0,1,3), (0,2,3), (1,2,3)])

Here is the call graph for this function:

Definition at line 973 of file test_itertools.py.

00973 
00974     def test_combinations_with_replacement(self):
00975         self.assertEqual(list(combinations_with_replacement('ABC', 2)),
00976                          [('A','A'), ('A','B'), ('A','C'), ('B','B'), ('B','C'), ('C','C')])

Here is the call graph for this function:

Definition at line 977 of file test_itertools.py.

00977 
00978     def test_compress(self):
00979         self.assertEqual(list(compress('ABCDEF', [1,0,1,0,1,1])), list('ACEF'))

Here is the call graph for this function:

Definition at line 980 of file test_itertools.py.

00980 
00981     def test_count(self):
00982         self.assertEqual(list(islice(count(10), 5)), [10, 11, 12, 13, 14])

Here is the call graph for this function:

Definition at line 983 of file test_itertools.py.

00983 
00984     def test_cycle(self):
00985         self.assertEqual(list(islice(cycle('ABCD'), 12)), list('ABCDABCDABCD'))

Here is the call graph for this function:

Definition at line 986 of file test_itertools.py.

00986 
00987     def test_dropwhile(self):
00988         self.assertEqual(list(dropwhile(lambda x: x<5, [1,4,6,4,1])), [6,4,1])

Here is the call graph for this function:

Definition at line 995 of file test_itertools.py.

00995 
00996     def test_filter(self):
00997         self.assertEqual(list(filter(lambda x: x%2, range(10))), [1,3,5,7,9])

Here is the call graph for this function:

Definition at line 998 of file test_itertools.py.

00998 
00999     def test_filterfalse(self):
01000         self.assertEqual(list(filterfalse(lambda x: x%2, range(10))), [0,2,4,6,8])

Here is the call graph for this function:

Definition at line 989 of file test_itertools.py.

00989 
00990     def test_groupby(self):
00991         self.assertEqual([k for k, g in groupby('AAAABBBCCDAABBB')],
00992                          list('ABCDAB'))
00993         self.assertEqual([(list(g)) for k, g in groupby('AAAABBBCCD')],
00994                          [list('AAAA'), list('BBB'), list('CC'), list('D')])

Here is the call graph for this function:

Definition at line 1004 of file test_itertools.py.

01004 
01005     def test_islice(self):
01006         self.assertEqual(list(islice('ABCDEFG', 2)), list('AB'))
01007         self.assertEqual(list(islice('ABCDEFG', 2, 4)), list('CD'))
01008         self.assertEqual(list(islice('ABCDEFG', 2, None)), list('CDEFG'))
01009         self.assertEqual(list(islice('ABCDEFG', 0, None, 2)), list('ACEG'))

Here is the call graph for this function:

Definition at line 1001 of file test_itertools.py.

01001 
01002     def test_map(self):
01003         self.assertEqual(list(map(pow, (2,3,10), (5,2,3))), [32, 9, 1000])

Here is the call graph for this function:

Definition at line 1017 of file test_itertools.py.

01017 
01018     def test_permutations(self):
01019         self.assertEqual(list(permutations('ABCD', 2)),
01020                          list(map(tuple, 'AB AC AD BA BC BD CA CB CD DA DB DC'.split())))
01021         self.assertEqual(list(permutations(range(3))),
01022                          [(0,1,2), (0,2,1), (1,0,2), (1,2,0), (2,0,1), (2,1,0)])

Here is the call graph for this function:

Definition at line 1023 of file test_itertools.py.

01023 
01024     def test_product(self):
01025         self.assertEqual(list(product('ABCD', 'xy')),
01026                          list(map(tuple, 'Ax Ay Bx By Cx Cy Dx Dy'.split())))
01027         self.assertEqual(list(product(range(2), repeat=3)),
01028                         [(0,0,0), (0,0,1), (0,1,0), (0,1,1),
01029                          (1,0,0), (1,0,1), (1,1,0), (1,1,1)])

Here is the call graph for this function:

Definition at line 1030 of file test_itertools.py.

01030 
01031     def test_repeat(self):
01032         self.assertEqual(list(repeat(10, 3)), [10, 10, 10])

Here is the call graph for this function:

Definition at line 1033 of file test_itertools.py.

01033 
01034     def test_stapmap(self):
01035         self.assertEqual(list(starmap(pow, [(2,5), (3,2), (10,3)])),
01036                          [32, 9, 1000])

Here is the call graph for this function:

Definition at line 1037 of file test_itertools.py.

01037 
01038     def test_takewhile(self):
01039         self.assertEqual(list(takewhile(lambda x: x<5, [1,4,6,4,1])), [1,4])
01040 

Here is the call graph for this function:

Definition at line 1010 of file test_itertools.py.

01010 
01011     def test_zip(self):
01012         self.assertEqual(list(zip('ABCD', 'xy')), [('A', 'x'), ('B', 'y')])

Here is the call graph for this function:

Definition at line 1013 of file test_itertools.py.

01013 
01014     def test_zip_longest(self):
01015         self.assertEqual(list(zip_longest('ABCD', 'xy', fillvalue='-')),
01016                          [('A', 'x'), ('B', 'y'), ('C', '-'), ('D', '-')])

Here is the call graph for this function:


The documentation for this class was generated from the following file: