Skip to content

Commit

Permalink
add test 4 peak-shift
Browse files Browse the repository at this point in the history
  • Loading branch information
yakir12 committed Jul 29, 2022
1 parent 39b4f91 commit 253dbcd
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ begin # empty eeg topoplot
@test_figure("nullInterpolator", f)
end

@testset "peaks" begin
# 4 coordinates with one peak
positions = Point2f[(-1, 0), (0, -1), (1, 0), (0, 1)]
i = 1
peak_xy = positions[i]
data = zeros(length(positions))
data[i] = 1
fig = topoplot(data, positions)
# tighten the limits so that the limits of the axis and the data will match
tightlimits!(fig.axis)

# retrieve the interpolated data
m = fig.plot.plots[].color[]
# get the limits of the axes and data
rect = fig.axis.targetlimits[]
minx, miny = minimum(rect)
maxx, maxy = maximum(rect)
# recreate the coordinates of the data
x = range(minx, maxx, length=size(m, 1))
y = range(miny, maxy, length=size(m, 2))
xys = Point2f.(x, y')

# find the highest point
_, i = findmax(x -> isnan(x) ? -Inf : x, m)
xy = xys[i]
@test isapprox(xy, peak_xy; atol=0.02)
end

# begin
# f = Figure(resolution=(1000, 1000))
# s = Slider(f[:, 1], range=1:size(data, 2), startvalue=351)
Expand Down

0 comments on commit 253dbcd

Please sign in to comment.