<commit_before>import unittest
from test import test_support
from itertools import *
from weakref import proxy
import sys
import operator
import random
maxsize = test_support.MAX_Py_ssize_t
minsize = -maxsize-1

def onearg(x):
    'Test function of one argument'
    return 2*x

def errfunc(*args):
    'Test function that raises an error'
    raise ValueError

def gen3():
    'Non-restartable source sequence'
    for i in (0, 1, 2):
        yield i

def isEven(x):
    'Test predicate'
    return x%2==0

def isOdd(x):
    'Test predicate'
    return x%2==1

class StopNow:
    'Class emulating an empty iterable.'
    def __iter__(self):
        return self
    def next(self):
        raise StopIteration

def take(n, seq):
    'Convenience function for partially consuming a long of infinite iterable'
    return list(islice(seq, n))

def fact(n):
    'Factorial'
    return reduce(operator.mul, range(1, n+1), 1)

class TestBasicOps(unittest.TestCase):
    def test_chain(self):
        self.assertEqual(list(chain('abc', 'def')), list('abcdef'))
        self.assertEqual(list(chain('abc')), list('abc'))
        self.assertEqual(list(chain('')), [])
        self.assertEqual(take(4, chain('abc', 'def')), list('abcd'))
        self.assertRaises(TypeError, chain, 2, 3)

    def test_combinations(self):
        self.assertRaises(TypeError, combinations, 'abc')   # missing r argument
        self.assertRaises(TypeError, combinations, 'abc', 2, 1) # too many arguments
        self.assertRaises(ValueError, combinations, 'abc', -2)  # r is negative
        self.assertRaises(ValueError, combinations, 'abc', 32)  # r is too big
        self.assertEqual(list(combinations(range(4), 3)),
                                           [(0,1,2), (0,1,3), (0,2,3), (1,2,3)])
        for n in range(6):
            values = [5*x-12 for x in range(n)]
            for r in range(n+1):
                result = list(combinations(values, r))
                self.assertEqual(len(result), fact(n) / fact(r) / fact(n-r)) # right number of combs
                self.assertEqual(len(result), len(set(result)))         # no repeats
                self.assertEqual(result, sorted(result))                # lexicographic order
                for c in result:
                    self.assertEqual(len(c), r)                         # r-length combinations
                    self.assertEqual(len(set(c)), r)                    # no duplicate elements
                    self.assertEqual(list(c), sorted(c))                # keep original ordering
                    self.assert_(all(e in values for e in c))           # elements taken from input iterable

    def test_count(self):
        self.assertEqual(zip('abc',count()), [('a', 0), ('b', 1), ('c', 2)])
        self.assertEqual(zip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)])
        self.assertEqual(take(2, zip('abc',count(3))), [('a', 3), ('b', 4)])
        self.assertEqual(take(2, zip('abc',count(-1))), [('a', -1), ('b', 0)])
        self.assertEqual(take(2, zip('abc',count(-3))), [('a', -3), ('b', -2)])
        self.assertRaises(TypeError, count, 2, 3)<commit_msg>Larger test range<commit_after>import unittest
from test import test_support
from itertools import *
from weakref import proxy
import sys
import operator
import random
maxsize = test_support.MAX_Py_ssize_t
minsize = -maxsize-1

def onearg(x):
    'Test function of one argument'
    return 2*x

def errfunc(*args):
    'Test function that raises an error'
    raise ValueError

def gen3():
    'Non-restartable source sequence'
    for i in (0, 1, 2):
        yield i

def isEven(x):
    'Test predicate'
    return x%2==0

def isOdd(x):
    'Test predicate'
    return x%2==1

class StopNow:
    'Class emulating an empty iterable.'
    def __iter__(self):
        return self
    def next(self):
        raise StopIteration

def take(n, seq):
    'Convenience function for partially consuming a long of infinite iterable'
    return list(islice(seq, n))

def fact(n):
    'Factorial'
    return reduce(operator.mul, range(1, n+1), 1)

class TestBasicOps(unittest.TestCase):
    def test_chain(self):
        self.assertEqual(list(chain('abc', 'def')), list('abcdef'))
        self.assertEqual(list(chain('abc')), list('abc'))
        self.assertEqual(list(chain('')), [])
        self.assertEqual(take(4, chain('abc', 'def')), list('abcd'))
        self.assertRaises(TypeError, chain, 2, 3)

    def test_combinations(self):
        self.assertRaises(TypeError, combinations, 'abc')   # missing r argument
        self.assertRaises(TypeError, combinations, 'abc', 2, 1) # too many arguments
        self.assertRaises(ValueError, combinations, 'abc', -2)  # r is negative
        self.assertRaises(ValueError, combinations, 'abc', 32)  # r is too big
        self.assertEqual(list(combinations(range(4), 3)),
                                           [(0,1,2), (0,1,3), (0,2,3), (1,2,3)])
        for n in range(8):
            values = [5*x-12 for x in range(n)]
            for r in range(n+1):
                result = list(combinations(values, r))
                self.assertEqual(len(result), fact(n) / fact(r) / fact(n-r)) # right number of combs
                self.assertEqual(len(result), len(set(result)))         # no repeats
                self.assertEqual(result, sorted(result))                # lexicographic order
                for c in result:
                    self.assertEqual(len(c), r)                         # r-length combinations
                    self.assertEqual(len(set(c)), r)                    # no duplicate elements
                    self.assertEqual(list(c), sorted(c))                # keep original ordering
                    self.assert_(all(e in values for e in c))           # elements taken from input iterable

    def test_count(self):
        self.assertEqual(zip('abc',count()), [('a', 0), ('b', 1), ('c', 2)])
        self.assertEqual(zip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)])
        self.assertEqual(take(2, zip('abc',count(3))), [('a', 3), ('b', 4)])
        self.assertEqual(take(2, zip('abc',count(-1))), [('a', -1), ('b', 0)])
        self.assertEqual(take(2, zip('abc',count(-3))), [('a', -3), ('b', -2)])
        self.assertRaises(TypeError, count, 2, 3)
{'fraction_non_alphanumeric': 0.15047923322683707, 'fraction_numerical': 0.019488817891373803, 'mean_word_length': 2.4958123953098825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4861299', 'n_tokens_mistral': 2001, 'n_tokens_neox': 1910, 'n_words': 525}