Skip to content

Commit

Permalink
Add check in error hint (#199)
Browse files Browse the repository at this point in the history
MethodErrors can be generated for objects for which `nameof`
has no method.

Also updates to Aqua 0.8, and adds [compat]. We didn't have
a [compat] before so the new release of Aqua broke our
tests.
  • Loading branch information
timholy authored Jan 25, 2024
1 parent 2ed7df8 commit 1d4f6c7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
16 changes: 14 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ImageCore"
uuid = "a09fc81d-aa75-5fe9-8630-4744c3626534"
version = "0.10.1"
version = "0.10.2"

[deps]
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"
Expand All @@ -14,15 +14,26 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"

[compat]
Aqua = "0.8"
BlockArrays = "0.16"
ColorVectorSpace = "0.10"
Colors = "0.12"
Documenter = "1"
FFTW = "1"
FixedPointNumbers = "0.8"
ImageIO = "0.6"
ImageInTerminal = "0.5"
Logging = "1"
MappedArrays = "0.2, 0.3, 0.4"
MosaicViews = "0.3.3"
OffsetArrays = "0.8, 0.9, 0.10, 0.11, 1.0.1"
PaddedViews = "0.5.8"
PrecompileTools = "1"
Random = "1"
Reexport = "0.2, 1.0"
ReferenceTests = "0.10"
Statistics = "1"
Test = "1"
julia = "1.6"

[extras]
Expand All @@ -32,10 +43,11 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "BlockArrays", "Documenter", "FFTW", "ImageIO", "ImageInTerminal", "Random", "ReferenceTests", "Statistics", "Test"]
test = ["Aqua", "BlockArrays", "Documenter", "FFTW", "ImageIO", "ImageInTerminal", "Logging", "Random", "ReferenceTests", "Statistics", "Test"]
3 changes: 2 additions & 1 deletion src/ImageCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ end

function __init__()
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs
if nameof(exc.f) (:fft, :rfft, :plan_fft, :plan_rfft, :realfloat) && argtypes[1] <: AbstractArray{<:Colorant}
f = exc.f
if isa(f, Function) && nameof(f) (:fft, :rfft, :plan_fft, :plan_rfft, :realfloat) && argtypes[1] <: AbstractArray{<:Colorant}
throw_ffterror(io, exc.f, exc.args...)
end
end
Expand Down
12 changes: 10 additions & 2 deletions test/functions.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using ImageCore
using FFTW
using Logging
using Test

@testset "functions" begin
ag = rand(Gray{Float32}, 4, 5)
Expand All @@ -8,14 +11,19 @@ using FFTW
(fft, (ac,)), (fft, (ac, 1:2)), (plan_fft, (ac,)),
(rfft, (ac,)), (rfft, (ac, 1:2)), (plan_rfft, (ac,)))
dims_str = eltype(args[1])<:Gray ? "1:2" : "2:3"
ret = @test_throws "channelview, and likely $dims_str" f(args...)
@test_throws "channelview, and likely $dims_str" f(args...)
end
for (a, dims) in ((ag, 1:2), (ac, 2:3))
@test ifft(fft(channelview(a), dims), dims) channelview(a)
ret = @test_throws "channelview, and likely $dims" rfft(a)
@test irfft(rfft(channelview(a), dims), 4, dims) channelview(a)
end

# Ensure that the hint doesn't error
@test_logs min_level=Logging.Warn try
[3](1, 2)
catch err
showerror(devnull, err)
end

a = [RGB(1,0,0), RGB(0,1,0), RGB(0,0,1)]
@test a' == [RGB(1,0,0) RGB(0,1,0) RGB(0,0,1)]
Expand Down
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ using Aqua, Documenter # for meta quality checks
deps_compat=true,
stale_deps=true,
# FIXME? re-enable the `piracy` test
piracy=false, # currently just `float` and `paddedviews`
project_toml_formatting=true,
piracies=false, # currently just `float` and `paddedviews`
unbound_args=true,
)
DocMeta.setdocmeta!(ImageCore, :DocTestSetup, :(using ImageCore); recursive=true)
Expand Down

2 comments on commit 1d4f6c7

@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
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/99550

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.2 -m "<description of version>" 1d4f6c78531e533d93818b21f9429598ce3606cd
git push origin v0.10.2

Please sign in to comment.