-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
promote fails with BitArrays #43551
Comments
I think its failing because theres no definition of a Promotion rule ( julia> using Random
julia> import Base.promote_rule
julia> promote_rule(::Type{BitMatrix},::Type{Matrix{T}}) where {T} = Matrix{T}
promote_rule (generic function with 125 methods)
julia> promote(bitrand(2,2),randn(2,2))
([1.0 0.0; 0.0 1.0], [1.3555790148282878 1.1034170972100035; 0.2637702233227674 -0.8688494447101851])
julia> This is just the first thing i tried, so there has to be a better way to write it and make it more general (including So one fix would be to include a Maybe i'm also missing something but thats what i came up with by quickly looking over it. Edit: I tried using a rule like: julia> promote_rule(::Type{BitArray},::Type{Array})= Array
promote_rule (generic function with 126 methods) in an attempt to make a generalized rule, but it doesn't seem to work: julia> promote(BitArray([1,0,1]),Array([1,3,4]))
ERROR: promotion of types BitVector and Vector{Int64} failed to change any arguments
Stacktrace:
[1] error(::String, ::String, ::String)
@ Base .\error.jl:42
[2] sametype_error(input::Tuple{BitVector, Vector{Int64}})
@ Base .\promotion.jl:316
[3] not_sametype(x::Tuple{BitVector, Vector{Int64}}, y::Tuple{BitVector, Vector{Int64}})
@ Base .\promotion.jl:310
[4] promote(x::BitVector, y::Vector{Int64})
@ Base .\promotion.jl:293
[5] top-level scope
@ REPL[22]:1 |
…itarray promotion
Fix #43551 Co-authored-by: Jakob Sachs <jakobsachs1999@gmail.com>
Defines a fallback promote_result for any AbstractArray, for the case when specific promote_rules are not defined for the specific array type. Fix #43551 Co-authored-by: Jakob Sachs <jakobsachs1999@gmail.com>
Defines a fallback promote_result for any AbstractArray, for the case when specific promote_rules are not defined for the specific array type. Add a few good promote_rules too. Fix #43551 Co-authored-by: Jakob Sachs <jakobsachs1999@gmail.com>
Defines a fallback promote_result for any AbstractArray, for the case when specific promote_rules are not defined for the specific array type. Add a few good promote_rules too. Fix #43551 Co-authored-by: Jakob Sachs <jakobsachs1999@gmail.com>
Defines a fallback promote_result for any AbstractArray, for the case when specific promote_rules are not defined for the specific array type. Add a few good promote_rules too. Fix JuliaLang#43551 Co-authored-by: Jakob Sachs <jakobsachs1999@gmail.com>
Contrast that with,
The text was updated successfully, but these errors were encountered: