SymPy.jl icon indicating copy to clipboard operation
SymPy.jl copied to clipboard

hiding `import_from` preamble to a submodule?

Open mmikhasenko opened this issue 5 years ago • 3 comments

In order to use Clebsch-Gordan coefficients (clebsch_gordan) and Wigner D (WignerD), I have to start my notebook with the 8 lines block.

using SymPy
import PyCall
#
PyCall.pyimport_conda("sympy.physics.quantum.spin", "sympy")
PyCall.pyimport_conda("sympy.physics.wigner",       "sympy")

import_from(sympy.physics.quantum.spin, (:WignerD,), typ=:Any)
import_from(sympy.physics.wigner)
import_from(sympy.physics.quantum.spin)

I would love to have it defined in the package and just use using SymPy.Physics or using SymPy.Spin, or something similar. Any good suggestions?

mmikhasenko avatar Nov 14 '20 11:11 mmikhasenko

We have https://github.com/JuliaPy/SymPy.jl/blob/master/src/physics.jl but that is just a start. What might be best would be to make that a submodule (so it has its own namespace, as you suggest) and add more conveniences in that.

jverzani avatar Nov 14 '20 12:11 jverzani

great. Accept PR? Something in this spirit?

module Spin

using SymPy
import PyCall
#
# include("wigner_functions.jl")
PyCall.pyimport_conda("sympy.physics.quantum.spin", "sympy")
import_from(sympy.physics.quantum.spin, (:WignerD,), typ=:Any)
#
export clebsch_gordan
#
# include("clebshes.jl")
PyCall.pyimport_conda("sympy.physics.wigner",       "sympy")
import_from(sympy.physics.wigner)
#
wignerD(j,m1,m2,alpha,beta,gamma) = WignerD(j,m1,m2,alpha,beta,gamma).doit()
wignerd(j,m1,m2,theta) = WignerD(j,m1,m2,0,theta,0).doit()
#
export wignerD, wignerd

end

mmikhasenko avatar Nov 14 '20 18:11 mmikhasenko

Yes, along those lines.

On Sat, Nov 14, 2020 at 1:11 PM Misha Mikhasenko [email protected] wrote:

great. Accept PR? Something in this spirit?

module Spin using SymPyimport PyCall## include("wigner_functions.jl") PyCall.pyimport_conda("sympy.physics.quantum.spin", "sympy")import_from(sympy.physics.quantum.spin, (:WignerD,), typ=:Any)#export clebsch_gordan## include("clebshes.jl") PyCall.pyimport_conda("sympy.physics.wigner", "sympy")import_from(sympy.physics.wigner)#WignerD(j,m1,m2,theta) = WignerD(j,m1,m2,0,theta,0).doit()Wignerd(j,m1,m2,theta) = WignerD(j,m1,m2,0,theta,0).doit()#export WignerD, Wignerd end

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/JuliaPy/SymPy.jl/issues/385#issuecomment-727244927, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADG6TEND7USWJF2I3KOHITSP3B3TANCNFSM4TVQDE7Q .

-- John Verzani Department of Mathematics College of Staten Island, CUNY [email protected]

jverzani avatar Nov 14 '20 18:11 jverzani