Пример #1
0
def test_function():
    exponential_func = Function(exp)
    sin_func = Function(sin)
    # print(exponential_func.execute(sin_func.execute(0)))

    assert sin_func.execute(0, False) == 0
    assert exponential_func.execute(sin_func.execute(0, False), False) == 1

    print('Function tested SUCCESSFULLY')
Пример #2
0
while not STACK.is_empty():
    print(STACK.pop())
    print("Elements left: " + str(STACK.size()))

print("\nQueue test")
QUEUE = Queue()
for elem in range(2, 6):
    QUEUE.push(elem)
while not QUEUE.is_empty():
    print(QUEUE.pop())
    print("Elements left: " + str(QUEUE.size()))

print("\nFunction test")
EXPONENTIAL_FUNC = Function(numpy.exp)
SIN_FUNC = Function(numpy.sin)
print(EXPONENTIAL_FUNC.execute(SIN_FUNC.execute(0)))

print("\nOperator test")
ADD_OP = Operator(numpy.add, 0)
MULTIPLY_OP = Operator(numpy.multiply, 1)
print(ADD_OP.execute(1, MULTIPLY_OP.execute(2, 3)))

print("\nCalculator test")
CALC = Calculator()
print("Calculator class test: " +
      str(CALC.functions['EXP'].execute((CALC.operators['PLUSS'].execute(
          1, CALC.operators['GANGE'].execute(2, 3))))))
CALC.output_queue.push(1)
CALC.output_queue.push(2)
CALC.output_queue.push(3)
CALC.output_queue.push(CALC.operators['GANGE'])