Skip to content

Add AbstractIrrational to list of types for TrackedReal promote_rule definitions #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ DiffRules = "1.4"
DiffTests = "< 0.1.2"
ForwardDiff = "0.10"
FunctionWrappers = "1"
IrrationalConstants = "0.2"
LogExpFunctions = "0.3"
MacroTools = "0.5"
NaNMath = "0.3, 1"
Expand All @@ -34,7 +35,8 @@ julia = "1"
[extras]
DiffTests = "de460e47-3fe3-5279-bb4a-814414816d5d"
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
IrrationalConstants = "92d709cd-6900-40b7-9082-c6be49f344b6"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["DiffTests", "FillArrays", "Test"]
test = ["DiffTests", "FillArrays", "IrrationalConstants", "Test"]
2 changes: 1 addition & 1 deletion src/ReverseDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using ChainRulesCore
# Not all operations will be valid over all of these types, but that's okay; such cases
# will simply error when they hit the original operation in the overloaded definition.
const ARRAY_TYPES = (:AbstractArray, :AbstractVector, :AbstractMatrix, :Array, :Vector, :Matrix)
const REAL_TYPES = (:Bool, :Integer, :(Irrational{:ℯ}), :(Irrational{:π}), :Rational, :BigFloat, :BigInt, :AbstractFloat, :Real, :Dual)
const REAL_TYPES = (:Bool, :Integer, :AbstractIrrational, :Rational, :BigFloat, :BigInt, :AbstractFloat, :Real, :Dual)

const SKIPPED_UNARY_SCALAR_FUNCS = Symbol[:isinf, :isnan, :isfinite, :iseven, :isodd, :isreal, :isinteger]
const SKIPPED_BINARY_SCALAR_FUNCS = Symbol[:isequal, :isless, :<, :>, :(==), :(!=), :(<=), :(>=)]
Expand Down
2 changes: 2 additions & 0 deletions test/TrackedTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using ReverseDiff, Test
using ReverseDiff: TrackedReal, TrackedArray

import ForwardDiff
import IrrationalConstants: log2π

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

Expand Down Expand Up @@ -609,6 +610,7 @@ empty!(tp)
@test promote_type(T, Integer) === TrackedReal{BigInt,Float64,A}
@test promote_type(T, typeof(ℯ)) === TrackedReal{BigFloat,Float64,A}
@test promote_type(T, typeof(π)) === TrackedReal{BigFloat,Float64,A}
@test promote_type(T, typeof(log2π)) === TrackedReal{BigFloat,Float64,A}
@test promote_type(T, Rational{Int}) === TrackedReal{Rational{BigInt},Float64,A}
@test promote_type(T, BigFloat) === TrackedReal{BigFloat,Float64,A}
@test promote_type(T, BigInt) === T
Expand Down