-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Broadcasting over VectorOfArray
does not preserve type of parent array
#410
Comments
Could you please point me to the specific errors this bug might cause in Trixi.jl (simple description is also fine)? |
It is this specific elixir, but I am unsure of why this issue would impact that test and not others. We have other tests where we use VoA wrappers around StructArrays (for example this) and those examples don't fail with the same error. |
I think this issue would still be nice to resolve, but I don't think it's what's causing some failing tests in trixi-framework/Trixi.jl#2150, so no rush on addressing this. |
Fixes #410 This specializes so that if `u.u` is not a vector, it will convert the broadcast to fix that. I couldn't find a nice generic way to use `map` so the fallback is to build the vector and convert, which seems to not be a big performance issue. For StructArrays, `convert(typeof(x), Vector(x))` fails, and so this case is specialized.
Fixes #410 This specializes so that if `u.u` is not a vector, it will convert the broadcast to fix that. I couldn't find a nice generic way to use `map` so the fallback is to build the vector and convert, which seems to not be a big performance issue. For StructArrays, `convert(typeof(x), Vector(x))` fails, and so this case is specialized.
Well it's what I had open while on a flight so it's done now |
Thank you! |
Describe the bug 🐞
Broadcasting a function over
VectorOfArray(::StructArray{SVector})
does not preserve theStructArray{SVector}
type of the parent array. Instead, it producesVectorOfArray(::Array{SVector})
Expected behavior
I expect broadcasting over
VectorOfArray(::StructArray{SVector})
to create anotherVectorOfArray(::StructArray{SVector})
.Minimal Reproducible Example 👇
I would expect
typeof(zero.(VectorOfArray(x)))
to be the same astypeof(VectorOfArray)
.Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
Related to trixi-framework/Trixi.jl#2150
The text was updated successfully, but these errors were encountered: