-
Notifications
You must be signed in to change notification settings - Fork 15
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
@plottest
#62
Comments
We should provide a guaranteed way to support extensions, either via creating another And we can then move image-related functionality out from the core. |
I would prefer to compare data instead of figures as figures can be unstable due to backend changes. |
but sometime you want to test against that. |
I've just refactored the test suite of ImageInpainting.jl and replaced VisualRegressionTests.jl to ReferenceTests.jl and it is so much cleaner now. Thanks for this package! Next, I will try to refactor all packages in the GeoStats.jl stack to use ReferenceTests.jl as well, and they are full of Suppose I have a plot object with the GR backend |
I think |
Nice, I don't know if I understood the mimetype comment, but I will give it a try, hopefully soon. |
@oxinabox what should the |
I am not sure, I don't remember how that bit of the code works. |
Any example that we could copy/paste? I am searching the web for a simple example of how to convert a plot into an image without success. |
I could do the following: using Plots
io = IOBuffer()
p = scatter(rand(100))
show(io, "image/png", p) # stores data in in-memory buffer
data = take!(io) # retrieve data as a Vector{UInt8} I have no idea how to convert this vector of int into an image. |
Hey! I am really rusty and outdated -- and there is a possibility that my memory is somehow skewed and simply wrong -- but maybe I can provide some useful breadcrumbs. First of all I think you are on the right track that you'd want to convert a figure into an actual image (aka colorant array) and then hook into our image comparing logic. Now concerning the In order to get a colorant array you have to essentially pretend its a .png file with the byte contents of @timholy What is the current best practice to deserialize the contents of an image in memory (like |
People helped on Zulip, this is the final solution with PNGFiles: using PNGFiles
function asimage(plt)
io = IOBuffer()
show(io, "image/png", plt)
seekstart(io)
PNGFiles.load(io)
end
img = asimage(scatter(rand(100))) @oxinabox would you like me to submit a PR with this helper macro? Perhaps |
That would be awesome. |
I wonder if we want something like VisualRegressionTest's
@plottest
that takes as input something that interacts withdisplay
. (I think? Or maybe it just callssavefig
but interacting as a display seems more robust)Right now it's annoying to use this with plots since they don't return object that can be compared.
Then I could stop using VisualRegressionTests
The text was updated successfully, but these errors were encountered: