JuliaLinearAlgebra / LinearMaps.jl

A Julia package for defining and working with linear maps, also known as linear transformations or linear operators acting on vectors. The only requirement for a LinearMap is that it can act on a vector (by multiplication) efficiently.
Other
303 stars 42 forks source link

`hvcat` type piracy breaks Manifolds.jl on Julia 1.10 #219

Closed mateuszbaran closed 8 months ago

mateuszbaran commented 12 months ago

Resolving #214 uncovered another issue:

  MethodError: hvcat(::Tuple{Int64, Int64}, ::UniformScaling{Bool}, ::Matrix{Float64}, ::Matrix{Float64}, ::UniformScaling{Bool}) is ambiguous.

  Candidates:
    hvcat(rows::Tuple{Vararg{Int64}}, As::Union{AbstractArray, LinearAlgebra.AbstractQ, UniformScaling, LinearMaps.LinearMap}...)
      @ LinearMaps ~/.julia/packages/LinearMaps/6ej60/src/blockmap.jl:165
    hvcat(rows::Tuple{Vararg{Int64}}, A::Union{Number, AbstractArray, UniformScaling}...)
      @ LinearAlgebra ~/hostedtoolcache/julia/1.10.0-beta3/x64/share/julia/stdlib/v1.10/LinearAlgebra/src/uniformscaling.jl:447

  Possible fix, define
    hvcat(::Tuple{Vararg{Int64}}, ::Vararg{Union{AbstractArray, UniformScaling}})

See here for CI log: https://github.com/JuliaManifolds/Manifolds.jl/actions/runs/6453880959/job/17518302750?pr=648 .

dkarrasch commented 12 months ago

That is because https://github.com/JuliaLang/julia/pull/51132 hasn't been backported yet. Can you please check on nightly if the issue is present there?

mateuszbaran commented 12 months ago

I've recently stopped running tests of Manifolds.jl on nightly because it fails too often. I'll wait for the next prerelease of Julia then.

dkarrasch commented 12 months ago

Sure, or test the failing test locally, not the entire test suite.

baggepinnen commented 11 months ago

This has broken a lot of functionality in the control-systems packages as well. Aren't methods like this one

Base.vcat(As::Union{LinearMap, UniformScaling, AbstractArray, AbstractQ}...)

super piracy?

I expect this to work

julia> [randn(1,1) I; I randn(1,1)]
2×2 Matrix{Float64}:
 0.791215   1.0
 1.0       -0.779665

But after loading LinearMaps.jl v3.11.1 on julia v1.10-beta3, I get

julia> [randn(1,1) I; I randn(1,1)]
ERROR: MethodError: hvcat(::Tuple{Int64, Int64}, ::Matrix{Float64}, ::UniformScaling{Bool}, ::UniformScaling{Bool}, ::Matrix{Float64}) is ambiguous.

Candidates:
  hvcat(rows::Tuple{Vararg{Int64}}, As::Union{AbstractArray, LinearAlgebra.AbstractQ, UniformScaling, LinearMaps.LinearMap}...)
    @ LinearMaps ~/.julia/packages/LinearMaps/6ej60/src/blockmap.jl:165
  hvcat(rows::Tuple{Vararg{Int64}}, A::Union{Number, AbstractArray, UniformScaling}...)
    @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/uniformscaling.jl:447

Possible fix, define
  hvcat(::Tuple{Vararg{Int64}}, ::Vararg{Union{AbstractArray, UniformScaling}})

Stacktrace:
 [1] top-level scope
   @ REPL[12]:1
dkarrasch commented 8 months ago

I think this is resolved, right?

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using LinearAlgebra, LinearMaps
Precompiling LinearMaps
  1 dependency successfully precompiled in 3 seconds

julia> [randn(1,1) I; I randn(1,1)]
2×2 Matrix{Float64}:
 -1.11862  1.0
  1.0      0.63299
mateuszbaran commented 8 months ago

Manifolds.jl works now but type piracy is something that should be avoided.