Skip to content

Commit

Permalink
Merge branch 'dev' into jc/test_tri_node_reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
jlchan authored Dec 10, 2023
2 parents 50230c9 + 1c0cfe7 commit 99f7971
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
17 changes: 1 addition & 16 deletions src/named_array_partition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Base.propertynames(x::NamedArrayPartition) = propertynames(getfield(x, :names_to
Base.getproperty(x::NamedArrayPartition, s::Symbol) =
getindex(ArrayPartition(x).x, getproperty(getfield(x, :names_to_indices), s))

# !!! this won't work if `v` isn't the same size as
# this enables x.s = some_array.
@inline function Base.setproperty!(x::NamedArrayPartition, s::Symbol, v)
index = getproperty(getfield(x, :names_to_indices), s)
ArrayPartition(x).x[index] .= v
Expand All @@ -62,21 +62,6 @@ Base.mapreduce(f, op, x::NamedArrayPartition) = mapreduce(f, op, ArrayPartition(
Base.similar(x::NamedArrayPartition{T, S, NT}) where {T, S, NT} =
NamedArrayPartition{T, S, NT}(similar(ArrayPartition(x)), getfield(x, :names_to_indices))

# # return NamedArrayPartition when possible, otherwise next best thing of the correct size
# function Base.similar(x::ArrayPartition, dims::NTuple{N,Int}) where {N}
# if dims == size(x)
# return similar(x)
# else
# return similar(ArrayPartition(x).x[1], eltype(x), dims)
# end
# end

# # similar array partition of common type
# @inline function Base.similar(A::ArrayPartition, ::Type{T}) where {T}
# N = npartitions(A)
# ArrayPartition(i->similar(A.x[i], T), N)
# end

# broadcasting
Base.BroadcastStyle(::Type{<:NamedArrayPartition}) = Broadcast.ArrayStyle{NamedArrayPartition}()
function Base.similar(bc::Broadcast.Broadcasted{Broadcast.ArrayStyle{NamedArrayPartition}},
Expand Down
2 changes: 1 addition & 1 deletion test/named_array_partition_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@test (@capture_out Base.show(stdout, MIME"text/plain"(), x)) == "(a = [1.0], b = [2.0])"

using StructArrays
using StartUpDG: SVector
using StaticArrays: SVector
x = NamedArrayPartition(a = StructArray{SVector{2, Float64}}((ones(5), 2*ones(5))),
b = StructArray{SVector{2, Float64}}((3 * ones(2,2), 4*ones(2,2))))
@test typeof(x.a) <: StructVector{<:SVector{2}}
Expand Down

0 comments on commit 99f7971

Please sign in to comment.