Skip to content

Commit

Permalink
Less piracy of hcat and vcat (#515)
Browse files Browse the repository at this point in the history
* remove most-bad methods

* up
  • Loading branch information
ericphanson committed Nov 19, 2023
1 parent c6a21df commit 8be99c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Convex"
uuid = "f65535da-76fb-5f13-bab9-19810c17039a"
version = "0.15.3"
version = "0.15.4"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
4 changes: 4 additions & 0 deletions docs/src/release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release notes

## v0.15.4 (October 24, 2023)

* Convex's piracy of `hcat` and `vcat` was made less severe, allowing precompilation of Convex.jl on Julia 1.10.

## v0.15.3 (February 11, 2023)

* Add support for LDLFactorizations v0.10 [#496](https://github.com/jump-dev/Convex.jl/pull/496).
Expand Down
12 changes: 8 additions & 4 deletions src/atoms/affine/stack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,25 @@ end

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

hcat(args::AbstractExpr...) = HcatAtom(args...)
function hcat(args::AbstractExprOrValue...)
function Base.hcat(args::AbstractExprOrValue...)
if all(Base.Fix2(isa, Value), args)
return Base.cat(args..., dims = Val(2))
end
return HcatAtom(map(arg -> convert(AbstractExpr, arg), args)...)
end
hcat(args::Value...) = Base.cat(args..., dims = Val(2))

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

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

2 comments on commit 8be99c2

@ericphanson
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/95614

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.15.4 -m "<description of version>" 8be99c2e97bb8d03829eafaa80e1ac35388846a7
git push origin v0.15.4

Please sign in to comment.