Comments (4)
I see number of exceptions AttributeError: 'NoneType' object has no attribute 'primitive'. Here is just one example out of many
I assume that you have a script and a big bank of test examples or something. Could you perhaps share that somehow?
from sympy.
I see number of exceptions AttributeError: 'NoneType' object has no attribute 'primitive'. Here is just one example out of many
I assume that you have a script and a big bank of test examples or something. Could you perhaps share that somehow?
I got these from Computer Algebra Independent Integration Tests which lists exceptions generated. Note that the command shown on these pages should be string.
i.e. when it says on the above link
integrate(a**x/(b**x),x)
It is actually entered in the test program as
integrate(S( "a**x/(b**x)" ) ,x)
Also the symbols command is needed before, which is now not shown.
from sympy.
I got these from Computer Algebra Independent Integration Tests which lists exceptions generated
Oh, very nice.
It would be good to add something in CI to keep track of these examples. It would be better to have test results for the whole database rather than tracking a separate GitHub issue for each case.
Is the code for these examples publicly available somewhere?
Perhaps if we could turn those tests into doctests we could do snapshot testing with them using something like pytest-accept:
https://github.com/max-sixty/pytest-accept
from sympy.
Is the code for these examples publicly available somewhere?
The integration problems were collected from different sources such as by Albert Rich Rubi test suite and from contributions by others.
There are 367 test files. With total of 107,000 integrals.
Each report page for each file contains an appendix with link to plain text input file that contains all the integration problems in that file, in each CAS own syntax,
For example for sympy, here link to report 1 and you will see an appendix there. Following that there is link to download the python file with all the integration problems for sympy for that one test file.
This below is simplified version of my python script that runs on one file only and at the end gives percentage solved and failed. The input file that contains the integration problem and this script need to be in same folder.
#minimal example showing how to run CAS integration test on one
#input file to call sympy integrate command. The input file name
#is now hardcoded inside the main function below
#Run this script using the command
#
# python ./test_one_CAS_integration.py
#
#At the end it will give % passed and % failed for this one file.
#Do the same for different integration test input files.
#version: April 17, 2024
from sympy import *
import multiprocessing as mp
import os, sys, datetime, ntpath, time
def doTheIntegration(q1,q2):
problem = q1.get()
integrand = S(problem[0])
theVar = S(problem[1])
anti = integrate(integrand ,theVar)
if str(anti).find("Integral") == -1:
result=1
else:
result=0
q2.put([result,anti])
if __name__ == "__main__":
input_test_file="input.py"
try:
exec(open(input_test_file).read()) #This reads lst
except Exception as ee:
print("Failed to open file of integration problems. [",input_test_file, "]", type(ee).__name__)
sys.exit(1)
number_passed = 0
number_failed = 0
for counter, item in enumerate(lst,start=1):
q1= mp.Queue()
q2= mp.Queue()
q1.put([item[0],item[1]]) #integrand, variable
process = mp.Process(target=doTheIntegration, args=(q1,q2,))
process.start()
try:
result = q2.get(True,30) #30 seconds timeout
if result[0]==1:
number_passed = number_passed + 1
print("#",counter," PASSED")
else:
number_failed = number_failed + 1
print("#",counter," FAILED")
except Exception as ee:
number_failed = number_failed + 1
print("#",counter," TIMED OUT")
print("TEST Summary: Passed ", number_passed*100/len(lst),
"%, Failed ", number_failed*100/len(lst),"%")
Running the above using python ./test_one_CAS_integration.py
gives
>python ./test_one_CAS_integration_file.py
# 1 PASSED
# 2 PASSED
# 3 PASSED
# 4 PASSED
# 5 PASSED
# 6 PASSED
# 7 PASSED
# 8 PASSED
# 9 PASSED
# 10 PASSED
# 11 PASSED
# 12 PASSED
# 13 PASSED
# 14 PASSED
# 15 PASSED
# 16 PASSED
# 17 PASSED
# 18 PASSED
# 19 FAILED
# 20 PASSED
# 21 PASSED
etc...
172 PASSED
# 173 FAILED
# 174 FAILED
# 175 PASSED
TEST Summary: Passed 93.71428571428571 %, Failed 6.285714285714286 %
The independent CAS integration program just does more book keeping and statistics and generates the Latex for the reports and so on. But the above script is the basic idea. Feel free to use and modify as you need.
from sympy.
Related Issues (20)
- TypeError on `function_range` of Abs(((log(x))**Rational(1, 3))) HOT 5
- S(0)==False->True (should be False) HOT 5
- Wrong result for digamma integral representation HOT 16
- hyperexpand bad output called on I*meijerg(((1, x + 2), ()), ((x + S(1)/2,), (0,)), z*exp_polar(I*pi))*exp(-I*pi*x)/(2*sqrt(pi)) HOT 7
- 1x1 MatrixSymbol should be treated as a scalar HOT 4
- Recursively get property downwards for `Add` and `Mul` HOT 1
- Roots of non-real elements should be non-real themselves, but their domain is unknown HOT 1
- collect function bug HOT 3
- Display Function Cannot Combine Vector Arrows with Subscripts In Jupyter Notebooks HOT 1
- Why is the Quaternion logarithmic map given a private-looking name? HOT 3
- analytic_func() of ImmutableMatrix is broken and trys to mutate some immutable matrix during execution HOT 1
- RecursionError in simplify of non-commutative expressions with non-integer coefficient HOT 1
- Wrong answer calculating the inverse Laplace transform of a function HOT 1
- Derivative is incorrectly set to 0 for some summation expressions. HOT 2
- Rust Codegen doesn't generate public functions HOT 3
- coeff for non-integer powers fails
- wrong result integrating sin(a*(x+pi))**2 HOT 5
- Improving Beam Class to Handle Hinge Beams Using Singularity Functions to Describe Hinges
- integrate((x**8+1)**(-1/2),x) raises _CoeffExpValueError HOT 4
- Ideal membership testing raises `ValueError` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sympy.