-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1250 from contradict/fix_mtk_downstream
Fix downstream test
- Loading branch information
Showing
3 changed files
with
40 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |