Skip to content

Commit 0796d8b

Browse files
authored
Merge pull request #6 from stevengj/pyhasattr
use pyhasattr instead of hasproperty
2 parents 69a320e + d58f6c4 commit 0796d8b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/PythonPlot.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function Base.show(io::IO, ::MIME"text/plain", h::LazyHelp)
3636
for k in h.keys
3737
o = pygetattr(o, k)
3838
end
39-
if hasproperty(o, :__doc__)
39+
if pyhasattr(o, "__doc__")
4040
print(io, pyconvert(String, o.__doc__))
4141
else
4242
print(io, "no Python docstring found for ", o)
@@ -76,7 +76,7 @@ Base.getproperty(f::Figure, s::Symbol) = getproperty(Py(f), s)
7676
Base.getproperty(f::Figure, s::AbstractString) = getproperty(f, Symbol(s))
7777
Base.setproperty!(f::Figure, s::Symbol, x) = setproperty!(Py(f), s, x)
7878
Base.setproperty!(f::Figure, s::AbstractString, x) = setproperty!(f, Symbol(s), x)
79-
Base.hasproperty(f::Figure, s::Symbol) = hasproperty(Py(f), s)
79+
Base.hasproperty(f::Figure, s::Symbol) = pyhasattr(Py(f), s)
8080
Base.propertynames(f::Figure) = propertynames(Py(f))
8181

8282
for (mime,fmt) in aggformats
@@ -175,10 +175,10 @@ const plt_funcs = (:acorr,:annotate,:arrow,:autoscale,:autumn,:axes,:axhline,:ax
175175
for f in plt_funcs
176176
sf = string(f)
177177
@eval @doc LazyHelp(pyplot,$sf) function $f(args...; kws...)
178-
if !hasproperty(pyplot, $(QuoteNode(f)))
178+
if !pyhasattr(pyplot, $sf)
179179
error("matplotlib ", version, " does not have pyplot.", $sf)
180180
end
181-
return pycall(pyplot.$f, args...; kws...)
181+
return pycall(pyplot.$sf, args...; kws...)
182182
end
183183
end
184184

src/colormaps.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Base.getproperty(c::ColorMap, s::AbstractString) = getproperty(Py(c), Symbol(s))
2626
Base.setproperty!(c::ColorMap, s::Symbol, x) = setproperty!(Py(c), s, x)
2727
Base.setproperty!(c::ColorMap, s::AbstractString, x) = setproperty!(Py(c), Symbol(s), x)
2828
Base.propertynames(c::ColorMap) = propertynames(Py(c))
29-
Base.hasproperty(c::ColorMap, s::Union{Symbol,AbstractString}) = hasproperty(Py(c), s)
29+
Base.hasproperty(c::ColorMap, s::Union{Symbol,AbstractString}) = pyhasattr(Py(c), s)
3030

3131
function Base.show(io::IO, c::ColorMap)
3232
print(io, "ColorMap \"$(pyconvert(String, c.name))\"")

src/plot3d.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PythonCall.Py(m::LazyPyModule) = _ispynull(getfield(m, :o)) ? PythonCall.pycopy!
1212
Base.Docs.doc(m::LazyPyModule) = Base.Docs.Text(pyconvert(String, Py(m).__doc__))
1313
Base.getproperty(m::LazyPyModule, x::Symbol) = getproperty(Py(m), x)
1414
Base.setproperty!(m::LazyPyModule, x::Symbol, v) = setproperty!(Py(m), x, v)
15-
Base.hasproperty(m::LazyPyModule, x::Symbol) = PyCall.hasproperty(Py(m), x)
15+
Base.hasproperty(m::LazyPyModule, x::Symbol) = pyhasattr(Py(m), x)
1616
Base.propertynames(m::LazyPyModule) = propertynames(Py(m))
1717

1818
###########################################################################

0 commit comments

Comments
 (0)