Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug on PyCall's master only (after dot overloading merged)? #636

Closed
PallHaraldsson opened this issue Jan 24, 2019 · 16 comments · Fixed by #647
Closed

Bug on PyCall's master only (after dot overloading merged)? #636

PallHaraldsson opened this issue Jan 24, 2019 · 16 comments · Fixed by #647

Comments

@PallHaraldsson
Copy link
Contributor

PallHaraldsson commented Jan 24, 2019

Minimal example, this works on PyCall, just not its master (when warnings display, but that seems not to be the problem as ok with Python 2.7):

julia> using PyPlot
[ Info: Recompiling stale cache file /home/qwerty/.julia/compiled/v1.2/PyPlot/oatAj.ji for PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]

julia> plot()
0-element Array{Any,1}

By now, most of the discussion below is invalid (from a time I got errors, not just warnings, so must have done things differently), applied to:

I'm just trying it out (that worked with older PyCall; and older Julia, 0.6 I think):

cstjean/ScikitLearn.jl#51 (comment)

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Jan 24, 2019

I'm not sure what I should report more, I could exact versions, but doubt they matter for anything else that PyCall.

I doubt it matters but I'm on Julia 1.2 (on Ubuntu 18.04.1). I guess I'm on PyCall's master, or whatever you get with add then using PyCall (I also did build for 2.7). I'm not sure how I get the exact PyCall version number or tag or commit or whatever, but at least:

julia> pyversion
v"2.7.15-rc1"

I probably never had to change from Python 3 (but either should work?!), just did when I ran into trouble that was I guess unrelated.

@stevengj
Copy link
Member

stevengj commented Jan 24, 2019

You don't get PyCall's master when you add PyCall, you get the latest released version. If you type status at the Pkg prompt it will tell you which package versions you are using.

If you type free PyCall at the Pkg prompt it will go back to the latest release version — do you get the same error about NULL PyObject there?

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Jan 28, 2019

You don't get PyCall's master when you add PyCall, you get the latest released version.

Thanks, for some reason, it seems however I was using master:

(v1.2) pkg> status
Status ~/.julia/environments/v1.2/Project.toml
[6e4b80f9] BenchmarkTools v0.4.2
[54eb57ff] InteractiveCodeSearch v0.3.0
[438e738f] PyCall v1.18.5+ #master (https://github.com/JuliaPy/PyCall.jl)
[d330b81b] PyPlot v2.7.0
[e6cf234a] RandomNumbers v1.0.3
[3646fa90] ScikitLearn v0.5.0
[98e33af6] SimpleDirectMediaLayer v0.1.0
[276daf66] SpecialFunctions v0.7.2
[9a3f8284] Random

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Jan 28, 2019

I do not get any errors on (non-master) v1.18.5 (with Python 2).

I also got this to work with Conda/Python 3, and without Conda should be able to work too.

@PallHaraldsson PallHaraldsson changed the title Bug in latest PyCall (after dot overloading merged)? Bug PyCall's master (after dot overloading merged)? Jan 28, 2019
@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Jan 28, 2019

I no longer get the errors I got on master, while I do get lots of warnings and actually don't get any plot displayed (note, it worked before with Conda, before trying master). Either I did something differently or master has changed recently (if you revered for me, I may have done something wrong the first time):

julia> pyversion
v"3.7.1"

(v1.2) pkg> status
[..]
  [438e738f] PyCall v1.18.5+ #master (https://github.com/JuliaPy/PyCall.jl.git)


julia> using PyPlot 
[ Info: Recompiling stale cache file /home/qwerty/.julia/compiled/v1.2/PyPlot/oatAj.ji for PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]
┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = __init__() at init.jl:175

[..]

julia> imshow(Z, interpolation="nearest",
               extent=(minimum(xx), maximum(xx), minimum(yy), maximum(yy)),
              cmap=PyPlot.cm[:Paired],
              aspect="auto", origin="lower")
┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = top-level scope at none:0
└ @ Core none:0
┌ Warning: `haskey(o::PyObject, s::Union{Symbol, AbstractString})` is deprecated, use `hasproperty(o, s)` instead.
│   caller = #imshow#67(::Base.Iterators.Pairs{Symbol,Any,NTuple{5,Symbol},NamedTuple{(:interpolation, :extent, :cmap, :aspect, :origin),Tuple{String,NTuple{4,Float64},ColorMap,String,String}}}, ::Function, ::Array{Int32,2}) at PyPlot.jl:176
└ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/PyPlot.jl:176
┌ Warning: `getindex(o::PyObject, s::AbstractString)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o."s"` instead of `o["s"]`.
│   caller = #imshow#67(::Base.Iterators.Pairs{Symbol,Any,NTuple{5,Symbol},NamedTuple{(:interpolation, :extent, :cmap, :aspect, :origin),Tuple{String,NTuple{4,Float64},ColorMap,String,String}}}, ::Function, ::Array{Int32,2}) at PyPlot.jl:179
└ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/PyPlot.jl:179
PyObject <matplotlib.image.AxesImage object at 0x7f6ff63dc6d8>

julia> plot(reduced_data[:, 1], reduced_data[:, 2], "k.", markersize=2)
┌ Warning: `haskey(o::PyObject, s::Union{Symbol, AbstractString})` is deprecated, use `hasproperty(o, s)` instead.
│   caller = #plot#85(::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:markersize,),Tuple{Int64}}}, ::Function, ::Array{Float64,1}, ::Vararg{Any,N} where N) at PyPlot.jl:176
└ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/PyPlot.jl:176
┌ Warning: `getindex(o::PyObject, s::AbstractString)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o."s"` instead of `o["s"]`.
│   caller = #plot#85(::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:markersize,),Tuple{Int64}}}, ::Function, ::Array{Float64,1}, ::Vararg{Any,N} where N) at PyPlot.jl:179
└ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/PyPlot.jl:179
1-element Array{PyObject,1}:
 PyObject <matplotlib.lines.Line2D object at 0x7f6ff6664cc0>

[..]

@PallHaraldsson PallHaraldsson changed the title Bug PyCall's master (after dot overloading merged)? Bug on PyCall's master only (after dot overloading merged)? Jan 28, 2019
@PallHaraldsson
Copy link
Contributor Author

(v1.2) pkg> status
[..]
[438e738f] PyCall v1.18.5+ #master (https://github.com/JuliaPy/PyCall.jl.git)

I would have thought this to be the git commit, and since it's the same on master, and when I'm not on it, I would have thought I'm using the same code either way. So I'm confused why I don't get the plot on master (I've tried twice now).

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Jan 28, 2019

I did try master with:

julia> pyversion
v"2.7.15-rc1"

and then I get the plot (and the warnings), so not sure why I don't get it with master and Conda.

@PallHaraldsson
Copy link
Contributor Author

There's a workaround in the PyPlot thread, but should it be needed?

@stevengj
Copy link
Member

stevengj commented Feb 9, 2019

I can reproduce this on my machine. I agree that it shouldn't be needed — it should work, albeit with lots of deprecation warnings.

@stevengj stevengj mentioned this issue Feb 9, 2019
5 tasks
@stevengj
Copy link
Member

stevengj commented Feb 9, 2019

It appears to be a problem with the backend detection — PyPlot.backend is "Agg" (a non-gui fallback backend).

@tkf
Copy link
Member

tkf commented Feb 13, 2019

I needed to switch to Python environment with qt5agg to reproduce this issue. If what you guys were seeing was Qt related, I think #647 should fix it.

@tkf
Copy link
Member

tkf commented Feb 15, 2019

@PallHaraldsson You can now try PyCall master to see if it's fixed.

@stevengj
Copy link
Member

It fixes the problem for me.

@kapple19
Copy link

Hi everyone,

I don't quite understand how you guys fixed the warnings. Help?

I'm using Symata and get the following in the REPL.

symata 1> Expand((a + b)^2)┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = _sjtopy(::Symbol) at sympy.jl:754
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy.jl:754┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = apprules(::Mxpr{:Expand}) at sympy_application.jl:17
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy_application.jl:17┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = _pytosj(::PyCall.PyObject) at sympy.jl:399
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy.jl:399┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = _pytosj(::PyCall.PyObject) at sympy.jl:408
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy.jl:408┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = _pytosj(::PyCall.PyObject) at sympy.jl:416
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy.jl:416┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = _pytosj(::PyCall.PyObject) at sympy.jl:422
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy.jl:422┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = _pytosj(::PyCall.PyObject) at sympy.jl:425
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy.jl:425┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = _pytosj(::PyCall.PyObject) at sympy.jl:431
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy.jl:431┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│   caller = _pytosj(::PyCall.PyObject) at sympy.jl:412
└ @ Symata C:\Users\T0185914\.julia\packages\Symata\1oDeR\src\sympy.jl:412Out(1) = a^2 + 2a*b + b^2

@tkf
Copy link
Member

tkf commented Jul 12, 2019

You need to open an issue in https://github.com/jlapeyre/Symata.jl so that they can update the code.

@kapple19
Copy link

I see. I thought my issue here is the same as what was discussed and resolved above.

I'll do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants