Skip to content

Commit 80b2369

Browse files
Merge pull request #117 from JuliaDiff/an/oneto
Fix calculation of 1x1 Jacobian of a Vector
2 parents 2d81794 + 0913cb2 commit 80b2369

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# FiniteDiff
22

33
[![Build Status](https://travis-ci.org/JuliaDiff/FiniteDiff.jl.svg?branch=master)](https://travis-ci.org/JuliaDiff/FiniteDiff.jl)
4+
[![codecov](https://codecov.io/gh/JuliaDiff/FiniteDiff.jl/branch/master/graph/badge.svg?token=PnBAscoOiU)](https://codecov.io/gh/JuliaDiff/FiniteDiff.jl)
45

56
This package is for calculating derivatives, gradients, Jacobians, Hessians,
67
etc. numerically. This library is for maximizing speed while giving a usable

src/FiniteDiff.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ _vec(x) = vec(x)
99
_vec(x::Number) = x
1010

1111
_mat(x::AbstractMatrix) = x
12-
_mat(x::StaticVector) = reshape(x, (axes(x, 1), SOneTo(1)))
13-
_mat(x::AbstractVector) = reshape(x, (axes(x, 1), OneTo(1)))
12+
_mat(x::StaticVector) = reshape(x, (axes(x, 1), SOneTo(1)))
13+
_mat(x::AbstractVector) = reshape(x, (axes(x, 1), Base.OneTo(1)))
1414

1515
include("iteration_utils.jl")
1616
include("epsilons.jl")

test/out_of_place_tests.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,15 @@ J = FiniteDiff.finite_difference_jacobian(f, x, Val{:forward}, eltype(x),
3434
@test J second_derivative_stencil(30)
3535
@test typeof(J) == typeof(spJ)
3636

37-
#1x1 SVector test
38-
x = SVector{1}([1.])
3937
f(x) = x
40-
J = FiniteDiff.finite_difference_jacobian(f, x, Val{:forward}, eltype(x))
41-
@test J[1, 1] 1.0
42-
@test J isa SMatrix{1,1}
43-
J = FiniteDiff.finite_difference_jacobian(f, x, Val{:central}, eltype(x))
44-
@test J[1, 1] 1.0
45-
@test J isa SMatrix{1,1}
46-
J = FiniteDiff.finite_difference_jacobian(f, x, Val{:complex}, eltype(x))
47-
@test J[1, 1] 1.0
48-
@test J isa SMatrix{1,1}
38+
@testset "1x1 test of $x" for
39+
(x, y) in ((SVector{1}([1.]), SMatrix{1,1}), ([1.0], Matrix)),
40+
difftype in (:forward, :central, :complex)
41+
42+
J = FiniteDiff.finite_difference_jacobian(f, x, Val{difftype}, eltype(x))
43+
@test J[1, 1] 1.0
44+
@test J isa y
45+
end
4946

5047
x = SVector{1}([1.])
5148
f(x) = vcat(x, x)

0 commit comments

Comments
 (0)