Skip to content

Commit

Permalink
Merge 229c8a4 into 958711d
Browse files Browse the repository at this point in the history
  • Loading branch information
felipenoris committed Apr 11, 2019
2 parents 958711d + 229c8a4 commit 936947a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/prelude.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const CHUNKS = [Chunk{i}() for i in 1:DEFAULT_CHUNK_THRESHOLD]

function Chunk(input_length::Integer, threshold::Integer = DEFAULT_CHUNK_THRESHOLD)
N = pickchunksize(input_length, threshold)
N <= DEFAULT_CHUNK_THRESHOLD && return CHUNKS[N]
0 < N <= DEFAULT_CHUNK_THRESHOLD && return CHUNKS[N]
return Chunk{N}()
end

Expand Down
9 changes: 9 additions & 0 deletions test/GradientTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,13 @@ for T in (StaticArrays.SArray, StaticArrays.MArray)
@test DiffResults.gradient(sresult3) == DiffResults.gradient(result)
end

# Issue 399

let
f_const(x) = 1.0
g_grad_const = x -> ForwardDiff.gradient(f_const, x)
@test g_grad_const([1.0]) == [0.0]
@test isempty(g_grad_const(zeros(Float64, 0)))
end

end # module

0 comments on commit 936947a

Please sign in to comment.