From 0cdba63e0b455b30fad6a95222d29dfc5e4792e4 Mon Sep 17 00:00:00 2001 From: contradict Date: Fri, 30 Aug 2024 08:31:13 -0700 Subject: [PATCH 1/3] Fix downstream test NT.get_unit assumes DynamicQuantities, to use Unitful use MT.UnitfulUnitCheck.get_unit. --- test/downstream/modeling_toolkit_utils.jl | 50 +++++++++++++++++------ 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/test/downstream/modeling_toolkit_utils.jl b/test/downstream/modeling_toolkit_utils.jl index e9fbb75db..2acc50f5e 100644 --- a/test/downstream/modeling_toolkit_utils.jl +++ b/test/downstream/modeling_toolkit_utils.jl @@ -1,34 +1,58 @@ using Symbolics: diff2term using ModelingToolkit -using ModelingToolkit: equivalent, get_unit, value, VariableUnit -using Unitful: @u_str +using ModelingToolkit: equivalent, get_unit, value, VariableUnit, UnitfulUnitCheck +using DynamicQuantities: @u_str as @du_str +using Unitful: @u_str as @uu_str using Test -@variables t [unit = u"s"] k(t) +@variables t [unit = du"s"] k(t) D = Differential(t) @test equivalent( - u"1/s", + du"s^-1", get_unit( diff2term( - value(D(k)), - Dict(VariableUnit => get_unit(D(k))) - ) + value(D(k)), + Dict(VariableUnit => get_unit(D(k))) + ) ) ) @test equivalent( - u"1/s^2", + du"s^-2", get_unit( diff2term( - value(D(D(k))), - Dict(VariableUnit => get_unit(D(D(k)))) - ) + value(D(D(k))), + Dict(VariableUnit => get_unit(D(D(k)))) + ) + ) +) + +@variables t [unit = uu"s"] k(t) +D = Differential(t) + +@test equivalent( + uu"s^-1", + UnitfulUnitCheck.get_unit( + diff2term( + value(D(k)), + Dict(VariableUnit => UnitfulUnitCheck.get_unit(D(k))) + ) + ) +) + +@test equivalent( + uu"s^-2", + UnitfulUnitCheck.get_unit( + diff2term( + value(D(D(k))), + Dict(VariableUnit => UnitfulUnitCheck.get_unit(D(D(k)))) + ) ) ) @variables x y t D = Differential(t) Symbolics.diff2term(D(x)) -Symbolics.diff2term(D(sqrt(sqrt(sqrt(+(x,y)))))) -Symbolics.diff2term(D(x+y)) +Symbolics.diff2term(D(sqrt(sqrt(sqrt(+(x, y)))))) +Symbolics.diff2term(D(x + y)) From 7b2a117800e2b6d9af52ef182280f8c19f1a51e0 Mon Sep 17 00:00:00 2001 From: contradict Date: Fri, 30 Aug 2024 09:07:47 -0700 Subject: [PATCH 2/3] Add dependency on DynamicQuantities to test environment --- test/downstream/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/downstream/Project.toml b/test/downstream/Project.toml index b7c6ffdcc..7210a24dc 100644 --- a/test/downstream/Project.toml +++ b/test/downstream/Project.toml @@ -1,4 +1,5 @@ [deps] +DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821" ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" ParameterizedFunctions = "65888b18-ceab-5e60-b2b9-181511a3b968" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" From 6cc8735b2bf0bf6390d21e121ff25b606dd57044 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 30 Aug 2024 12:10:51 -0400 Subject: [PATCH 3/3] Update Project.toml --- Project.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e893e2fbd..780047fa5 100644 --- a/Project.toml +++ b/Project.toml @@ -100,6 +100,7 @@ julia = "1.10" [extras] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" +DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" Groebner = "0b43b601-686d-58a3-8a1c-6623616c7cd4" Lux = "b2108857-7c20-44ae-9111-449ecde12c47" @@ -113,4 +114,4 @@ SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test", "SafeTestsets", "Pkg", "PkgBenchmark", "PreallocationTools", "ForwardDiff", "Groebner", "BenchmarkTools", "ReferenceTests", "SymPy", "Random", "Lux", "ComponentArrays", "Nemo"] +test = ["Test", "SafeTestsets", "Pkg", "PkgBenchmark", "PreallocationTools", "ForwardDiff", "Groebner", "BenchmarkTools", "ReferenceTests", "SymPy", "Random", "Lux", "ComponentArrays", "Nemo", "DynamicQuantities"]