Skip to content

Commit 15f042d

Browse files
authored
Revert "Add DiffResult for MArray (#18)"
This reverts commit f80602e.
1 parent f80602e commit 15f042d

File tree

3 files changed

+5
-83
lines changed

3 files changed

+5
-83
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DiffResults"
22
uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
3-
version = "1.2.0"
3+
version = "1.1.0"
44

55
[deps]
66
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"

src/DiffResults.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module DiffResults
22

3-
using StaticArraysCore: StaticArray, similar_type, Size, SArray
3+
using StaticArraysCore: StaticArray, similar_type, Size
44

55
#########
66
# Types #
@@ -36,7 +36,7 @@ Return `r::DiffResult`, with output value storage provided by `value` and output
3636
storage provided by `derivs`.
3737
3838
In reality, `DiffResult` is an abstract supertype of two concrete types, `MutableDiffResult`
39-
and `ImmutableDiffResult`. If all `value`/`derivs` are all `Number`s or `StaticArrays.SArray`s,
39+
and `ImmutableDiffResult`. If all `value`/`derivs` are all `Number`s or `StaticArray`s,
4040
then `r` will be immutable (i.e. `r::ImmutableDiffResult`). Otherwise, `r` will be mutable
4141
(i.e. `r::MutableDiffResult`).
4242
@@ -45,8 +45,8 @@ Note that `derivs` can be provide in splatted form, i.e. `DiffResult(value, deri
4545
DiffResult
4646

4747
DiffResult(value::Number, derivs::Tuple{Vararg{Number}}) = ImmutableDiffResult(value, derivs)
48-
DiffResult(value::Number, derivs::Tuple{Vararg{SArray}}) = ImmutableDiffResult(value, derivs)
49-
DiffResult(value::SArray, derivs::Tuple{Vararg{SArray}}) = ImmutableDiffResult(value, derivs)
48+
DiffResult(value::Number, derivs::Tuple{Vararg{StaticArray}}) = ImmutableDiffResult(value, derivs)
49+
DiffResult(value::StaticArray, derivs::Tuple{Vararg{StaticArray}}) = ImmutableDiffResult(value, derivs)
5050
DiffResult(value::Number, derivs::Tuple{Vararg{AbstractArray}}) = MutableDiffResult(value, derivs)
5151
DiffResult(value::AbstractArray, derivs::Tuple{Vararg{AbstractArray}}) = MutableDiffResult(value, derivs)
5252
DiffResult(value::Union{Number,AbstractArray}, derivs::Union{Number,AbstractArray}...) = DiffResult(value, derivs)

test/runtests.jl

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
1010
n0, n1, n2 = rand(), rand(), rand()
1111
x0, x1, x2 = rand(k), rand(k, k), rand(k, k, k)
1212
s0, s1, s2 = SVector{k}(rand(k)), SMatrix{k,k}(rand(k, k)), SArray{Tuple{k,k,k}}(rand(k, k, k))
13-
m0, m1, m2 = MVector{k}(rand(k)), MMatrix{k,k}(rand(k, k)), MArray{Tuple{k,k,k}}(rand(k, k, k))
14-
1513
rn = DiffResult(n0, n1, n2)
1614
rx = DiffResult(x0, x1, x2)
1715
rs = DiffResult(s0, s1, s2)
18-
rm = DiffResult(m0, m1, m2)
1916
rsmix = DiffResult(n0, s0, s1)
2017

2118
issimilar(x, y) = typeof(x) == typeof(y) && size(x) == size(y)
@@ -25,7 +22,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
2522
@test rn === DiffResult(n0, n1, n2)
2623
@test rx == DiffResult(x0, x1, x2)
2724
@test rs === DiffResult(s0, s1, s2)
28-
@test rm == DiffResult(m0, m1, m2)
2925
@test rsmix === DiffResult(n0, s0, s1)
3026

3127
@test issimilar(GradientResult(x0), DiffResult(first(x0), x0))
@@ -38,15 +34,9 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
3834
@test JacobianResult(SVector{k+1}(vcat(s0, 0.0)), s0) === DiffResult(SVector{k+1}(vcat(s0, 0.0)), zeros(SMatrix{k+1,k,Float64}))
3935
@test HessianResult(s0) === DiffResult(first(s0), s0, zeros(SMatrix{k,k,Float64}))
4036

41-
@test issimilar(GradientResult(m0), DiffResult(first(m0), m0))
42-
@test issimilar(JacobianResult(m0), DiffResult(m0, zeros(MMatrix{k,k,Float64})))
43-
@test issimilar(JacobianResult(MVector{k + 1}(vcat(m0, 0.0)), m0), DiffResult(MVector{k + 1}(vcat(m0, 0.0)), zeros(MMatrix{k + 1,k,Float64})))
44-
@test issimilar(HessianResult(m0), DiffResult(first(m0), m0, zeros(MMatrix{k,k,Float64})))
45-
4637
@test eltype(rn) === typeof(n0)
4738
@test eltype(rx) === eltype(x0)
4839
@test eltype(rs) === eltype(s0)
49-
@test eltype(rm) === eltype(m0)
5040

5141
rn_copy = copy(rn)
5242
@test rn == rn_copy
@@ -60,10 +50,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
6050
@test rs == rs_copy
6151
@test rs === rs_copy
6252

63-
rm_copy = copy(rm)
64-
@test rm == rm_copy
65-
@test rm !== rm_copy
66-
6753
rsmix_copy = copy(rsmix)
6854
@test rsmix == rsmix_copy
6955
@test rsmix === rsmix_copy
@@ -73,7 +59,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
7359
@test value(rn) === n0
7460
@test value(rx) === x0
7561
@test value(rs) === s0
76-
@test value(rm) === m0
7762
@test value(rsmix) === n0
7863

7964
rn = value!(rn, n1)
@@ -91,11 +76,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
9176
@test typeof(value(rs)) === typeof(s0)
9277
rs = value!(rs, s0)
9378

94-
m0_new, m0_copy = rand(k), copy(m0)
95-
rm = value!(rm, m0_new)
96-
@test value(rm) === m0 == m0_new
97-
rm = value!(rm, m0_copy)
98-
9979
rsmix = value!(rsmix, n1)
10080
@test value(rsmix) === n1
10181
rsmix = value!(rsmix, n0)
@@ -115,11 +95,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
11595
@test typeof(value(rs)) === typeof(s0)
11696
rs = value!(rs, s0)
11797

118-
m0_new, m0_copy = rand(k), copy(m0)
119-
rm = value!(exp, rm, m0_new)
120-
@test value(rm) === m0 == exp.(m0_new)
121-
rm = value!(rm, m0_copy)
122-
12398
rsmix = value!(exp, rsmix, n1)
12499
@test value(rsmix) === exp(n1)
125100
rsmix = value!(rsmix, n0)
@@ -141,9 +116,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
141116
@test derivative(rs) === s1
142117
@test derivative(rs, Val{2}) === s2
143118

144-
@test derivative(rm) === m1
145-
@test derivative(rm, Val{2}) === m2
146-
147119
@test derivative(rsmix) === s0
148120
@test derivative(rsmix, Val{2}) === s1
149121

@@ -168,11 +140,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
168140
@test typeof(derivative(rsmix)) === typeof(s0)
169141
rsmix = derivative!(rsmix, s0)
170142

171-
m1_new, m1_copy = rand(k, k), copy(m1)
172-
rm = derivative!(rm, m1_new)
173-
@test derivative(rm) === m1 == m1_new
174-
rm = derivative!(rm, m1_copy)
175-
176143
rn = derivative!(rn, n1, Val{2})
177144
@test derivative(rn, Val{2}) === n1
178145
rn = derivative!(rn, n2, Val{2})
@@ -194,11 +161,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
194161
@test typeof(derivative(rsmix, Val{2})) === typeof(s1)
195162
rsmix = derivative!(rsmix, s1, Val{2})
196163

197-
m2_new, m2_copy = rand(k, k, k), copy(m2)
198-
rm = derivative!(rm, m2_new, Val{2})
199-
@test derivative(rm, Val{2}) === m2 == m2_new
200-
rm = derivative!(rm, m2_copy, Val{2})
201-
202164
rn = derivative!(exp, rn, n0)
203165
@test derivative(rn) === exp(n0)
204166
rn = derivative!(rn, n1)
@@ -220,11 +182,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
220182
@test typeof(derivative(rsmix)) === typeof(s0)
221183
rsmix = derivative!(exp, rsmix, s0)
222184

223-
m1_new, m1_copy = rand(k, k), copy(m1)
224-
rm = derivative!(exp, rm, m1_new)
225-
@test derivative(rm) === m1 == exp.(m1_new)
226-
rm = derivative!(exp, rm, m1_copy)
227-
228185
rn = derivative!(exp, rn, n1, Val{2})
229186
@test derivative(rn, Val{2}) === exp(n1)
230187
rn = derivative!(rn, n2, Val{2})
@@ -245,11 +202,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
245202
@test derivative(rsmix, Val{2}) == exp.(s1_new)
246203
@test typeof(derivative(rsmix, Val{2})) === typeof(s1)
247204
rsmix = derivative!(exp, rsmix, s1, Val{2})
248-
249-
m2_new, m2_copy = rand(k, k, k), copy(m2)
250-
rm = derivative!(exp, rm, m2_new, Val{2})
251-
@test derivative(rm, Val{2}) === m2 == exp.(m2_new)
252-
rm = derivative!(exp, rm, m2_copy, Val{2})
253205
end
254206

255207
@testset "gradient/gradient!" begin
@@ -265,11 +217,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
265217
@test typeof(gradient(rs)) === typeof(s1)
266218
rs = gradient!(rs, s1)
267219

268-
m1_new, m1_copy = rand(k, k), copy(m1)
269-
rm = gradient!(rm, m1_new)
270-
@test gradient(rm) === m1 == m1_new
271-
rm = gradient!(rm, m1_copy)
272-
273220
x1_new, x1_copy = rand(k, k), copy(x1)
274221
rx = gradient!(exp, rx, x1_new)
275222
@test gradient(rx) === x1 == exp.(x1_new)
@@ -281,11 +228,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
281228
@test typeof(gradient(rsmix)) === typeof(s0)
282229
rsmix = gradient!(exp, rsmix, s0)
283230

284-
m1_new, m1_copy = rand(k, k), copy(m1)
285-
rm = gradient!(exp, rm, m1_new)
286-
@test gradient(rm) === m1 == exp.(m1_new)
287-
rm = gradient!(exp, rm, m1_copy)
288-
289231
T = typeof(SVector{k*k}(rand(k*k)))
290232
rs_new = gradient!(rs, convert(T, gradient(rs)))
291233
@test rs_new === rs
@@ -304,11 +246,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
304246
@test typeof(jacobian(rs)) === typeof(s1)
305247
rs = jacobian!(rs, s1)
306248

307-
m1_new, m1_copy = rand(k, k), copy(m1)
308-
rm = jacobian!(rm, m1_new)
309-
@test jacobian(rm) === m1 == m1_new
310-
rm = jacobian!(rm, m1_copy)
311-
312249
x1_new, x1_copy = rand(k, k), copy(x1)
313250
rx = jacobian!(exp, rx, x1_new)
314251
@test jacobian(rx) === x1 == exp.(x1_new)
@@ -320,11 +257,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
320257
@test typeof(jacobian(rsmix)) === typeof(s0)
321258
rsmix = jacobian!(exp, rsmix, s0)
322259

323-
m1_new, m1_copy = rand(k, k), copy(m1)
324-
rm = jacobian!(exp, rm, m1_new)
325-
@test jacobian(rm) === m1 == exp.(m1_new)
326-
rm = jacobian!(exp, rm, m1_copy)
327-
328260
T = typeof(SVector{k*k}(rand(k*k)))
329261
rs_new = jacobian!(rs, convert(T, jacobian(rs)))
330262
@test rs_new === rs
@@ -343,11 +275,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
343275
@test typeof(hessian(rs)) === typeof(s2)
344276
rs = hessian!(rs, s2)
345277

346-
m2_new, m2_copy = rand(k, k, k), copy(m2)
347-
rm = hessian!(rm, m2_new)
348-
@test hessian(rm) === m2 == m2_new
349-
rm = hessian!(rm, m2_copy)
350-
351278
x2_new, x2_copy = rand(k, k, k), copy(x2)
352279
rx = hessian!(exp, rx, x2_new)
353280
@test hessian(rx) === x2 == exp.(x2_new)
@@ -359,11 +286,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
359286
@test typeof(hessian(rsmix)) === typeof(s1)
360287
rsmix = hessian!(exp, rsmix, s1)
361288

362-
m2_new, m2_copy = rand(k, k, k), copy(m2)
363-
rm = hessian!(exp, rm, m2_new)
364-
@test hessian(rm) === m2 == exp.(m2_new)
365-
rm = hessian!(exp, rm, m2_copy)
366-
367289
T = typeof(SVector{k*k*k}(rand(k*k*k)))
368290
rs_new = hessian!(rs, convert(T, hessian(rs)))
369291
@test rs_new === rs

0 commit comments

Comments
 (0)