Spaces:
Running
Running
MilesCranmer
commited on
Remove Feynman problems and dataset
Browse files- .github/workflows/CI.yml +5 -5
- datasets/FeynmanEquations.csv +0 -101
- pysr/__init__.py +0 -2
- pysr/feynman_problems.py +0 -176
.github/workflows/CI.yml
CHANGED
@@ -64,22 +64,22 @@ jobs:
|
|
64 |
run: pip install coverage coveralls
|
65 |
- name: "Run tests"
|
66 |
run: |
|
67 |
-
coverage run --source=pysr --omit='*/test
|
68 |
-
coverage run --append --source=pysr --omit='*/test
|
69 |
- name: "Install JAX"
|
70 |
run: pip install jax jaxlib # (optional import)
|
71 |
if: ${{ matrix.test-id == 'main' }}
|
72 |
- name: "Run JAX tests"
|
73 |
-
run: coverage run --append --source=pysr --omit='*/test
|
74 |
if: ${{ matrix.test-id == 'main' }}
|
75 |
- name: "Install Torch"
|
76 |
run: pip install torch # (optional import)
|
77 |
if: ${{ matrix.test-id == 'main' }}
|
78 |
- name: "Run Torch tests"
|
79 |
-
run: coverage run --append --source=pysr --omit='*/test
|
80 |
if: ${{ matrix.test-id == 'main' }}
|
81 |
- name: "Run custom env tests"
|
82 |
-
run: coverage run --append --source=pysr --omit='*/test
|
83 |
- name: "Coveralls"
|
84 |
env:
|
85 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
64 |
run: pip install coverage coveralls
|
65 |
- name: "Run tests"
|
66 |
run: |
|
67 |
+
coverage run --source=pysr --omit='*/test/*' -m pysr test main
|
68 |
+
coverage run --append --source=pysr --omit='*/test/*' -m pysr test cli
|
69 |
- name: "Install JAX"
|
70 |
run: pip install jax jaxlib # (optional import)
|
71 |
if: ${{ matrix.test-id == 'main' }}
|
72 |
- name: "Run JAX tests"
|
73 |
+
run: coverage run --append --source=pysr --omit='*/test/*' -m pysr test jax
|
74 |
if: ${{ matrix.test-id == 'main' }}
|
75 |
- name: "Install Torch"
|
76 |
run: pip install torch # (optional import)
|
77 |
if: ${{ matrix.test-id == 'main' }}
|
78 |
- name: "Run Torch tests"
|
79 |
+
run: coverage run --append --source=pysr --omit='*/test/*' -m pysr test torch
|
80 |
if: ${{ matrix.test-id == 'main' }}
|
81 |
- name: "Run custom env tests"
|
82 |
+
run: coverage run --append --source=pysr --omit='*/test/*' -m pysr test env
|
83 |
- name: "Coveralls"
|
84 |
env:
|
85 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
datasets/FeynmanEquations.csv
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
Filename,datapoints,Number,Output,Formula,# variables,v1_name,v1_low,v1_high,v2_name,v2_low,v2_high,v3_name,v3_low,v3_high,v4_name,v4_low,v4_high,v5_name,v5_low,v5_high,v6_name,v6_low,v6_high,v7_name,v7_low,v7_high,v8_name,v8_low,v8_high,v9_name,v9_low,v9_high,v10_name,v10_low,v10_high
|
2 |
-
I.6.2a,10,1,f,exp(-theta**2/2)/sqrt(2*pi),1,theta,1,3,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
3 |
-
I.6.2,100,2,f,exp(-(theta/sigma)**2/2)/(sqrt(2*pi)*sigma),2,sigma,1,3,theta,1,3,,,,,,,,,,,,,,,,,,,,,,,,
|
4 |
-
I.6.2b,1000,3,f,exp(-((theta-theta1)/sigma)**2/2)/(sqrt(2*pi)*sigma),3,sigma,1,3,theta,1,3,theta1,1,3,,,,,,,,,,,,,,,,,,,,,
|
5 |
-
I.8.14,100,4,d,sqrt((x2-x1)**2+(y2-y1)**2),4,x1,1,5,x2,1,5,y1,1,5,y2,1,5,,,,,,,,,,,,,,,,,,
|
6 |
-
I.9.18,1000000,5,F,G*m1*m2/((x2-x1)**2+(y2-y1)**2+(z2-z1)**2),9,m1,1,2,m2,1,2,G,1,2,x1,3,4,x2,1,2,y1,3,4,y2,1,2,z1,3,4,z2,1,2,,,
|
7 |
-
I.10.7,10,6,m,m_0/sqrt(1-v**2/c**2),3,m_0,1,5,v,1,2,c,3,10,,,,,,,,,,,,,,,,,,,,,
|
8 |
-
I.11.19,100,7,A,x1*y1+x2*y2+x3*y3,6,x1,1,5,x2,1,5,x3,1,5,y1,1,5,y2,1,5,y3,1,5,,,,,,,,,,,,
|
9 |
-
I.12.1,10,8,F,mu*Nn,2,mu,1,5,Nn,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
10 |
-
I.12.2,10,10,F,q1*q2*r/(4*pi*epsilon*r**3),4,q1,1,5,q2,1,5,epsilon,1,5,r,1,5,,,,,,,,,,,,,,,,,,
|
11 |
-
I.12.4,10,11,Ef,q1*r/(4*pi*epsilon*r**3),3,q1,1,5,epsilon,1,5,r,1,5,,,,,,,,,,,,,,,,,,,,,
|
12 |
-
I.12.5,10,12,F,q2*Ef,2,q2,1,5,Ef,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
13 |
-
I.12.11,10,13,F,q*(Ef+B*v*sin(theta)),5,q,1,5,Ef,1,5,B,1,5,v,1,5,theta,1,5,,,,,,,,,,,,,,,
|
14 |
-
I.13.4,10,9,K,1/2*m*(v**2+u**2+w**2),4,m,1,5,v,1,5,u,1,5,w,1,5,,,,,,,,,,,,,,,,,,
|
15 |
-
I.13.12,10,14,U,G*m1*m2*(1/r2-1/r1),5,m1,1,5,m2,1,5,r1,1,5,r2,1,5,G,1,5,,,,,,,,,,,,,,,
|
16 |
-
I.14.3,10,15,U,m*g*z,3,m,1,5,g,1,5,z,1,5,,,,,,,,,,,,,,,,,,,,,
|
17 |
-
I.14.4,10,16,U,1/2*k_spring*x**2,2,k_spring,1,5,x,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
18 |
-
I.15.3x,10,17,x1,(x-u*t)/sqrt(1-u**2/c**2),4,x,5,10,u,1,2,c,3,20,t,1,2,,,,,,,,,,,,,,,,,,
|
19 |
-
I.15.3t,100,18,t1,(t-u*x/c**2)/sqrt(1-u**2/c**2),4,x,1,5,c,3,10,u,1,2,t,1,5,,,,,,,,,,,,,,,,,,
|
20 |
-
I.15.1,10,19,p,m_0*v/sqrt(1-v**2/c**2),3,m_0,1,5,v,1,2,c,3,10,,,,,,,,,,,,,,,,,,,,,
|
21 |
-
I.16.6,10,20,v1,(u+v)/(1+u*v/c**2),3,c,1,5,v,1,5,u,1,5,,,,,,,,,,,,,,,,,,,,,
|
22 |
-
I.18.4,10,21,r,(m1*r1+m2*r2)/(m1+m2),4,m1,1,5,m2,1,5,r1,1,5,r2,1,5,,,,,,,,,,,,,,,,,,
|
23 |
-
I.18.12,10,22,tau,r*F*sin(theta),3,r,1,5,F,1,5,theta,0,5,,,,,,,,,,,,,,,,,,,,,
|
24 |
-
I.18.14,10,23,L,m*r*v*sin(theta),4,m,1,5,r,1,5,v,1,5,theta,1,5,,,,,,,,,,,,,,,,,,
|
25 |
-
I.24.6,10,24,E_n,1/2*m*(omega**2+omega_0**2)*1/2*x**2,4,m,1,3,omega,1,3,omega_0,1,3,x,1,3,,,,,,,,,,,,,,,,,,
|
26 |
-
I.25.13,10,25,Volt,q/C,2,q,1,5,C,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
27 |
-
I.26.2,100,26,theta1,arcsin(n*sin(theta2)),2,n,0,1,theta2,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
28 |
-
I.27.6,10,27,foc,1/(1/d1+n/d2),3,d1,1,5,d2,1,5,n,1,5,,,,,,,,,,,,,,,,,,,,,
|
29 |
-
I.29.4,10,28,k,omega/c,2,omega,1,10,c,1,10,,,,,,,,,,,,,,,,,,,,,,,,
|
30 |
-
I.29.16,1000,29,x,sqrt(x1**2+x2**2-2*x1*x2*cos(theta1-theta2)),4,x1,1,5,x2,1,5,theta1,1,5,theta2,1,5,,,,,,,,,,,,,,,,,,
|
31 |
-
I.30.3,100,30,Int,Int_0*sin(n*theta/2)**2/sin(theta/2)**2,3,Int_0,1,5,theta,1,5,n,1,5,,,,,,,,,,,,,,,,,,,,,
|
32 |
-
I.30.5,100,31,theta,arcsin(lambd/(n*d)),3,lambd,1,2,d,2,5,n,1,5,,,,,,,,,,,,,,,,,,,,,
|
33 |
-
I.32.5,10,32,Pwr,q**2*a**2/(6*pi*epsilon*c**3),4,q,1,5,a,1,5,epsilon,1,5,c,1,5,,,,,,,,,,,,,,,,,,
|
34 |
-
I.32.17,10,33,Pwr,(1/2*epsilon*c*Ef**2)*(8*pi*r**2/3)*(omega**4/(omega**2-omega_0**2)**2),6,epsilon,1,2,c,1,2,Ef,1,2,r,1,2,omega,1,2,omega_0,3,5,,,,,,,,,,,,
|
35 |
-
I.34.8,10,34,omega,q*v*B/p,4,q,1,5,v,1,5,B,1,5,p,1,5,,,,,,,,,,,,,,,,,,
|
36 |
-
I.34.1,10,35,omega,omega_0/(1-v/c),3,c,3,10,v,1,2,omega_0,1,5,,,,,,,,,,,,,,,,,,,,,
|
37 |
-
I.34.14,10,36,omega,(1+v/c)/sqrt(1-v**2/c**2)*omega_0,3,c,3,10,v,1,2,omega_0,1,5,,,,,,,,,,,,,,,,,,,,,
|
38 |
-
I.34.27,10,37,E_n,(h/(2*pi))*omega,2,omega,1,5,h,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
39 |
-
I.37.4,100,38,Int,I1+I2+2*sqrt(I1*I2)*cos(delta),3,I1,1,5,I2,1,5,delta,1,5,,,,,,,,,,,,,,,,,,,,,
|
40 |
-
I.38.12,10,39,r,4*pi*epsilon*(h/(2*pi))**2/(m*q**2),4,m,1,5,q,1,5,h,1,5,epsilon,1,5,,,,,,,,,,,,,,,,,,
|
41 |
-
I.39.1,10,40,E_n,3/2*pr*V,2,pr,1,5,V,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
42 |
-
I.39.11,10,41,E_n,1/(gamma-1)*pr*V,3,gamma,2,5,pr,1,5,V,1,5,,,,,,,,,,,,,,,,,,,,,
|
43 |
-
I.39.22,10,42,pr,n*kb*T/V,4,n,1,5,T,1,5,V,1,5,kb,1,5,,,,,,,,,,,,,,,,,,
|
44 |
-
I.40.1,10,43,n,n_0*exp(-m*g*x/(kb*T)),6,n_0,1,5,m,1,5,x,1,5,T,1,5,g,1,5,kb,1,5,,,,,,,,,,,,
|
45 |
-
I.41.16,10,44,L_rad,h/(2*pi)*omega**3/(pi**2*c**2*(exp((h/(2*pi))*omega/(kb*T))-1)),5,omega,1,5,T,1,5,h,1,5,kb,1,5,c,1,5,,,,,,,,,,,,,,,
|
46 |
-
I.43.16,10,45,v,mu_drift*q*Volt/d,4,mu_drift,1,5,q,1,5,Volt,1,5,d,1,5,,,,,,,,,,,,,,,,,,
|
47 |
-
I.43.31,10,46,D,mob*kb*T,3,mob,1,5,T,1,5,kb,1,5,,,,,,,,,,,,,,,,,,,,,
|
48 |
-
I.43.43,10,47,kappa,1/(gamma-1)*kb*v/A,4,gamma,2,5,kb,1,5,A,1,5,v,1,5,,,,,,,,,,,,,,,,,,
|
49 |
-
I.44.4,10,48,E_n,n*kb*T*ln(V2/V1),5,n,1,5,kb,1,5,T,1,5,V1,1,5,V2,1,5,,,,,,,,,,,,,,,
|
50 |
-
I.47.23,10,49,c,sqrt(gamma*pr/rho),3,gamma,1,5,pr,1,5,rho,1,5,,,,,,,,,,,,,,,,,,,,,
|
51 |
-
I.48.2,100,50,E_n,m*c**2/sqrt(1-v**2/c**2),3,m,1,5,v,1,2,c,3,10,,,,,,,,,,,,,,,,,,,,,
|
52 |
-
I.50.26,10,51,x,x1*(cos(omega*t)+alpha*cos(omega*t)**2),4,x1,1,3,omega,1,3,t,1,3,alpha,1,3,,,,,,,,,,,,,,,,,,
|
53 |
-
II.2.42,10,52,Pwr,kappa*(T2-T1)*A/d,5,kappa,1,5,T1,1,5,T2,1,5,A,1,5,d,1,5,,,,,,,,,,,,,,,
|
54 |
-
II.3.24,10,53,flux,Pwr/(4*pi*r**2),2,Pwr,1,5,r,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
55 |
-
II.4.23,10,54,Volt,q/(4*pi*epsilon*r),3,q,1,5,epsilon,1,5,r,1,5,,,,,,,,,,,,,,,,,,,,,
|
56 |
-
II.6.11,10,55,Volt,1/(4*pi*epsilon)*p_d*cos(theta)/r**2,4,epsilon,1,3,p_d,1,3,theta,1,3,r,1,3,,,,,,,,,,,,,,,,,,
|
57 |
-
II.6.15a,1000,56,Ef,p_d/(4*pi*epsilon)*3*z/r**5*sqrt(x**2+y**2),6,epsilon,1,3,p_d,1,3,r,1,3,x,1,3,y,1,3,z,1,3,,,,,,,,,,,,
|
58 |
-
II.6.15b,10,57,Ef,p_d/(4*pi*epsilon)*3*cos(theta)*sin(theta)/r**3,4,epsilon,1,3,p_d,1,3,theta,1,3,r,1,3,,,,,,,,,,,,,,,,,,
|
59 |
-
II.8.7,10,58,E_n,3/5*q**2/(4*pi*epsilon*d),3,q,1,5,epsilon,1,5,d,1,5,,,,,,,,,,,,,,,,,,,,,
|
60 |
-
II.8.31,10,59,E_den,epsilon*Ef**2/2,2,epsilon,1,5,Ef,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
61 |
-
II.10.9,10,60,Ef,sigma_den/epsilon*1/(1+chi),3,sigma_den,1,5,epsilon,1,5,chi,1,5,,,,,,,,,,,,,,,,,,,,,
|
62 |
-
II.11.3,10,61,x,q*Ef/(m*(omega_0**2-omega**2)),5,q,1,3,Ef,1,3,m,1,3,omega_0,3,5,omega,1,2,,,,,,,,,,,,,,,
|
63 |
-
II.11.17,10,62,n,n_0*(1+p_d*Ef*cos(theta)/(kb*T)),6,n_0,1,3,kb,1,3,T,1,3,theta,1,3,p_d,1,3,Ef,1,3,,,,,,,,,,,,
|
64 |
-
II.11.20,10,63,Pol,n_rho*p_d**2*Ef/(3*kb*T),5,n_rho,1,5,p_d,1,5,Ef,1,5,kb,1,5,T,1,5,,,,,,,,,,,,,,,
|
65 |
-
II.11.27,100,64,Pol,n*alpha/(1-(n*alpha/3))*epsilon*Ef,4,n,0,1,alpha,0,1,epsilon,1,2,Ef,1,2,,,,,,,,,,,,,,,,,,
|
66 |
-
II.11.28,100,65,theta,1+n*alpha/(1-(n*alpha/3)),2,n,0,1,alpha,0,1,,,,,,,,,,,,,,,,,,,,,,,,
|
67 |
-
II.13.17,10,66,B,1/(4*pi*epsilon*c**2)*2*I/r,4,epsilon,1,5,c,1,5,I,1,5,r,1,5,,,,,,,,,,,,,,,,,,
|
68 |
-
II.13.23,100,67,rho_c,rho_c_0/sqrt(1-v**2/c**2),3,rho_c_0,1,5,v,1,2,c,3,10,,,,,,,,,,,,,,,,,,,,,
|
69 |
-
II.13.34,10,68,j,rho_c_0*v/sqrt(1-v**2/c**2),3,rho_c_0,1,5,v,1,2,c,3,10,,,,,,,,,,,,,,,,,,,,,
|
70 |
-
II.15.4,10,69,E_n,-mom*B*cos(theta),3,mom,1,5,B,1,5,theta,1,5,,,,,,,,,,,,,,,,,,,,,
|
71 |
-
II.15.5,10,70,E_n,-p_d*Ef*cos(theta),3,p_d,1,5,Ef,1,5,theta,1,5,,,,,,,,,,,,,,,,,,,,,
|
72 |
-
II.21.32,10,71,Volt,q/(4*pi*epsilon*r*(1-v/c)),5,q,1,5,epsilon,1,5,r,1,5,v,1,2,c,3,10,,,,,,,,,,,,,,,
|
73 |
-
II.24.17,10,72,k,sqrt(omega**2/c**2-pi**2/d**2),3,omega,4,6,c,1,2,d,2,4,,,,,,,,,,,,,,,,,,,,,
|
74 |
-
II.27.16,10,73,flux,epsilon*c*Ef**2,3,epsilon,1,5,c,1,5,Ef,1,5,,,,,,,,,,,,,,,,,,,,,
|
75 |
-
II.27.18,10,74,E_den,epsilon*Ef**2,2,epsilon,1,5,Ef,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
76 |
-
II.34.2a,10,75,I,q*v/(2*pi*r),3,q,1,5,v,1,5,r,1,5,,,,,,,,,,,,,,,,,,,,,
|
77 |
-
II.34.2,10,76,mom,q*v*r/2,3,q,1,5,v,1,5,r,1,5,,,,,,,,,,,,,,,,,,,,,
|
78 |
-
II.34.11,10,77,omega,g_*q*B/(2*m),4,g_,1,5,q,1,5,B,1,5,m,1,5,,,,,,,,,,,,,,,,,,
|
79 |
-
II.34.29a,10,78,mom,q*h/(4*pi*m),3,q,1,5,h,1,5,m,1,5,,,,,,,,,,,,,,,,,,,,,
|
80 |
-
II.34.29b,10,79,E_n,g_*mom*B*Jz/(h/(2*pi)),5,g_,1,5,h,1,5,Jz,1,5,mom,1,5,B,1,5,,,,,,,,,,,,,,,
|
81 |
-
II.35.18,10,80,n,n_0/(exp(mom*B/(kb*T))+exp(-mom*B/(kb*T))),5,n_0,1,3,kb,1,3,T,1,3,mom,1,3,B,1,3,,,,,,,,,,,,,,,
|
82 |
-
II.35.21,10,81,M,n_rho*mom*tanh(mom*B/(kb*T)),5,n_rho,1,5,mom,1,5,B,1,5,kb,1,5,T,1,5,,,,,,,,,,,,,,,
|
83 |
-
II.36.38,10,82,f,mom*H/(kb*T)+(mom*alpha)/(epsilon*c**2*kb*T)*M,8,mom,1,3,H,1,3,kb,1,3,T,1,3,alpha,1,3,epsilon,1,3,c,1,3,M,1,3,,,,,,
|
84 |
-
II.37.1,10,83,E_n,mom*(1+chi)*B,3,mom,1,5,B,1,5,chi,1,5,,,,,,,,,,,,,,,,,,,,,
|
85 |
-
II.38.3,10,84,F,Y*A*x/d,4,Y,1,5,A,1,5,d,1,5,x,1,5,,,,,,,,,,,,,,,,,,
|
86 |
-
II.38.14,10,85,mu_S,Y/(2*(1+sigma)),2,Y,1,5,sigma,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
87 |
-
III.4.32,10,86,n,1/(exp((h/(2*pi))*omega/(kb*T))-1),4,h,1,5,omega,1,5,kb,1,5,T,1,5,,,,,,,,,,,,,,,,,,
|
88 |
-
III.4.33,10,87,E_n,(h/(2*pi))*omega/(exp((h/(2*pi))*omega/(kb*T))-1),4,h,1,5,omega,1,5,kb,1,5,T,1,5,,,,,,,,,,,,,,,,,,
|
89 |
-
III.7.38,10,88,omega,2*mom*B/(h/(2*pi)),3,mom,1,5,B,1,5,h,1,5,,,,,,,,,,,,,,,,,,,,,
|
90 |
-
III.8.54,10,89,prob,sin(E_n*t/(h/(2*pi)))**2,3,E_n,1,2,t,1,2,h,1,4,,,,,,,,,,,,,,,,,,,,,
|
91 |
-
III.9.52,1000,90,prob,(p_d*Ef*t/(h/(2*pi)))*sin((omega-omega_0)*t/2)**2/((omega-omega_0)*t/2)**2,6,p_d,1,3,Ef,1,3,t,1,3,h,1,3,omega,1,5,omega_0,1,5,,,,,,,,,,,,
|
92 |
-
III.10.19,100,91,E_n,mom*sqrt(Bx**2+By**2+Bz**2),4,mom,1,5,Bx,1,5,By,1,5,Bz,1,5,,,,,,,,,,,,,,,,,,
|
93 |
-
III.12.43,10,92,L,n*(h/(2*pi)),2,n,1,5,h,1,5,,,,,,,,,,,,,,,,,,,,,,,,
|
94 |
-
III.13.18,10,93,v,2*E_n*d**2*k/(h/(2*pi)),4,E_n,1,5,d,1,5,k,1,5,h,1,5,,,,,,,,,,,,,,,,,,
|
95 |
-
III.14.14,10,94,I,I_0*(exp(q*Volt/(kb*T))-1),5,I_0,1,5,q,1,2,Volt,1,2,kb,1,2,T,1,2,,,,,,,,,,,,,,,
|
96 |
-
III.15.12,10,95,E_n,2*U*(1-cos(k*d)),3,U,1,5,k,1,5,d,1,5,,,,,,,,,,,,,,,,,,,,,
|
97 |
-
III.15.14,10,96,m,(h/(2*pi))**2/(2*E_n*d**2),3,h,1,5,E_n,1,5,d,1,5,,,,,,,,,,,,,,,,,,,,,
|
98 |
-
III.15.27,10,97,k,2*pi*alpha/(n*d),3,alpha,1,5,n,1,5,d,1,5,,,,,,,,,,,,,,,,,,,,,
|
99 |
-
III.17.37,10,98,f,beta*(1+alpha*cos(theta)),3,beta,1,5,alpha,1,5,theta,1,5,,,,,,,,,,,,,,,,,,,,,
|
100 |
-
III.19.51,10,99,E_n,-m*q**4/(2*(4*pi*epsilon)**2*(h/(2*pi))**2)*(1/n**2),5,m,1,5,q,1,5,h,1,5,n,1,5,epsilon,1,5,,,,,,,,,,,,,,,
|
101 |
-
III.21.20,10,100,j,-rho_c_0*q*A_vec/m,4,rho_c_0,1,5,q,1,5,A_vec,1,5,m,1,5,,,,,,,,,,,,,,,,,,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pysr/__init__.py
CHANGED
@@ -2,7 +2,6 @@ from . import sklearn_monkeypatch
|
|
2 |
from .deprecated import best, best_callable, best_row, best_tex, pysr
|
3 |
from .export_jax import sympy2jax
|
4 |
from .export_torch import sympy2torch
|
5 |
-
from .feynman_problems import FeynmanProblem, Problem
|
6 |
from .sr import PySRRegressor, jl
|
7 |
|
8 |
# This file is created by setuptools_scm during the build process:
|
@@ -12,7 +11,6 @@ __all__ = [
|
|
12 |
"sklearn_monkeypatch",
|
13 |
"sympy2jax",
|
14 |
"sympy2torch",
|
15 |
-
"FeynmanProblem",
|
16 |
"Problem",
|
17 |
"install",
|
18 |
"PySRRegressor",
|
|
|
2 |
from .deprecated import best, best_callable, best_row, best_tex, pysr
|
3 |
from .export_jax import sympy2jax
|
4 |
from .export_torch import sympy2torch
|
|
|
5 |
from .sr import PySRRegressor, jl
|
6 |
|
7 |
# This file is created by setuptools_scm during the build process:
|
|
|
11 |
"sklearn_monkeypatch",
|
12 |
"sympy2jax",
|
13 |
"sympy2torch",
|
|
|
14 |
"Problem",
|
15 |
"install",
|
16 |
"PySRRegressor",
|
pysr/feynman_problems.py
DELETED
@@ -1,176 +0,0 @@
|
|
1 |
-
import csv
|
2 |
-
from functools import partial
|
3 |
-
from pathlib import Path
|
4 |
-
|
5 |
-
import numpy as np
|
6 |
-
|
7 |
-
from .deprecated import best, pysr
|
8 |
-
|
9 |
-
PKG_DIR = Path(__file__).parents[1]
|
10 |
-
FEYNMAN_DATASET = PKG_DIR / "datasets" / "FeynmanEquations.csv"
|
11 |
-
|
12 |
-
|
13 |
-
class Problem:
|
14 |
-
"""
|
15 |
-
Problem API to work with PySR.
|
16 |
-
|
17 |
-
Has attributes: X, y as pysr accepts, form which is a string representing the correct equation and variable_names
|
18 |
-
|
19 |
-
Should be able to call pysr(problem.X, problem.y, var_names=problem.var_names) and have it work
|
20 |
-
"""
|
21 |
-
|
22 |
-
def __init__(self, X, y, form=None, variable_names=None):
|
23 |
-
self.X = X
|
24 |
-
self.y = y
|
25 |
-
self.form = form
|
26 |
-
self.variable_names = variable_names
|
27 |
-
|
28 |
-
|
29 |
-
class FeynmanProblem(Problem):
|
30 |
-
"""
|
31 |
-
Stores the data for the problems from the 100 Feynman Equations on Physics.
|
32 |
-
This is the benchmark used in the AI Feynman Paper
|
33 |
-
"""
|
34 |
-
|
35 |
-
def __init__(self, row, gen=False, dp=500):
|
36 |
-
"""
|
37 |
-
row: a row read as a dict from the FeynmanEquations dataset provided in the datasets folder of the repo
|
38 |
-
gen: If true the problem will have dp X and y values randomly generated else they will be None
|
39 |
-
"""
|
40 |
-
self.eq_id = row["Filename"]
|
41 |
-
self.n_vars = int(row["# variables"])
|
42 |
-
super(FeynmanProblem, self).__init__(
|
43 |
-
None,
|
44 |
-
None,
|
45 |
-
form=row["Formula"],
|
46 |
-
variable_names=[row[f"v{i + 1}_name"] for i in range(self.n_vars)],
|
47 |
-
)
|
48 |
-
self.low = [float(row[f"v{i+1}_low"]) for i in range(self.n_vars)]
|
49 |
-
self.high = [float(row[f"v{i+1}_high"]) for i in range(self.n_vars)]
|
50 |
-
self.dp = dp
|
51 |
-
if gen:
|
52 |
-
self.X = np.random.uniform(0.01, 25, size=(self.dp, self.n_vars))
|
53 |
-
d = {}
|
54 |
-
for var in range(len(self.variable_names)):
|
55 |
-
d[self.variable_names[var]] = self.X[:, var]
|
56 |
-
d["exp"] = np.exp
|
57 |
-
d["sqrt"] = np.sqrt
|
58 |
-
d["pi"] = np.pi
|
59 |
-
d["cos"] = np.cos
|
60 |
-
d["sin"] = np.sin
|
61 |
-
d["tan"] = np.tan
|
62 |
-
d["tanh"] = np.tanh
|
63 |
-
d["ln"] = np.log
|
64 |
-
d["log"] = np.log # Quite sure the Feynman dataset has no base 10 logs
|
65 |
-
d["arcsin"] = np.arcsin
|
66 |
-
self.y = eval(self.form, d)
|
67 |
-
|
68 |
-
def __str__(self):
|
69 |
-
return f"Feynman Equation: {self.eq_id}|Form: {self.form}"
|
70 |
-
|
71 |
-
def __repr__(self):
|
72 |
-
return str(self)
|
73 |
-
|
74 |
-
|
75 |
-
def mk_problems(first=100, gen=False, dp=500, data_dir=FEYNMAN_DATASET):
|
76 |
-
"""
|
77 |
-
|
78 |
-
first: the first "first" equations from the dataset will be made into problems
|
79 |
-
data_dir: the path pointing to the Feynman Equations csv
|
80 |
-
returns: list of FeynmanProblems
|
81 |
-
"""
|
82 |
-
ret = []
|
83 |
-
with open(data_dir) as csvfile:
|
84 |
-
reader = csv.DictReader(csvfile)
|
85 |
-
for i, row in enumerate(reader):
|
86 |
-
if i > first:
|
87 |
-
break
|
88 |
-
if row["Filename"] == "":
|
89 |
-
continue
|
90 |
-
p = FeynmanProblem(row, gen=gen, dp=dp)
|
91 |
-
ret.append(p)
|
92 |
-
return ret
|
93 |
-
|
94 |
-
|
95 |
-
def run_on_problem(problem, verbosity=0, multiprocessing=True):
|
96 |
-
"""
|
97 |
-
Takes in a problem and returns a tuple: (equations, best predicted equation, actual equation)
|
98 |
-
"""
|
99 |
-
from time import time
|
100 |
-
|
101 |
-
starting = time()
|
102 |
-
equations = pysr(
|
103 |
-
problem.X,
|
104 |
-
problem.y,
|
105 |
-
variable_names=problem.variable_names,
|
106 |
-
verbosity=verbosity,
|
107 |
-
)
|
108 |
-
timing = time() - starting
|
109 |
-
others = {"time": timing, "problem": problem}
|
110 |
-
if not multiprocessing:
|
111 |
-
others["equations"] = equations
|
112 |
-
return str(best(equations)), problem.form, others
|
113 |
-
|
114 |
-
|
115 |
-
def do_feynman_experiments_parallel(
|
116 |
-
first=100,
|
117 |
-
verbosity=0,
|
118 |
-
dp=500,
|
119 |
-
output_file_path="FeynmanExperiment.csv",
|
120 |
-
data_dir=FEYNMAN_DATASET,
|
121 |
-
):
|
122 |
-
import multiprocessing as mp
|
123 |
-
|
124 |
-
from tqdm import tqdm
|
125 |
-
|
126 |
-
problems = mk_problems(first=first, gen=True, dp=dp, data_dir=data_dir)
|
127 |
-
ids = []
|
128 |
-
predictions = []
|
129 |
-
true_equations = []
|
130 |
-
time_takens = []
|
131 |
-
pool = mp.Pool()
|
132 |
-
results = []
|
133 |
-
with tqdm(total=len(problems)) as pbar:
|
134 |
-
f = partial(run_on_problem, verbosity=verbosity)
|
135 |
-
for i, res in enumerate(pool.imap(f, problems)):
|
136 |
-
results.append(res)
|
137 |
-
pbar.update()
|
138 |
-
for res in results:
|
139 |
-
prediction, true_equation, others = res
|
140 |
-
problem = others["problem"]
|
141 |
-
ids.append(problem.eq_id)
|
142 |
-
predictions.append(prediction)
|
143 |
-
true_equations.append(true_equation)
|
144 |
-
time_takens.append(others["time"])
|
145 |
-
with open(output_file_path, "a") as f:
|
146 |
-
writer = csv.writer(f, delimiter=",")
|
147 |
-
writer.writerow(["ID", "Predicted", "True", "Time"])
|
148 |
-
for i in range(len(ids)):
|
149 |
-
writer.writerow([ids[i], predictions[i], true_equations[i], time_takens[i]])
|
150 |
-
|
151 |
-
|
152 |
-
def do_feynman_experiments(
|
153 |
-
first=100,
|
154 |
-
verbosity=0,
|
155 |
-
dp=500,
|
156 |
-
output_file_path="FeynmanExperiment.csv",
|
157 |
-
data_dir=FEYNMAN_DATASET,
|
158 |
-
):
|
159 |
-
from tqdm import tqdm
|
160 |
-
|
161 |
-
problems = mk_problems(first=first, gen=True, dp=dp, data_dir=data_dir)
|
162 |
-
ids = []
|
163 |
-
predictions = []
|
164 |
-
true_equations = []
|
165 |
-
time_takens = []
|
166 |
-
for problem in tqdm(problems):
|
167 |
-
prediction, true_equation, others = run_on_problem(problem, verbosity)
|
168 |
-
ids.append(problem.eq_id)
|
169 |
-
predictions.append(prediction)
|
170 |
-
true_equations.append(true_equation)
|
171 |
-
time_takens.append(others["time"])
|
172 |
-
with open(output_file_path, "a") as f:
|
173 |
-
writer = csv.writer(f, delimiter=",")
|
174 |
-
writer.writerow(["ID", "Predicted", "True", "Time"])
|
175 |
-
for i in range(len(ids)):
|
176 |
-
writer.writerow([ids[i], predictions[i], true_equations[i], time_takens[i]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|