Skip to content
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

Fix downstream test #1250

Merged
merged 3 commits into from
Aug 30, 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
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
1 change: 1 addition & 0 deletions test/downstream/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
50 changes: 37 additions & 13 deletions test/downstream/modeling_toolkit_utils.jl
Original file line number Diff line number Diff line change
@@ -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))
Loading