<commit_before>'''

This module should handle testing of global constraints that recieve a large
amound of use. Specifically the AllDiff

'''
from Numberjack import *
import unittest


class GlobalsATest(unittest.TestCase):
    solver = None

    '''
    AllDiff Tests
    '''
    def testAllDiffBinarySucc(self):
        m = Model()
        var1, var2 = [Variable([0]), Variable([1])]
        m.add(AllDiff([var1, var2]))
        s = GlobalsATest.solver(m)
        self.assertTrue(s.solve())
        self.assertTrue([var1.get_value(), var2.get_value()].count(1) == 1)

    def testAllDiffBinaryFail(self):
        m = Model()
        var1, var2 = [Variable([0]), Variable([0])]
        m.add(AllDiff([var1, var2]))
        s = GlobalsATest.solver(m)
        self.assertFalse(s.solve())

    def testAllDiffBooleanSucc(self):
        m = Model()
        var1, var2 = [Variable(), Variable()]
        m.add(AllDiff([var1, var2]))
        s = GlobalsATest.solver(m)
        self.assertTrue(s.solve())
        self.assertTrue([var1.get_value(), var2.get_value()].count(1) == 1)

    #def testAllDiffSingleSucc(self):
    #    m = Model()
    #    var = Variable(0,10)
    #    m.add(AllDiff([var]))
    #    s = GlobalsATest.solver(m)
    #    self.assertTrue(s.solve())
    #    self.assertTrue(var.get_value() == 0)
    #
    #def testAllDiffSingleBooleanSucc(self):
    #    m = Model()
    #    var = Variable()
    #    m.add(AllDiff([var]))
    #    s = GlobalsATest.solver(m)
    #    self.assertTrue(s.solve())
    #    self.assertTrue(var.get_value() == 0)

    def testAllDiffMulipleBooleanFail(self):
        m = Model()
        varray = [Variable() for i in range(3)]
        m.add(AllDiff(varray))
        s = GlobalsATest.solver(m)
        self.assertFalse(s.solve())

    def testAllDiffLargeVarraySucc(self):
        m = Model()
        varray = [Variable(0, 301) for i in range(300)]
        m.add(AllDiff(varray))
        s = GlobalsATest.solver(m)
        self.assertTrue(s.solve())
        self.assertTrue(set([i.get_value() for i in varray]) == set(range(0, 300)))

    def testAllDiffLargeVarrayFail(self):
        m = Model()
        varray = [Variable(0, 301) for i in range(400)]
        m.add(AllDiff(varray))
        s = GlobalsATest.solver(m)
        self.assertFalse(s.solve())

    '''
    Sum Tests
    '''
    def testSumSingleBooleanSucc(self):
        m = Model()
        var = Variable()<commit_msg>bugfix for large AllDiff test.<commit_after>'''

This module should handle testing of global constraints that recieve a large
amound of use. Specifically the AllDiff

'''
from Numberjack import *
import unittest


class GlobalsATest(unittest.TestCase):
    solver = None

    '''
    AllDiff Tests
    '''
    def testAllDiffBinarySucc(self):
        m = Model()
        var1, var2 = [Variable([0]), Variable([1])]
        m.add(AllDiff([var1, var2]))
        s = GlobalsATest.solver(m)
        self.assertTrue(s.solve())
        self.assertTrue([var1.get_value(), var2.get_value()].count(1) == 1)

    def testAllDiffBinaryFail(self):
        m = Model()
        var1, var2 = [Variable([0]), Variable([0])]
        m.add(AllDiff([var1, var2]))
        s = GlobalsATest.solver(m)
        self.assertFalse(s.solve())

    def testAllDiffBooleanSucc(self):
        m = Model()
        var1, var2 = [Variable(), Variable()]
        m.add(AllDiff([var1, var2]))
        s = GlobalsATest.solver(m)
        self.assertTrue(s.solve())
        self.assertTrue([var1.get_value(), var2.get_value()].count(1) == 1)

    #def testAllDiffSingleSucc(self):
    #    m = Model()
    #    var = Variable(0,10)
    #    m.add(AllDiff([var]))
    #    s = GlobalsATest.solver(m)
    #    self.assertTrue(s.solve())
    #    self.assertTrue(var.get_value() == 0)
    #
    #def testAllDiffSingleBooleanSucc(self):
    #    m = Model()
    #    var = Variable()
    #    m.add(AllDiff([var]))
    #    s = GlobalsATest.solver(m)
    #    self.assertTrue(s.solve())
    #    self.assertTrue(var.get_value() == 0)

    def testAllDiffMulipleBooleanFail(self):
        m = Model()
        varray = [Variable() for i in range(3)]
        m.add(AllDiff(varray))
        s = GlobalsATest.solver(m)
        self.assertFalse(s.solve())

    def testAllDiffLargeVarraySucc(self):
        m = Model()
        N = 300
        varray = [Variable(1, N) for i in range(N)]
        m.add(AllDiff(varray))
        s = GlobalsATest.solver(m)
        self.assertTrue(s.solve())
        self.assertTrue(set([i.get_value() for i in varray]) == set(range(1, N + 1)))

    def testAllDiffLargeVarrayFail(self):
        m = Model()
        varray = [Variable(0, 301) for i in range(400)]
        m.add(AllDiff(varray))
        s = GlobalsATest.solver(m)
        self.assertFalse(s.solve())

    '''
    Sum Tests
    '''
    def testSumSingleBooleanSucc(self):
        m = Model()
        var = Variable()
{'fraction_non_alphanumeric': 0.14980584508481504, 'fraction_numerical': 0.01859799713876967, 'mean_word_length': 2.448907681465821, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6399489', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1709, 'n_words': 322}