Skip to content

Commit

Permalink
Make AbstractTracer subtype of Real (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill authored May 22, 2024
1 parent 8072dd2 commit f1bf915
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SparseConnectivityTracer"
uuid = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
authors = ["Adrian Hill <[email protected]>"]
version = "0.4.1"
version = "0.5.0-DEV"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ local_hessian_pattern
!!! warning
Internals may change without warning in a future release of SparseConnectivityTracer.

SparseConnectivityTracer works by pushing `Number` types called tracers through generic functions.
SparseConnectivityTracer works by pushing `Real` number types called tracers through generic functions.
Currently, three tracer types are provided:

```@docs
Expand Down
3 changes: 1 addition & 2 deletions src/overload_connectivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ end
## Special cases

## Exponent (requires extra types)

for S in (Real, Integer, Rational, Irrational{:ℯ})
for S in (Real, Integer, Rational, Complex, Irrational{:ℯ})
Base.:^(t::ConnectivityTracer, ::S) = t
function Base.:^(dx::D, y::S) where {P,T<:ConnectivityTracer,D<:Dual{P,T}}
return Dual(primal(dx)^y, tracer(dx))
Expand Down
3 changes: 1 addition & 2 deletions src/overload_gradient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ end
## Special cases

## Exponent (requires extra types)

for S in (Real, Integer, Rational, Irrational{:ℯ})
for S in (Real, Integer, Rational, Complex, Irrational{:ℯ})
Base.:^(t::GradientTracer, ::S) = t
Base.:^(::S, t::GradientTracer) = t

Expand Down
2 changes: 1 addition & 1 deletion src/overload_hessian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ end
## Special cases

## Exponent (requires extra types)
for S in (Real, Integer, Rational, Irrational{:ℯ})
for S in (Real, Integer, Rational, Complex, Irrational{:ℯ})
function Base.:^(tx::T, y::S) where {T<:HessianTracer}
return T(gradient(tx), hessian(tx) (gradient(tx) × gradient(tx)))
end
Expand Down
8 changes: 4 additions & 4 deletions src/tracers.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
abstract type AbstractTracer <: Number end
abstract type AbstractTracer <: Real end

# Convenience constructor for empty tracers
empty(tracer::T) where {T<:AbstractTracer} = empty(T)
Expand All @@ -19,7 +19,7 @@ sparse_vector(T, index) = T([index])
"""
$(TYPEDEF)
`Number` type keeping track of input indices of previous computations.
`Real` number type keeping track of input indices of previous computations.
For a higher-level interface, refer to [`connectivity_pattern`](@ref).
Expand Down Expand Up @@ -72,7 +72,7 @@ ConnectivityTracer(t::ConnectivityTracer) = t
"""
$(TYPEDEF)
`Number` type keeping track of non-zero gradient entries.
`Real` number type keeping track of non-zero gradient entries.
For a higher-level interface, refer to [`jacobian_pattern`](@ref).
Expand Down Expand Up @@ -121,7 +121,7 @@ GradientTracer(t::GradientTracer) = t
"""
$(TYPEDEF)
`Number` type keeping track of non-zero gradient and Hessian entries.
`Real` number type keeping track of non-zero gradient and Hessian entries.
For a higher-level interface, refer to [`hessian_pattern`](@ref).
Expand Down

0 comments on commit f1bf915

Please sign in to comment.