Skip to content

Commit 471e5c2

Browse files
fix: fix unnecessary oneunit call in get_unit
1 parent 3a110df commit 471e5c2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/systems/unit_check.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ get_unit(x::SciMLBase.NullParameters) = unitless
7777
get_unit(op::typeof(instream), args) = get_unit(args[1])
7878

7979
function get_unit(op, args) # Fallback
80-
result = oneunit(op(get_unit.(args)...))
80+
result = op(get_unit.(args)...)
8181
try
8282
get_unit(result)
8383
catch

test/units.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,10 @@ sys = complete(sys)
240240
@test isequal(ModelingToolkit.getdefault(sys.pt.a), sys.v * sys.τ)
241241
@test ModelingToolkit.getdefault(sys.v) 2.0
242242
@test ModelingToolkit.getdefault(sys.τ) 3.0
243+
244+
@testset "Issue#3017" begin
245+
@constants c = 1 [unit = us"mol/nmol"]
246+
@variables k(t) [unit = us"mol/nmol"]
247+
@test ModelingToolkit.get_unit(c) == ModelingToolkit.get_unit(-c)
248+
@test_nowarn NonlinearSystem([k ~ c], [k], []; name=:example)
249+
end

0 commit comments

Comments
 (0)