コード例 #1
0
 def test_abs_multiplication(self):
     a = 1
     b = -2
     c = 3
     num = Numbers(a, b, c)
     self.assertEquals(math.fabs(a * b * c), num.abs_multiplication(),
                       'Wrong abs_multiplication')
コード例 #2
0
def test_is_even():
    instance = Numbers()
    assert instance.is_even(5) == False, "should be False"
    assert instance.is_even(4) == True, "should be True"
    assert instance.is_even(0) == True, "should be True"
    assert instance.is_even(-2) == True, "should be True"
    assert instance.is_even(-5) == False, "should be False"
コード例 #3
0
 def test_multiplication(self):
     a = 1
     b = 2
     c = 3
     num = Numbers(a, b, c)
     self.assertEquals(a * b * c, num.multiplication(),
                       'Wrong multiplication')
コード例 #4
0
def main():
    minRange, maxRange, nums = readParams()
    nm = Numbers()
    numbers = nm.getNumbers(minRange, maxRange, nums)
    print ("Random generated %d numbers between %d and %d are: " %
           (nums, minRange, maxRange))
    print (numbers)
    sortedNums = bubbleSort(numbers)
    print ("Sorted numbers are: ")
    print (sortedNums)
コード例 #5
0
ファイル: merge_sort.py プロジェクト: noah8713/ps-algods-py
def main():
    minRange, maxRange, nums = readParams()
    nm = Numbers()
    numbers = nm.getNumbers(minRange, maxRange, nums)
    print("Random generated %d numbers between %d and %d are: " %
          (nums, minRange, maxRange))
    print(numbers)
    sortedNums = merge_sort(numbers)
    print("Sorted numbers are: ")
    print(sortedNums)
コード例 #6
0
ファイル: TestWordValidation.py プロジェクト: AkireL/TestH3ru
 def test_isVerbSubjunctive(self):  
     self.h = Verb(Language() )     
     
     self.assertEqual(self.h.isVerbSubjunctive("xoxo"), False)        
     self.assertEqual(self.h.isVerbSubjunctive("xoxox"), False)        
     self.assertEqual(self.h.isVerbSubjunctive("oxooxo"), True)        
     self.assertEqual(self.h.isVerbSubjunctive("xxoxoxs"), False)  
     self.assertEqual(self.h.isVerbSubjunctive("oxoxoxo"), True)   
コード例 #7
0
 def test_init(self):
     num = Numbers(1, 2, 3)
     self.assertEqual(1, num.a,
                      "A have wrong value. Actual result: " + str(num.a))
     self.assertEqual(2, num.b,
                      "B have wrong value. Actual result: " + str(num.b))
     self.assertEqual(3, num.c,
                      "C have wrong value. Actual result: " + str(num.c))
コード例 #8
0
class Heuristic:
    def __init__(self):
        self.lObj = Language()
        self.vObj = Verb(self.lObj)
        self.pObj = Preposition(self.lObj)
        self.nObj = Numbers(self.vObj, self.pObj)
        
    def classify(self, word):
        try:
            self.lObj.isInLanguage(word)
            
            if self.nObj.isNumber(word):
                value = self.nObj.getValue(word)
                return {'word':word, 'type': Constant.HERUGLON_NUMBER_PRETTY, 'number': value } if self.nObj.isPretty(value) else {'word':word, 'type': Constant.HERUGLON_NUMBER, 'number': value}
            if self.vObj.isVerbSubjunctive(word):
                return {'word':word, 'type':Constant.HERUGLON_VERB_SUBJUNCTIVE}
            if self.vObj.isVerb(word):
                return {'word':word, 'type':Constant.HERUGLON_VERB}
            if self.pObj.isPreposition(word):
                return {'word':word, 'type':Constant.HERUGLON_PREPOSITION}
            
            return {'word':word, 'type':Constant.HERUGLON_UNKNOWN, 'error': "Unknown word" }
        except:
            return {'word':word, 'type':Constant.HERUGLON_UNKNOWN, 'error': sys.exc_info()[1] }
コード例 #9
0
def enter():
    global background, character, path, number, following_marbles, is_crush, map
    background = Background()
    if choose_state.selected_character == 'sad':
        character = Run_sadness100()
    elif choose_state.selected_character == 'happy':
        character = Run_happiness100()
    path = Path()
    number = Numbers()
    map = Map()
    following_marbles = FollowingMarbles()
    is_crush = False
    game_world.add_object(background, 0)
    game_world.add_object(path, 1)
    game_world.add_object(map, 1)
    game_world.add_object(number, 1)
    game_world.add_object(character, 1)
    game_world.add_object(following_marbles, 1)
コード例 #10
0
from Numbers import Numbers
from Cars import Car

liczby1 = Numbers([])
liczby1.addNumberToList(3)
liczby1.addNumberToList(5)
liczby1.addNumberToList(7)
liczby1.addNumberToList(1)
liczby1.addNumberToList(2)

liczby2 = Numbers([])
liczby2.addNumberToList(10)
liczby2.addNumberToList(20)
liczby2.addNumberToList(30)

print(liczby1.numbers)
print(liczby1.sumNumbers())
print(liczby2.numbers)
print(liczby2.sumNumbers())

print(Numbers.numbersSum)

# print(liczby.productNumbers())
#
# print(Numbers.subtractNumbers(3,5))
# Numbers.printInformationAboutMe()

# samochod1 = Car(Car,"inna")
# samochod2 = Car(Car,"inna")
# samochod3 = Car(Car,"inna")
# samochod4 = Car(Car,"inna")
コード例 #11
0
def test_add():
    instance = Numbers()
    assert instance.add(1) == 1, "should be 1"
    assert instance.add(1, 2) == 1+2, "should be 3"
    assert instance.add(1, 2, -3) == 1+2-3, "should be 0"
    assert instance.add(1, 2, 1.05) == 1+2+1.05, "should be 4.05"
コード例 #12
0
ファイル: TestNumber.py プロジェクト: AkireL/TestH3ru
 def test_getValue(self):
     n = Numbers(Verb(Language()), Preposition(Language()))
     self.assertEqual(n.getValue("gxjrc"), 605637)
コード例 #13
0
 def test_abs_multiplication(self):
     num = Numbers(1, -2, 1)
     self.assertEqual(
         2, num.abs_multiplication(),
         "Wrong absolute multiplication. Actual result: " +
         str(num.abs_multiplication()))
コード例 #14
0
 def test_abs_multiplication(self):
     a = 1
     b = -2
     c = 3
     num = Numbers(a, b, c)
     self.assertEquals(math.fabs(a * b * c), num.abs_multiplication(), 'Wrong abs_multiplication')
コード例 #15
0
 def test_abs_multiplication(self):
     num = Numbers(1, -2, 1)
     self.assertEqual(2, num.abs_multiplication(),
                      "Wrong absolute multiplication. Actual result: " + str(num.abs_multiplication()))
コード例 #16
0
ファイル: TestWordValidation.py プロジェクト: AkireL/TestH3ru
 def test_isVerb(self):
     self.h = Verb( Language() )     
     self.assertEqual(self.h.isVerb("xoxo"), False)        
     self.assertEqual(self.h.isVerb("xoxox"), False)        
     self.assertEqual(self.h.isVerb("xoxoxo"), True)        
     self.assertEqual(self.h.isVerb("xoxoxs"), False)        
コード例 #17
0
ファイル: TestWordValidation.py プロジェクト: AkireL/TestH3ru
class TestWordValidation(unittest.TestCase):

    def test_isInLanguage(self):  
        self.h = Language()     
        self.assertEqual(self.h.isInLanguage("xoxox"), True)

    def test_isVerb(self):
        self.h = Verb( Language() )     
        self.assertEqual(self.h.isVerb("xoxo"), False)        
        self.assertEqual(self.h.isVerb("xoxox"), False)        
        self.assertEqual(self.h.isVerb("xoxoxo"), True)        
        self.assertEqual(self.h.isVerb("xoxoxs"), False)        
 
    def test_isVerbSubjunctive(self):  
        self.h = Verb(Language() )     
        
        self.assertEqual(self.h.isVerbSubjunctive("xoxo"), False)        
        self.assertEqual(self.h.isVerbSubjunctive("xoxox"), False)        
        self.assertEqual(self.h.isVerbSubjunctive("oxooxo"), True)        
        self.assertEqual(self.h.isVerbSubjunctive("xxoxoxs"), False)  
        self.assertEqual(self.h.isVerbSubjunctive("oxoxoxo"), True)   

    def test_isPreposition(self):  
        self.h = Preposition(Language())     
        self.assertEqual(self.h.isPreposition("puxod"), False)
        self.assertEqual(self.h.isPreposition("puxood"), False)
        self.assertEqual(self.h.isPreposition("pwdood"), True)

    def test_isNumber(self):  
        self.h = Numbers(Verb(Language() ),Preposition(Language()) )     
        self.assertEqual(self.h.isNumber("gxjrc"), True)
        self.assertEqual(self.h.isNumber("pwdood"), False)
コード例 #18
0
 def test_sum(self):
     a = 1
     b = 2
     c = 3
     num = Numbers(a, b, c)
     self.assertEquals(a + b + c, num.sum(), 'Wrong sum')
コード例 #19
0
 def test_sum(self):
     a = 1
     b = 2
     c = 3
     num = Numbers(a, b, c)
     self.assertEquals(a + b + c, num.sum(), 'Wrong sum')
コード例 #20
0
 def test_init_negative(self):
     num = Numbers(1, 2, -3)
     self.assertEquals(1, num.a, 'A have wrong value')
     self.assertEquals(2, num.b, 'B have wrong value')
     self.assertEquals(0, num.c, 'C have wrong value')
コード例 #21
0
ファイル: TestWordValidation.py プロジェクト: AkireL/TestH3ru
 def test_isPreposition(self):  
     self.h = Preposition(Language())     
     self.assertEqual(self.h.isPreposition("puxod"), False)
     self.assertEqual(self.h.isPreposition("puxood"), False)
     self.assertEqual(self.h.isPreposition("pwdood"), True)
コード例 #22
0
 def __init__(self):
     self.lObj = Language()
     self.vObj = Verb(self.lObj)
     self.pObj = Preposition(self.lObj)
     self.nObj = Numbers(self.vObj, self.pObj)
コード例 #23
0
 def test_multiplication(self):
     num = Numbers(1, 2, 0)
     self.assertEqual(0, num.multiplication(), "Wrong multiplication. Actual result: " + str(num.multiplication()))
コード例 #24
0
 def test_init(self):
     num = Numbers(1, 2, 3)
     self.assertEquals(1, num.a, 'A have wrong value')
     self.assertEquals(2, num.b, 'B have wrong value')
     self.assertEquals(3, num.c, 'C have wrong value')
コード例 #25
0
 def test_multiplication(self):
     a = 1
     b = 2
     c = 3
     num = Numbers(a, b, c)
     self.assertEquals(a * b * c, num.multiplication(), 'Wrong multiplication')
コード例 #26
0
ファイル: TestWordValidation.py プロジェクト: AkireL/TestH3ru
 def test_isInLanguage(self):  
     self.h = Language()     
     self.assertEqual(self.h.isInLanguage("xoxox"), True)
コード例 #27
0
minimo = int(input("Qual o valor minimo?"))
h = int(input("Qual a amplitude?"))
amp= minimo+(h-1)
for l in lista:
	if (amp < lista[-1]):
		lista_amp = getFreque(lista, amp)
		frequence = len(lista_amp)

		frequence_relative = getFrequeReL(frequence, tamanho)

		frequence_acl +=frequence

		frequence_rel_acl = getFrequeAclRel(frequence_acl, tamanho)

		frequence_object = Numbers(lista_amp, frequence, frequence_relative, frequence_acl, frequence_rel_acl)
		lista_frequencias.append(frequence_object)
		amp+= (h)

last_numbers_frequency = len(lista)
last_numbers_frequency_relative = round(last_numbers_frequency/tamanho,3)*100
last_numbers_frequency_acl = frequence_acl+ last_numbers_frequency
last_numbers_frequency_acl_relative = round(last_numbers_frequency_acl/tamanho,4)*100
last_frequence_object = Numbers(lista, last_numbers_frequency, last_numbers_frequency_relative, last_numbers_frequency_acl, last_numbers_frequency_acl_relative)

lista_frequencias.append(last_frequence_object)
lista_hist = []
lista_hist.append(minimo)
print(" "," ","Classe", " "," ", "FA", " ", "FI%", " ", "FAci", " ", "FAci%")
for x in lista_frequencias:
	for i in x.number:
コード例 #28
0
 def test_sum(self):
     num = Numbers(1, 2, 0)
     self.assertEqual(3, num.sum(),
                      "Wrong sum. Actual result: " + str(num.sum()))
コード例 #29
0
 def test_multiplication(self):
     num = Numbers(1, 2, 0)
     self.assertEqual(
         0, num.multiplication(), "Wrong multiplication. Actual result: " +
         str(num.multiplication()))
コード例 #30
0
ファイル: TestWordValidation.py プロジェクト: AkireL/TestH3ru
 def test_isNumber(self):  
     self.h = Numbers(Verb(Language() ),Preposition(Language()) )     
     self.assertEqual(self.h.isNumber("gxjrc"), True)
     self.assertEqual(self.h.isNumber("pwdood"), False)
コード例 #31
0
 def test_sum(self):
     num = Numbers(1, 2, 0)
     self.assertEqual(3, num.sum(), "Wrong sum. Actual result: " + str(num.sum()))