Exemplo n.º 1
0
 def testExamplePybind11Calls(self):
     assert '0.0.1' == m.__version__
     assert 3 == m.add(1, 2)
     assert -1 == m.subtract(1, 2)
Exemplo n.º 2
0
import python_example as m

assert m.__version__ == '0.0.1'
assert m.add(1, 2) == 3
assert m.subtract(1, 2) == -1
Exemplo n.º 3
0
# coding: utf-8
# Author: [email protected]

# https://github.com/pybind/python_example

# first step: pip install ./python_example

import python_example
res = python_example.add(1, 2)
print(res)
Exemplo n.º 4
0
import python_example as m

if m.add(2, 1) == 3 and m.sub(2, 1) == 1:
    print("Test passed")
Exemplo n.º 5
0
def test_addition():
    np.testing.assert_allclose(python_example.add(1, 2), 3)
import sys

sys.path.append("../../../build/bind/use_pybind11")

import python_example

assert python_example.__version__ == '0.0.1' or python_example.__version__ == 'test'
assert python_example.add(1, 2) == 3
assert python_example.subtract(1, 2) == -1

print(python_example.__doc__)
print(python_example.add.__doc__)
print(python_example.subtract.__doc__)
Exemplo n.º 7
0
import python_example

#assert python_example.__version__ == '0.0.1'

a = 1
b = 2
a = taint(a)
b = taint(b)

ans1 = python_example.add(a, b)
ans2 = python_example.subtract(a, b)

print(ans1)
print(ans2)

def taint(x):
    return x
Exemplo n.º 8
0
import python_example

a = python_example.add(3.0, 1.3232)
print("the sum of two double is " + str(a))

b = python_example.square(4)
print("the square of one doulbe is " + str(b))

maturity = 0.5
BS = python_example.BS(maturity)
print("the option price calculated by BS formula is " + str(BS))

initEquityPrice = 10
numTimeSteps = 6
timetoExpiry = 6
drift = 0.1
volatility = 0.1
EPG = python_example.EquityPriceGenerator(initEquityPrice, numTimeSteps,
                                          timetoExpiry, drift, volatility)
print("EquityPriceGenerator initiated")
print(EPG)
price1 = EPG.operator(1)
print("the sequence of prices calculated by Monte Carlo formula is " +
      str(price1))

strikePrice = 42
exercisePrice = 40
interestRate = 0.1
volatility = 0.2
BSG = python_example.BlackScholesGenerator(strikePrice, exercisePrice,
                                           interestRate, volatility, maturity)
Exemplo n.º 9
0
import python_example as m

assert m.__version__ == '0.0.1'
print(m.__version__)
assert m.add(1, 2) == 3
print("m.add(100,200)=", m.add(100, 200))
assert m.subtract(1, 2) == -1
print("m.subtract(100,200)=", m.subtract(100, 200))
print(m.__doc__)
Exemplo n.º 10
0
def test_add_1_2():
    assert m.add(1, 2) == 3