JuliaPy / JuliaPy/SymPy.jl

`pyimport_conda` yields `PyObject NULL`

Open
#301 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
282
Forks
59
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm hitting a bug I'm having some trouble replicating, hope you might be able to steer me in the right direction.

At a very high level, the problem happens when I
1. Import `sympy.stats` in the standard way within my package
1. `using Soss` (my package) externally
1. Make a call involving `stats`

Result:
```julia
julia> Soss.stats
PyObject NULL
```
In some cases, this triggers a segfault.

---

For context, I've tried this in both Julia 1.2 and 1.3.

Also, the following works with no trouble:
```julia
# in a file
module M
import PyCall
import SymPy
using SymPy: Sym, sympy, symbols

export SymPy, stats, symbols

stats = PyCall.pyimport_conda("sympy.stats", "sympy")
SymPy.import_from(stats)

import Distributions.Normal
export Normal
Normal(μ::Sym, σ::Sym) = stats.Normal(:Normal, μ,σ) |> SymPy.density
Normal(μ,σ) = Normal(promote(μ,σ)...)
end

using Distributions
using .M

stats.Normal(:Normal, symbols(:μ),1) |> SymPy.density
Normal(symbols(:μ),1)

# in the REPL
julia> stats.Normal(:Normal, symbols(:μ),1) |> SymPy.density
NormalDistribution(μ, 1)

julia> Normal(symbols(:μ),1)
NormalDistribution(μ, 1)
```

The code in [symbolic.jl](https://github.com/cscherrer/Soss.jl/blob/925a28105a819198f59a96980fa48415748e51f8/src/symbolic.jl) takes this same approach. But when I try from a fresh environment, ...

```julia
(Soss#dev) pkg> add Soss#dev
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Updating git-repo `https://github.com/cscherrer/Soss.jl.git`
Resolving package versions...
Updating `~/Soss#dev/Project.toml`
[8ce77f84] + Soss v0.6.0 #dev (https://github.com/cscherrer/Soss.jl.git)
Updating `~/Soss#dev/Manifest.toml`
... (other dependencies)
[8f4d0f93] + Conda v1.3.0
[24249f21] + SymPy v1.0.7

julia> using Soss
[ Info: Recompiling stale cache file /home/chad/.julia/compiled/v1.2/Soss/vXX0U.ji for Soss [8ce77f84-9b61-11e8-39ff-d17a774bf41c]

# *LOTS* OF THESE
WARNING: eval into closed module SymPy:
Expr(:block, #= Symbol("/home/chad/.julia/packages/SymPy/1Cwgd/src/utils.jl"):252 =#, Expr(:call, :P, Expr(:parameters, Expr(:..., :kwargs)), Expr(:::, :ex, :SymbolicObject), Expr(:..., :args)) = Expr(:block, #= Symbol("/home/chad/.julia/packages/SymPy/1Cwgd/src/utils.jl"):252 =#, Expr(:call, Expr(:call, :getproperty, PyCall.PyObject(o=0x00007f6c2c085778), "P"), Expr(:parameters, Expr(:..., :kwargs)), :ex, Expr(:..., :args))))
** incremental compilation may be fatally broken for this module **

julia> Soss.stats
PyObject NULL
```

Any ideas?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.