Skip to content

Commit

Permalink
Increase code coverage (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill authored Nov 25, 2021
1 parent 8f02de0 commit e13c7aa
Show file tree
Hide file tree
Showing 89 changed files with 103 additions and 101 deletions.
1 change: 0 additions & 1 deletion src/DitherPunk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ include("ordered.jl")
include("ordered_imagemagick.jl")
include("error_diffusion.jl")
include("closest_color.jl")
include("show.jl")
include("eval.jl")

export dither, dither!
Expand Down
9 changes: 1 addition & 8 deletions src/api/binary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ dither

# If `out` is specified, it will be changed in place...
function dither!(out::GenericImage, img::GenericImage, alg::AbstractDither; kwargs...)
if size(out) != size(img)
throw(
ArgumentError(
"out and img should have the same shape, instead they are $(size(out)) and $(size(img))",
),
)
end
return _binarydither!(out, img, alg; kwargs...)
end

Expand Down Expand Up @@ -61,7 +54,7 @@ end
# when no color palette is provided
function _binarydither!(
out::GenericGrayImage, img::GenericGrayImage, alg::AbstractDither; to_linear=false
) where {T}
)
to_linear && (img = srgb2linear.(img))
return binarydither!(alg, out, img)
end
Expand Down
7 changes: 0 additions & 7 deletions src/api/color.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ colordither(alg, img, cs, metric) = throw(ColorNotImplementedError(alg))

# If `out` is specified, it will be changed in place...
function dither!(out::GenericImage, img::GenericImage, alg::AbstractDither, arg; kwargs...)
if size(out) != size(img)
throw(
ArgumentError(
"out and img should have the same shape, instead they are $(size(out)) and $(size(img))",
),
)
end
return out .= _colordither(eltype(out), img, alg, arg; kwargs...)
end

Expand Down
7 changes: 0 additions & 7 deletions src/eval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,3 @@ function test_on_gradient(alg::AbstractDither)

return mosaicview([srgb, dither_srgb, linear, dither_linear]; ncol=1)
end
function test_on_gradient(algs::AbstractArray{<:AbstractDither})
srgb, linear = gradient_image(100, 800)
dithers_srgb = [dither(srgb, alg) for alg in algs]
dithers_linear = [dither(linear, alg) for alg in algs]

return mosaicview([srgb, dithers_srgb..., linear, dithers_linear...]; ncol=1)
end
6 changes: 0 additions & 6 deletions src/show.jl

This file was deleted.

8 changes: 3 additions & 5 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ Convert pixel `u` from sRGB to linear color space.
@inline srgb2linear(u::Bool) = u

"""
linear2srgb(u)
upscale(img, scale)
Convert pixel `u` from linear to sRGB color space.
Upscale image by repeating individual pixels `scale` times.
"""
@inline linear2srgb(u::Number) = Colors.srgb_compand(u)
@inline linear2srgb(u::Gray) = typeof(u)(linear2srgb(gray(u)))
@inline linear2srgb(u::Bool) = u
upscale(img, scale) = repeat(img; inner=(scale, scale))

if VERSION >= v"1.7"
_closest_color_idx(px, cs, metric) = argmin(colordiff(px, c; metric=metric) for c in cs)
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion test/references/grad_Atkinson_linear.txt

This file was deleted.

1 change: 0 additions & 1 deletion test/references/grad_BalancedCenteredPoint_linear.txt

This file was deleted.

Loading

0 comments on commit e13c7aa

Please sign in to comment.