Skip to content

Commit 8be99c2

Browse files
authored
Less piracy of hcat and vcat (#515)
* remove most-bad methods * up
1 parent c6a21df commit 8be99c2

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Convex"
22
uuid = "f65535da-76fb-5f13-bab9-19810c17039a"
3-
version = "0.15.3"
3+
version = "0.15.4"
44

55
[deps]
66
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

docs/src/release_notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release notes
22

3+
## v0.15.4 (October 24, 2023)
4+
5+
* Convex's piracy of `hcat` and `vcat` was made less severe, allowing precompilation of Convex.jl on Julia 1.10.
6+
37
## v0.15.3 (February 11, 2023)
48

59
* Add support for LDLFactorizations v0.10 [#496](https://github.com/jump-dev/Convex.jl/pull/496).

src/atoms/affine/stack.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,25 @@ end
112112

113113
# * `Value` is not owned by Convex.jl
114114
# * splatting creates zero-argument functions, which again are not owned by Convex.jl
115+
Base.hcat(args::AbstractExpr...) = HcatAtom(args...)
115116

116-
hcat(args::AbstractExpr...) = HcatAtom(args...)
117-
function hcat(args::AbstractExprOrValue...)
117+
function Base.hcat(args::AbstractExprOrValue...)
118+
if all(Base.Fix2(isa, Value), args)
119+
return Base.cat(args..., dims = Val(2))
120+
end
118121
return HcatAtom(map(arg -> convert(AbstractExpr, arg), args)...)
119122
end
120-
hcat(args::Value...) = Base.cat(args..., dims = Val(2))
121123

122124
# TODO: implement vertical concatenation in a more efficient way
123125
vcat(args::AbstractExpr...) = transpose(HcatAtom(map(transpose, args)...))
124126
function vcat(args::AbstractExprOrValue...)
127+
if all(Base.Fix2(isa, Value), args)
128+
return Base.cat(args..., dims = Val(1))
129+
end
125130
return transpose(
126131
HcatAtom(map(arg -> transpose(convert(AbstractExpr, arg)), args)...),
127132
)
128133
end
129-
vcat(args::Value...) = Base.cat(args..., dims = Val(1)) # Note: this makes general vcat slower for anyone using Convex...
130134

131135
function hvcat(rows::Tuple{Vararg{Int}}, args::AbstractExprOrValue...)
132136
nbr = length(rows)

0 commit comments

Comments
 (0)