From 2403c89225dd273420b88bcd45c8e9a4c16ec442 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 12 Jan 2026 20:43:30 -0500 Subject: [PATCH 1/5] Add floatmax and floatmin methods for TrackedReal These methods delegate to the underlying value type, following the same pattern as eps. This fixes errors when code calls floatmax or floatmin on TrackedReal types during autodiff. Co-Authored-By: Claude Opus 4.5 --- src/tracked.jl | 6 ++++++ test/TrackedTests.jl | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/tracked.jl b/src/tracked.jl index 7b2753dc..f620c0d2 100644 --- a/src/tracked.jl +++ b/src/tracked.jl @@ -433,6 +433,12 @@ Base.rand(rng::Random.AbstractRNG, ::Type{TrackedReal{V,D,O}}) where {V,D,O} = T Base.eps(t::TrackedReal) = eps(value(t)) Base.eps(::Type{T}) where {T<:TrackedReal} = eps(valtype(T)) +Base.floatmax(t::TrackedReal) = floatmax(value(t)) +Base.floatmax(::Type{T}) where {T<:TrackedReal} = floatmax(valtype(T)) + +Base.floatmin(t::TrackedReal) = floatmin(value(t)) +Base.floatmin(::Type{T}) where {T<:TrackedReal} = floatmin(valtype(T)) + Base.floor(t::TrackedReal) = floor(value(t)) Base.floor(::Type{R}, t::TrackedReal) where {R<:Real} = floor(R, value(t)) diff --git a/test/TrackedTests.jl b/test/TrackedTests.jl index 18420bad..72711d6c 100644 --- a/test/TrackedTests.jl +++ b/test/TrackedTests.jl @@ -756,6 +756,12 @@ tr_rand = rand(MersenneTwister(1), TrackedReal{Int,Float64,Nothing}) @test eps(tr_float) === eps(v_float) @test eps(typeof(tr_float)) === eps(Float64) +@test floatmax(tr_float) === floatmax(v_float) +@test floatmax(typeof(tr_float)) === floatmax(Float64) + +@test floatmin(tr_float) === floatmin(v_float) +@test floatmin(typeof(tr_float)) === floatmin(Float64) + @test floor(tr_float) === floor(v_float) @test floor(Int, tr_float) === floor(Int, v_float) From 3ad62717369aa8817f56d68460c740170dbbf7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Tue, 13 Jan 2026 07:11:44 +0100 Subject: [PATCH 2/5] Only define `floatmin` and `floatmax` for types --- src/tracked.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/tracked.jl b/src/tracked.jl index f620c0d2..1198dea5 100644 --- a/src/tracked.jl +++ b/src/tracked.jl @@ -433,10 +433,7 @@ Base.rand(rng::Random.AbstractRNG, ::Type{TrackedReal{V,D,O}}) where {V,D,O} = T Base.eps(t::TrackedReal) = eps(value(t)) Base.eps(::Type{T}) where {T<:TrackedReal} = eps(valtype(T)) -Base.floatmax(t::TrackedReal) = floatmax(value(t)) Base.floatmax(::Type{T}) where {T<:TrackedReal} = floatmax(valtype(T)) - -Base.floatmin(t::TrackedReal) = floatmin(value(t)) Base.floatmin(::Type{T}) where {T<:TrackedReal} = floatmin(valtype(T)) Base.floor(t::TrackedReal) = floor(value(t)) From c186125f300cdcbc740e14a8bcbeafbc41b58f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Tue, 13 Jan 2026 07:12:04 +0100 Subject: [PATCH 3/5] Update tests --- test/TrackedTests.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/TrackedTests.jl b/test/TrackedTests.jl index 72711d6c..86555af1 100644 --- a/test/TrackedTests.jl +++ b/test/TrackedTests.jl @@ -756,10 +756,7 @@ tr_rand = rand(MersenneTwister(1), TrackedReal{Int,Float64,Nothing}) @test eps(tr_float) === eps(v_float) @test eps(typeof(tr_float)) === eps(Float64) -@test floatmax(tr_float) === floatmax(v_float) @test floatmax(typeof(tr_float)) === floatmax(Float64) - -@test floatmin(tr_float) === floatmin(v_float) @test floatmin(typeof(tr_float)) === floatmin(Float64) @test floor(tr_float) === floor(v_float) From 57b4698726303736ca31c45b20e2ee494d5d9a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Tue, 13 Jan 2026 07:21:43 +0100 Subject: [PATCH 4/5] Extend tests --- test/TrackedTests.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/TrackedTests.jl b/test/TrackedTests.jl index 86555af1..006490ad 100644 --- a/test/TrackedTests.jl +++ b/test/TrackedTests.jl @@ -733,6 +733,7 @@ tp = InstructionTape() tr_int = TrackedReal(v_int, d, tp) tr_float = TrackedReal(v_float, d, tp) tr_float2 = TrackedReal(v_float2, d2, tp) +tr_float32 = TrackedReal(Float32(v_float), Float32(d), tp) @test hash(tr_float) === hash(v_float) @test hash(tr_float, hash(1)) === hash(v_float, hash(1)) @@ -756,8 +757,10 @@ tr_rand = rand(MersenneTwister(1), TrackedReal{Int,Float64,Nothing}) @test eps(tr_float) === eps(v_float) @test eps(typeof(tr_float)) === eps(Float64) -@test floatmax(typeof(tr_float)) === floatmax(Float64) @test floatmin(typeof(tr_float)) === floatmin(Float64) +@test floatmin(typeof(tr_float32)) === floatmin(Float32) +@test floatmax(typeof(tr_float)) === floatmax(Float64) +@test floatmax(typeof(tr_float32)) === floatmax(Float32) @test floor(tr_float) === floor(v_float) @test floor(Int, tr_float) === floor(Int, v_float) From 7d268d155f3016eb3b63fc561ecbb33e3bce3f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Tue, 13 Jan 2026 07:23:14 +0100 Subject: [PATCH 5/5] Bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3a4cdfba..de85ed02 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ReverseDiff" uuid = "37e2e3b7-166d-5795-8a7a-e32c996b4267" -version = "1.16.1" +version = "1.16.2" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"