Skip to content

Commit 40473fe

Browse files
andreasnoackjrevels
authored andcommitted
New indexing traits names (#54)
1 parent 0b88066 commit 40473fe

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

REQUIRE

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ julia 0.5
22
DiffBase 0.0.3
33
ForwardDiff 0.3.4
44
Calculus 0.2.0
5+
Compat 0.19.0

docs/src/limits.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ seen users run into ("target function" here refers to the function being differe
1212

1313
- **Nested differentiation of closures is dangerous.** Differentiating closures is safe, and nested differentation is safe, but you might be vulnerable to a subtle bug if you try to do both. See [this ForwardDiff issue](https://github.com/JuliaDiff/ForwardDiff.jl/issues/83) for details. A fix is currently being planned for this problem.
1414

15-
- **Array input types must obey `A<:AbstractArray` and `Base.linearindexing(::A) == Base.LinearFast()`.**
15+
- **Array input types must obey `A<:AbstractArray` and `Base.IndexStyle(::A) == Base.IndexLinear()`.**
1616

1717
- **Array inputs that are being differentiated cannot be mutated**. This also applies to any "descendent" arrays that must be tracked (e.g. if `A` is an immutable input array, then `C = A * A` will also be immutable). If you try to perform `setindex!` on such arrays, an error will be thrown. In the future, this restriction might be lifted. Note that arrays explicitly constructed within the target function (e.g. via `ones`, `similar`, etc.) can be mutated, as well as output arrays used when taking the Jacobian of a function of the form `f!(output, input....).`

src/ReverseDiff.jl

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module ReverseDiff
44

55
using Base: RefValue
66

7+
using Compat
8+
79
using DiffBase
810
using DiffBase: DiffResult
911

src/tracked.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ immutable TrackedArray{V,D,N,VA,DA} <: AbstractArray{TrackedReal{V,D,TrackedArra
6868
deriv::DA
6969
tape::RawTape
7070
function TrackedArray(value::AbstractArray{V,N}, deriv::AbstractArray{D,N}, tape::RawTape)
71-
@assert Base.linearindexing(value) === Base.LinearFast()
71+
@assert IndexStyle(value) === IndexLinear()
7272
@assert size(value) === size(deriv)
7373
return new(value, deriv, tape)
7474
end
@@ -317,7 +317,7 @@ end
317317

318318
Base.setindex!(t::TrackedArray, args...) = error("TrackedArrays do not support setindex!")
319319

320-
Base.linearindexing(::TrackedArray) = Base.LinearFast()
320+
@compat Base.IndexStyle(::TrackedArray) = IndexLinear()
321321

322322
Base.size(t::TrackedArray) = size(value(t))
323323

test/TrackedTests.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module TrackedTests
22

33
using ReverseDiff, Base.Test
44
using ReverseDiff: TrackedReal, TrackedArray
5+
using Compat
56

67
include(joinpath(dirname(@__FILE__), "utils.jl"))
78

@@ -703,7 +704,7 @@ instr = tp[1]
703704
@test instr.cache === nothing
704705
empty!(tp)
705706

706-
@test Base.linearindexing(ta) === Base.LinearFast()
707+
@test IndexStyle(ta) === IndexLinear()
707708

708709
@test Base.size(ta) === size(varr)
709710

0 commit comments

Comments
 (0)