示例#1
0
文件: test.py 项目: beru/cython_test
def test():
    t = tf.zeros([10, 5])
    print(t)
    packed = tf.experimental.dlpack.to_dlpack(t)
    adder.add(packed, 111)
    t = tf.experimental.dlpack.from_dlpack(packed)
    print(t)
示例#2
0
def test_add_even_larger_ints():
    """Otestování výpočtu součtu dvou velkých celých čísel."""
    init()
    result = add(2**31 - 1, 1)
    expected = 2**31
    assert result == expected, "Očekávaná hodnota {}, vráceno {}".format(
        expected, result)
示例#3
0
def test_add_basic():
    """Otestování výpočtu součtu dvou celých čísel."""
    init()
    result = add(1, 2)
    expected = 3
    assert result == expected, "Očekávaná hodnota {}, vráceno {}".format(
        expected, result)
示例#4
0
def test_add_basic():
    """Otestování výpočtu součtu dvou komplexních čísel."""
    init()

    c1 = Complex(1.0, 2.0)
    c2 = Complex(3.0, 4.0)

    result = add(c1, c2)
    expected = Complex(4.0, 6.0)
    assert result == expected, \
        "Očekávaná hodnota {}, vráceno {}".format(expected, result)
示例#5
0
def calculate():
    import adder

    print("Input a number     ")
    d = input()
    d = int(d)

    print("Input a number     ")
    e = input()
    e = int(e)

    f = adder.add(d, e)

    print("So", d, "plus", e, "is")
    print(f)
    return (f)
示例#6
0
文件: helper.py 项目: rslu2000/IECCS
def getImportantInfo(dic, index):
    # Create an empty new dictionary
    new_dic = {}
    # Add fields from TCP
    new_dic["_id"] = tcp_data.Id.iloc[index]
    new_dic["Abstract"] = tcp_data.Abstract.iloc[index].replace("|",",")
    new_dic["Endorsement"] = tcp_data.Endorse.iloc[index]
    new_dic["Stance"] = getStanceByEndorse(tcp_data.Endorse.iloc[index])
    new_dic["Year"] = tcp_data.Year.iloc[index]
    new_dic["Category"] = tcp_data.Cat.iloc[index]
    new_dic["Title"] = tcp_data.Title.iloc[index].replace("|",",")

    # Add new data from WoS
    new_dic = adder.add(dic, new_dic)

    return new_dic
示例#7
0
文件: mult.py 项目: SimretA/CPV
def multiply(num1, num2):
    carry = 0
    num1len = len(num1)
    num2len = len(num2)
    to_add = []

    for i in range(num1len - 1, -1, -1):
        temp = ""
        for j in range(num2len - 1, -1, -1):

            multiplied = int(num1[i]) * int(num2[j]) + carry
            carry = multiplied // 10
            multiplied = multiplied % 10
            temp = str(multiplied) + temp

        temp += (num1len - 1 - i) * "0"
        to_add.append(temp)

    print(to_add)
    result = to_add[0]
    for result_i in range(1, len(to_add)):
        result = add(to_add[result_i], result)
    print("Result ", result)
def test_add():
    res = adder.add(2, 2)
    assert res == 4
示例#9
0
def extractDataFromRoot(roots, tcp_data):
    data = []
    for root in roots:
        data.append(adder.add(root[0], root[1], tcp_data))
    return data
 def test_7_set_input_error(self):
     self.assertIsNone(adder.add(7, {2}), "Error: Accepted 'set' type")
 def test_3_complex_input_error(self):
     self.assertIsNone(adder.add(7, 1.2J), "Error: Accepted complex number")
示例#12
0
import adder
import sys
import io

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding='utf-8')

print(adder.add(5, 50))
print(adder.add(100, 200))


def a(a, b):
    if (a > b):
        print("a is bigger than b")
    else:
        print("a즐")


a(10, 20)
a(20, 1)
 def test_2_float_input_error(self):
     self.assertIsNone(adder.add(1.2,2), "Error: Accepted floating point")
 def test_5_none_input_error(self):
     self.assertIsNone(adder.add(7, None), "Error: Accepted 'None' type")
 def test_12_neg_integer_input_success(self):
     self.assertEqual(adder.add(1, -3), -2, "Error: Negative integer Not accepted")
 def test_11_integer_input_success(self):
     self.assertEqual(adder.add(1, 3), 4, "Error: Integer Not accepted")
 def test_10_bool_input_error(self):
     self.assertIsNone(adder.add(True, 3), "Error: Accepted Mapped boolean")        
 def test_9_range_input_error(self):
     self.assertIsNone(adder.add(1, range(1)), "Error: Accepted 'range' type")
 def test_8_dict_input_error(self):
     self.assertIsNone(adder.add(7, {1:2}), "Error: Accepted 'dict' type")
def test_add_negative_int():
    """Test add() for negative integers -7 and -3"""
    number = adder.add(-7, -3)
    assert number == -10
示例#21
0
 def Add(self, request, context):
     response = adder_pb2.AddedResult()
     response.value = adder.add(request.value1, request.value2)
     return response
def test_add_positive_int():
    """Test add() for positive integers 2 and 10"""
    number = adder.add(2, 10)
    assert number == 12
示例#23
0
import adder

num1 = input('What is the 1st number?')
num2 = input('What is the 2nd number?')
adder.add(num1, num2)
def test_add():
    eq_(adder.add(2, 3), 5)
示例#25
0
"""Vytvoření úlohy."""

from adder import add

r = add(1, "foo")
print(r)
print(r())

try:
    print(r(blocking=True))
except Exception as e:
    print("Exception detected!", e)
示例#26
0
文件: calculator.py 项目: SimretA/CPV
from adder import add
from mult import multiply
from sub import sub

if __name__ == '__main__':
    choice = eval(
        input("Enter 1. to add\n2. to sub\n3. to multiply.\n4. to divide"))
    num1 = input("Enter first number")
    num2 = input("Enter second number")
    if choice == 1:
        add(num1, num2)
    elif choice == 2:
        sub(num1, num2)
    elif choice == 3:
        multiply(num1, num2)
    elif choice == 4:
        div(num1, num2)
 def test_4_null_input_error(self):
     self.assertIsNone(adder.add(7), "Error: Accepted null input")
def test_numbers_are_added(dummy_data):
    actual = adder.add(dummy_data, number=42)["value"]
    expected = pytest.approx(70.1)

    assert actual == expected
示例#29
0
def main():
    """Otestování, jestli je možné zavolat nativní funkci."""
    init()
    result = add(1, 2)
    print(f"1+2=", result, sep="")
 def test_6_sequence_input_error(self):
     self.assertIsNone(adder.add(7, [1]), "Error: Accepted 'sequence' type")
def test_add_str():
    eq_(adder.add(2, '2'), 9)
示例#32
0
import helper
import adder

if __name__ == "__main__":
	# print("hello")
	helper.greeting("hello2")
	adder.add(1, 2)
示例#33
0
def extractDataFromRoot(roots, tcp_data):
    data = []
    for root in roots:
        data.append(adder.add(root[0], root[1], tcp_data))
    return data
示例#34
0
 def testAdd(self):
     self.assertEqual(add(8, 8), 16)
def test_ignores_are_not_added(dummy_data):
    actual = adder.add(dummy_data, number=42, ignore_keys=["name", "zero"])["zero"]
    expected = 0

    assert actual == expected
示例#36
0
def test_rightmost_carry():
    a = [1, 2, 3]
    b = [7, 2, 9]
    c = [8, 5, 2]
    assert adder.add(a, b) == c
示例#37
0
def test_add():
    total = add(1, 1)
    assert total == 2
示例#38
0
def test_lefttmost_carry():
    a = [9, 2, 3]
    b = [7, 2, 0]
    c = [1, 6, 4, 3]
    assert adder.add(a, b) == c
示例#39
0
def test_add(x, y, z):
    res = adder.add(x, y)
    assert res == z
示例#40
0
def test_no_carry():
    a = [1, 2, 3]
    b = [7, 2, 0]
    c = [8, 4, 3]
    assert adder.add(a, b) == c
def test_add(x, y):
    res = adder.add(x)
    assert res == 4
示例#42
0
def test_a_longer():
    a = [1, 2, 3]
    b = [1, 0, 0, 0, 7, 2, 0]
    c = [1, 0, 0, 0, 8, 4, 3]
    assert adder.add(a, b) == c
示例#43
0
import adder

d = adder.add(4, 66)

print(d)
 def test_1_alpha_input_error(self):
     self.assertIsNone(adder.add("a",2), "Error: Accepted alpha character")