From 5a6f90b23e94dd5eb7004d8499486d62d71e8220 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 24 Feb 2020 08:09:47 -0500 Subject: [PATCH 1/2] Remove type mapping it's not used by the constructors anymore --- src/utils.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index c024e6d56e..0708f5fd66 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -90,8 +90,6 @@ function build_function(rhss, vs, ps = (), args = (), conv = simplified_expr, ex return $arr_bounds_block else X = $bounds_block - T = promote_type(map(typeof,X)...) - map(T,X) construct = $_constructor return construct(X) end From 11dc663ccd04c7c95639ecb59634b55e7d50e0a5 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Mon, 24 Feb 2020 09:11:00 -0500 Subject: [PATCH 2/2] fix MTK tests due to one(x) change in StaticArrays --- src/function_registration.jl | 1 + src/simplify.jl | 2 +- test/direct.jl | 1 + test/runtests.jl | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/function_registration.jl b/src/function_registration.jl index 092e4a9421..582cdcfe89 100644 --- a/src/function_registration.jl +++ b/src/function_registration.jl @@ -59,3 +59,4 @@ Base.:^(x::Expression,y::T) where T <: Rational = Operation(Base.:^, Expression[ @register Base.conj(x) @register Base.getindex(x,i) Base.getindex(x::Operation,i::Int64) = Operation(getindex,[x,i]) +Base.one(::Operation) = 1 diff --git a/src/simplify.jl b/src/simplify.jl index 17e098590d..8302b4a057 100644 --- a/src/simplify.jl +++ b/src/simplify.jl @@ -14,7 +14,7 @@ end simplify_constants(x, shorten_tree) = x simplify_constants(x) = simplify_constants(x, true) - +Base.isone(x::Operation) = x.op == one || x.op == Constant && isone(x.args) const AC_OPERATORS = (*, +) function _simplify_constants(O::Operation, shorten_tree) diff --git a/test/direct.jl b/test/direct.jl index 837380267a..f8bfd896b9 100644 --- a/test/direct.jl +++ b/test/direct.jl @@ -26,6 +26,7 @@ for i in 1:3 ∇ = ModelingToolkit.gradient(eqs[i],[x,y,z]) @test isequal(∂[i,:],∇) end + @test all(isequal.(ModelingToolkit.gradient(eqs[1],[x,y,z]),[σ * -1,σ,0])) @test all(isequal.(ModelingToolkit.hessian(eqs[1],[x,y,z]),0)) diff --git a/test/runtests.jl b/test/runtests.jl index 941809e8bc..9fb7a9e367 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,4 +9,4 @@ using ModelingToolkit, Test @testset "Constraints Test" begin include("constraints.jl") end @testset "PDE Construction Test" begin include("pde.jl") end @testset "Distributed Test" begin include("distributed.jl") end -#@testset "Latexify recipes Test" begin include("latexify.jl") end +@testset "Latexify recipes Test" begin include("latexify.jl") end