-
Notifications
You must be signed in to change notification settings - Fork 38
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
real(::Fill)
gives an array of arrays?
#145
Comments
This actually looks like a bug in Julia, why would 0-dimensional arrays have a different broadcasting behaviour: julia> x + x
0-dimensional Array{Int64, 0}:
2
julia> x .+ x
2 |
I do think it's the intended behaviour, although I don't see it mentioned in the manual. Maybe broadcast never produces a 0-array, e.g. |
I think it’s more “unintended consequence of design: it follows because 0-dimensional arrays are treated like constants in broadcasting with vectors/matrices, but the special case where everything is 0-dimensional was probably not thought through. I don’t think it’s going to change in Julia v1.x so yes I agree we should make |
JuliaLang/julia#28866 is the issue, it seems. |
Ah, I encountered the same issue: |
Can I maybe add that this still exists, and also is not consistent? It works for julia> A = Fill(1im)
0-dimensional Fill{Complex{Int64}}, with entry equal to 0 + 1im
julia> conj(A), real(A), imag(A), -A
(fill(Fill(0 - 1im)), fill(Fill(0)), fill(Fill(1)), Fill(0 - 1im))
julia> B = fill(1im)
0-dimensional Array{Complex{Int64}, 0}:
0 + 1im
julia> conj(B), real(B), imag(B), -B
(fill(0 - 1im), fill(0), fill(1), fill(0 - 1im)) Would you be ok with a PR that just manually fixes this by implementing the # makes 0-dimensional arrays behave like Julia Base
@inline function Base.broadcast_preserving_zero_d(f, As::AbstractFill...)
bc = broadcasted(f, As...)
return Base.materialize(bc)
end If we'd agree on this, I can add some tests as well. [edit] |
This is surprising:
I guess it comes from this difference, via
broadcast_preserving_zero_d
:The text was updated successfully, but these errors were encountered: