-
Notifications
You must be signed in to change notification settings - Fork 9
/
generate_constants.jl
35 lines (31 loc) · 1010 Bytes
/
generate_constants.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import SciPy
using SciPy.PyCall
const _ignore_funcs = ["constants"]
pyimport_conda("scipy", "scipy")
@pyinclude(joinpath(pkgdir(SciPy), "src", "scipy_api_list.py"))
apis = py"generate_scipy_apis"("constants")
all_properties = [apis["function"]; apis["class"]]
open(joinpath(@__DIR__, "src", "scipy_constants.jl"), "w") do io
for f in [apis["function"]; apis["class"]]
f in _ignore_funcs && continue
sf = Symbol(f)
h = SciPy.LazyHelp(pyconstants, f)
println(io, """
\"\"\"
$(strip(string(h)))
\"\"\"
$sf(args...; kws...) = pycall(pyconstants.$f, PyAny, args...; kws...)
""")
end
for f in pyconstants.__all__ |> unique |> sort
f in _ignore_funcs && continue # just in case
sf = Symbol(f)
help = SciPy.LazyHelp(pyconstants, f)
a = pybuiltin("getattr")(pyconstants, f)
a isa PyObject && continue
str = """
const $sf = $a
"""
println(io, str)
end
end