added test cases
This commit is contained in:
parent
59c0e71682
commit
f446db0ea7
2 changed files with 33 additions and 0 deletions
29
tests/2d/scipy/integrate.py
Normal file
29
tests/2d/scipy/integrate.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import sys
|
||||
from math import *
|
||||
|
||||
# this test is meaningful only if ulab is compiled with ulab.scipy.integrate
|
||||
# we're not going to test CPython scipy.
|
||||
try:
|
||||
from ulab import scipy
|
||||
except Exception as e:
|
||||
print ("could not import ulab.scipy: ", e)
|
||||
sys.exit(1)
|
||||
|
||||
i = scipy.integrate
|
||||
try:
|
||||
if str(type(i)) != "<class 'module'>":
|
||||
print ("scipy.integrate is not available")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print ("scipy.integrate is not available")
|
||||
sys.exit(1)
|
||||
|
||||
f = lambda x: x * sin(x) * exp(x)
|
||||
a=1
|
||||
b=2
|
||||
# what if they are not all available?
|
||||
algorithms = ( i.quad, i.romberg, i.simpson, i.quadgk )
|
||||
for quad in algorithms:
|
||||
print (quad(f, a, b))
|
||||
|
||||
|
||||
4
tests/2d/scipy/integrate.py.exp
Normal file
4
tests/2d/scipy/integrate.py.exp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(7.11263821415851, 5.438231077315757e-14)
|
||||
7.112638214158507
|
||||
7.112638214158494
|
||||
(7.112638214158507, 7.686723611780195e-14)
|
||||
Loading…
Reference in a new issue