|
|
|
|
@ -1,5 +1,3 @@
|
|
|
|
|
#定积分计算、变限积分计算、反常积分计算和敛散性
|
|
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
from numpy import *
|
|
|
|
|
from sympy import *
|
|
|
|
|
@ -71,9 +69,7 @@ def improper_integral_calculation(function,upper,lower):
|
|
|
|
|
except:
|
|
|
|
|
return None,False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestIntegralFunctions(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
def test_definite_integral(self):
|
|
|
|
|
"""测试定积分计算"""
|
|
|
|
|
# 测试案例1: ∫[0,1] x^2 dx = 1/3
|
|
|
|
|
@ -121,7 +117,6 @@ class TestIntegralFunctions(unittest.TestCase):
|
|
|
|
|
self.assertEqual(result, 2)
|
|
|
|
|
self.assertTrue(convergent)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def UI():
|
|
|
|
|
while True:
|
|
|
|
|
command= input('请选择功能:1.定积分计算2.变限积分计算3.反常积分计算和敛散性4.退出')
|
|
|
|
|
@ -149,11 +144,6 @@ def UI():
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main()
|
|
|
|
|
# 运行测试但不退出,允许后续代码执行
|
|
|
|
|
unittest.main(exit=False)
|
|
|
|
|
UI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|