Skip to content

Make CI pass #262

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

Merged
merged 9 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions test/derivatives/ArrayFunctionTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,42 @@ function testcat(f, args::Tuple, type, kwargs=NamedTuple())
@test value(x) == f(args...; kwargs...)
else
@assert length(args) == 2
x = f(track(args[1]), args[2]; kwargs...)
@test x isa type
@test value(x) == f(args...; kwargs...)

x = f(args[1], track(args[2]); kwargs...)
@test x isa type
@test value(x) == f(args...; kwargs...)
broken = f == hcat && (args[2] isa AbstractMatrix)
if broken && VERSION >= v"1.4"
Copy link
Member

Choose a reason for hiding this comment

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

Why 1.4? AFAICT (and as mentioned eg in #259) this issue is caused by a type piracy in SparseArrays introduced in Julia 1.10 (see JuliaSparse/SparseArrays.jl#431).

Copy link
Member Author

@gdalle gdalle Jul 31, 2024

Choose a reason for hiding this comment

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

I didn't do the bisection to figure out which version of Julia was guilty. I just took the version that was above 1.3, on which I was sure the tests were passing. I can replace it with 1.10, no problem.
Tbh we should just drop 1.0 and 1.3, even Julia doesn't support those anymore

@test_broken f(track(args[1]), args[2]; kwargs...) isa type
@test_broken value(f(track(args[1]), args[2]; kwargs...)) == f(args...; kwargs...)
else
@test f(track(args[1]), args[2]; kwargs...) isa type
@test value(f(track(args[1]), args[2]; kwargs...)) == f(args...; kwargs...)
end

broken = f == hcat && (args[1] isa AbstractMatrix)
if broken && VERSION >= v"1.4"
@test_broken f(args[1], track(args[2]); kwargs...) isa type
@test_broken value(f(args[1], track(args[2]); kwargs...)) == f(args...; kwargs...)
else
@test f(args[1], track(args[2]); kwargs...) isa type
@test value(f(args[1], track(args[2]); kwargs...)) == f(args...; kwargs...)
end
end

args = (args..., args...)
x = f(track.(args)...; kwargs...)
@test x isa type
@test value(x) == f(args...; kwargs...)

sizes = size.(args)
broken = (f in (vcat, hcat) && (args[2] isa AbstractArray))
if broken && VERSION >= v"1.4"
@test_broken f(track.(args)...; kwargs...) isa type
@test_broken value(f(track.(args)...; kwargs...)) == f(args...; kwargs...)
else
@test f(track.(args)...; kwargs...) isa type
@test value(f(track.(args)...; kwargs...)) == f(args...; kwargs...)
end

F = vecx -> sum(f(unpack(sizes, vecx)...; kwargs...))
X = pack(args)
@test ForwardDiff.gradient(F, X) == gradient(F, X)
end

function pack(xs)
return mapreduce(vcat, xs) do x
x isa Number ? x : vec(x)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using Test

const TESTDIR = dirname(@__FILE__)

test_println(kind, f, pad = " ") = println(pad, "testing $(kind): `$(f)`...")

@testset "ReverseDiff" begin

println("running TapeTests...")
t = @elapsed include(joinpath(TESTDIR, "TapeTests.jl"))
println("done (took $t seconds).")
Expand Down Expand Up @@ -53,3 +57,5 @@ println("done (took $t seconds).")
println("running CompatTests...")
t = @elapsed include(joinpath(TESTDIR, "compat/CompatTests.jl"))
println("done (took $t seconds).")

end
Loading