Skip to content

Commit

Permalink
added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
h-milz committed Dec 8, 2024
1 parent 59c0e71 commit f446db0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/2d/scipy/integrate.py
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions tests/2d/scipy/integrate.py.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(7.11263821415851, 5.438231077315757e-14)
7.112638214158507
7.112638214158494
(7.112638214158507, 7.686723611780195e-14)

0 comments on commit f446db0

Please sign in to comment.