Skip to content

Commit

Permalink
Fix SCPyPlotExt
Browse files Browse the repository at this point in the history
The `SCPyPlotExt` had two problems:

- the default argument to `pdata` is `Profile.fetch()`, but `Profile`
was not imported
- the extension was not adding methods to `SnoopCompile.pgdsgui`

As a result, the tutorial on `pgdsgui` was broken.

This commit fixes both of these issues.
  • Loading branch information
Sbozzolo committed Oct 13, 2024
1 parent 5be5369 commit bba45ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ext/SCPyPlotExt.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module SCPyPlotExt

import Profile

using SnoopCompile
using SnoopCompile: MethodLoc, InferenceTimingNode, PGDSData, lookups
using PyPlot: PyPlot, plt, PyCall

get_bystr(@nospecialize(by)) = by === inclusive ? "Inclusive" :
by === exclusive ? "Exclusive" : error("unknown ", by)

function pgdsgui(ax::PyCall.PyObject, ridata::AbstractVector{Pair{Union{Method,MethodLoc},PGDSData}}; bystr, consts, markersz=25, linewidth=0.5, t0 = 0.001, interactive::Bool=true, kwargs...)
function SnoopCompile.pgdsgui(ax::PyCall.PyObject, ridata::AbstractVector{Pair{Union{Method,MethodLoc},PGDSData}}; bystr, consts, markersz=25, linewidth=0.5, t0 = 0.001, interactive::Bool=true, kwargs...)
methodref = Ref{Union{Method,MethodLoc}}() # returned to the user for inspection of clicked methods
function onclick(event)
xc, yc = event.xdata, event.ydata
Expand Down Expand Up @@ -48,11 +50,11 @@ function pgdsgui(ax::PyCall.PyObject, ridata::AbstractVector{Pair{Union{Method,M
return methodref
end

function pgdsgui(ax::PyCall.PyObject, args...; consts::Bool=true, by=inclusive, kwargs...)
function SnoopCompile.pgdsgui(ax::PyCall.PyObject, args...; consts::Bool=true, by=inclusive, kwargs...)
pgdsgui(ax, prep_ri(args...; consts, by, kwargs...); bystr=get_bystr(by), consts, kwargs...)
end

function pgdsgui(args...; kwargs...)
function SnoopCompile.pgdsgui(args...; kwargs...)
fig, ax = plt.subplots()
pgdsgui(ax, args...; kwargs...), ax
end
Expand Down
2 changes: 1 addition & 1 deletion src/SnoopCompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ that method.
`ax` is the pyplot axis of the scatterplot.
!!! compat
`pgdsgui` depends on PyPlot via the Requires.jl package. You must load both SnoopCompile and PyPlot for this function to be defined.
`pgdsgui` depends on PyPlot via Julia extensions. You must load both SnoopCompile and PyPlot for this function to be defined.
"""
function pgdsgui end
export pgdsgui
Expand Down

0 comments on commit bba45ea

Please sign in to comment.