From 3b0cd7af1e4bce3e51826f5c87485c2ac1b295d0 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Fri, 2 Nov 2018 12:06:50 -0700 Subject: [PATCH] Don't overwrite Base.vect for numbers with a different implementation Fixes https://github.com/JuliaOpt/Convex.jl/issues/241 --- src/atoms/affine/stack.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/atoms/affine/stack.jl b/src/atoms/affine/stack.jl index 3d1f4aa59..a362fe472 100644 --- a/src/atoms/affine/stack.jl +++ b/src/atoms/affine/stack.jl @@ -132,8 +132,15 @@ function hvcat(rows::Tuple{Vararg{Int}}, args::AbstractExprOrValue...) return vcat(rs...) end +_isexpr(x::Union{T,Type{T}}) where {T<:AbstractExpr} = true +_isexpr(x) = false -Base.vect(args::T...) where {T<:AbstractExpr} = transpose(HcatAtom(map(transpose, args)...)) Base.vect(args::AbstractExpr...) = transpose(HcatAtom(map(transpose, args)...)) -Base.vect(args::AbstractExprOrValue...) = transpose(HcatAtom(map(arg -> transpose(convert(AbstractExpr, arg)), args)...)) -Base.vect(args::Value...) = collect(args) + +function Base.vect(args::AbstractExprOrValue...) + if any(_isexpr, args) + transpose(HcatAtom(map(arg -> transpose(convert(AbstractExpr, arg)), args)...)) + else + invoke(Base.vect, Tuple{Vararg{Any}}, args...) + end +end