Skip to content

Commit 74e9d56

Browse files
committed
up
1 parent baea381 commit 74e9d56

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ end
158158
function check_var_types(sys_type::Type{T}, dvs) where T <: AbstractSystem
159159
any(u -> !(symtype(u) <: Number), dvs) && error("The type of unknown variables must be a numeric type.")
160160
if sys_type == ODESystem || sys_type == SDESystem || sys_type == PDESystem
161-
any(u -> !(symtype(u) <: Float), dvs) && error("The type of unknown variables for an SDESystem, PDESystem, or ODESystem must be a float.")
161+
any(u -> !(symtype(u) <: AbstractFloat), dvs) && error("The type of unknown variables for an SDESystem, PDESystem, or ODESystem must be a float.")
162162
end
163163
nothing
164164
end

test/odesystem.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,3 +1552,10 @@ end
15521552
expected_tstops = unique!(sort!(vcat(0.0:0.075:10.0, 0.1, 0.2, 0.65, 0.35, 0.45)))
15531553
@test all(x -> any(isapprox(x, atol = 1e-6), sol2.t), expected_tstops)
15541554
end
1555+
1556+
let
1557+
@parameters p d
1558+
@variables X(t)::Int64
1559+
eq = D(X) ~ p - d*X
1560+
@test_throws Exception @mtkbuild osys = ODESystem([eq], t)
1561+
end

test/sdesystem.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,3 +868,12 @@ end
868868
@test length(ModelingToolkit.get_noiseeqs(sys)) == 1
869869
@test length(observed(sys)) == 1
870870
end
871+
872+
# Test validating types of states
873+
let
874+
@parameters p d
875+
@variables X(t)::Int64
876+
@brownian z
877+
eq2 = D(X) ~ p - d*X + z
878+
@test_throws Exception @mtkbuild ssys = System([eq2], t)
879+
end

0 commit comments

Comments
 (0)