From 4b291aaa2e218bc5bbd1ca16e40b5bc6b9316caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Wed, 7 Jun 2023 18:40:38 -0400 Subject: [PATCH 1/5] Update partials.jl --- src/partials.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partials.jl b/src/partials.jl index a5316e3e..ddec4ebc 100644 --- a/src/partials.jl +++ b/src/partials.jl @@ -7,7 +7,7 @@ end ############################## @generated function single_seed(::Type{Partials{N,V}}, ::Val{i}) where {N,V,i} - ex = Expr(:tuple, [ifelse(i === j, :(one(V)), :(zero(V))) for j in 1:N]...) + ex = Expr(:tuple, [ifelse(i === j, :(oneunit(V)), :(zero(V))) for j in 1:N]...) return :(Partials($(ex))) end From ba51c37e229a262bfa637927aeeaa5f7e4b13199 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Fri, 4 Aug 2023 18:22:14 -0400 Subject: [PATCH 2/5] add Measurements test --- Project.toml | 3 ++- test/MiscTest.jl | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1f12c7ba..12497280 100644 --- a/Project.toml +++ b/Project.toml @@ -38,9 +38,10 @@ julia = "1.6" Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" DiffTests = "de460e47-3fe3-5279-bb4a-814414816d5d" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Calculus", "DiffTests", "SparseArrays", "StaticArrays", "Test", "InteractiveUtils"] +test = ["Calculus", "DiffTests", "SparseArrays", "StaticArrays", "Test", "InteractiveUtils", "Measurements"] diff --git a/test/MiscTest.jl b/test/MiscTest.jl index 2a22cb2f..5b4fc1d0 100644 --- a/test/MiscTest.jl +++ b/test/MiscTest.jl @@ -6,6 +6,7 @@ using Test using ForwardDiff using DiffTests using SparseArrays: sparse +using Measurements include(joinpath(dirname(@__FILE__), "utils.jl")) @@ -159,3 +160,8 @@ end @test ForwardDiff.derivative(x -> rem2pi(x, RoundDown), rand()) == 1 end # module + +#issue 651, using Measurements +#one(x::Measurement{T}) where T = one(T) != oneunit(x) +f651(x) = 2.1*x + 1 +@test ForwardDiff.derivative(f,1.0 ± 0.01) == 2.1 From b7bb89805e537efc94afdc0f982b2dd728a979b8 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Fri, 4 Aug 2023 18:36:15 -0400 Subject: [PATCH 3/5] use explicit measurement constructor --- test/MiscTest.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/MiscTest.jl b/test/MiscTest.jl index 5b4fc1d0..0ec379fa 100644 --- a/test/MiscTest.jl +++ b/test/MiscTest.jl @@ -164,4 +164,4 @@ end # module #issue 651, using Measurements #one(x::Measurement{T}) where T = one(T) != oneunit(x) f651(x) = 2.1*x + 1 -@test ForwardDiff.derivative(f,1.0 ± 0.01) == 2.1 +@test ForwardDiff.derivative(f,Measurements.measurement(1.0, 0.001)) == 2.1 From 39193dcf78bad858f5154600718d7bbf2fc6726b Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Fri, 4 Aug 2023 18:48:29 -0400 Subject: [PATCH 4/5] typo --- test/MiscTest.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/MiscTest.jl b/test/MiscTest.jl index 0ec379fa..64269b81 100644 --- a/test/MiscTest.jl +++ b/test/MiscTest.jl @@ -164,4 +164,4 @@ end # module #issue 651, using Measurements #one(x::Measurement{T}) where T = one(T) != oneunit(x) f651(x) = 2.1*x + 1 -@test ForwardDiff.derivative(f,Measurements.measurement(1.0, 0.001)) == 2.1 +@test ForwardDiff.derivative(f651,Measurements.measurement(1.0, 0.001)) == 2.1 From 94db0b539f58a0e1388911805c7f79a3af4cae83 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Sun, 6 Aug 2023 20:51:10 -0400 Subject: [PATCH 5/5] another typo --- test/MiscTest.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/MiscTest.jl b/test/MiscTest.jl index 64269b81..b48c7de6 100644 --- a/test/MiscTest.jl +++ b/test/MiscTest.jl @@ -6,7 +6,7 @@ using Test using ForwardDiff using DiffTests using SparseArrays: sparse -using Measurements +using Measurements: Measurements include(joinpath(dirname(@__FILE__), "utils.jl")) @@ -159,9 +159,9 @@ end @test ForwardDiff.derivative(x -> rem2pi(x, RoundUp), rand()) == 1 @test ForwardDiff.derivative(x -> rem2pi(x, RoundDown), rand()) == 1 -end # module - #issue 651, using Measurements #one(x::Measurement{T}) where T = one(T) != oneunit(x) f651(x) = 2.1*x + 1 @test ForwardDiff.derivative(f651,Measurements.measurement(1.0, 0.001)) == 2.1 + +end # module