Skip to content

Commit

Permalink
Update histogram whenever enabled changes state (fixes #168) (#172)
Browse files Browse the repository at this point in the history
We make `enabled` an unused dependency of the histogram-calculating code, thus ensuring it updates.
  • Loading branch information
timholy authored Apr 22, 2019
1 parent 26e8e3d commit 56e999d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ImageView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ default_axes(img::AxisArray) = axisnames(img)[[1,2]]
# default_slices(img) = ntuple(d->PlayerInfo(Signal(1), axes(img, d+2)), ndims(img)-2)

function histsignals(enabled::Signal, defaultimg, img::Signal, clim::Signal{CLim{T}}) where {T<:GrayLike}
return [map(filterwhen(enabled, defaultimg, img); name="histsig") do image
return [map(filterwhen(enabled, defaultimg, img), enabled; name="histsig") do image, _ # `enabled` fixes issue #168
cl = value(clim)
smin = float(nanz(min(minfinite(image), cl.min)))
smax = float(nanz(max(maxfinite(image), cl.max)))
Expand Down
7 changes: 7 additions & 0 deletions test/contrast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@ using Test
@test isa(ret, Dict)
Gtk.destroy(ret["window"])
end
# issue #168
h = value(value(histsig)[1])
fill!(h.weights, 0)
push!(enabled, false)
yield()
h = value(value(histsig)[1])
@test sum(h.weights) > 0
end
end

6 comments on commit 56e999d

@timholy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/180

After the above pull request is merged, it is recommended that you create
a tag on this repository for the registered package version:

git tag -a v0.9.0 -m "<description of version>" 56e999d51c2d8c996d056a6659ac87ff95629812
git push origin v0.9.0

@timholy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/180

After the above pull request is merged, it is recommended that you create
a tag on this repository for the registered package version:

git tag -a v0.9.0 -m "<description of version>" 56e999d51c2d8c996d056a6659ac87ff95629812
git push origin v0.9.0

@timholy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/180

After the above pull request is merged, it is recommended that you create
a tag on this repository for the registered package version:

git tag -a v0.9.0 -m "<description of version>" 56e999d51c2d8c996d056a6659ac87ff95629812
git push origin v0.9.0

Please sign in to comment.