Skip to content

Commit b13cb14

Browse files
Add more unit tests with edge case fixes
1 parent c9912c3 commit b13cb14

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/DataLayouts/non_extruded_broadcasted.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ end
9292
Base.throw_boundserror(bc, (I,))
9393
end
9494
end
95+
# getindex on DefaultArrayStyle{0} ignores the
96+
# index value, so this should always be safe
97+
@inline Base.checkbounds(bc::NonExtrudedBroadcasted{Style}, I::Union{Integer, CartesianIndex{0}}) where {Style <: Base.Broadcast.DefaultArrayStyle{0}} = nothing
98+
9599

96100
# To handle scalar cases, let's just switch back to
97101
# Base.Broadcast.Broadcasted and allow cartesian indexing:

test/DataLayouts/unit_non_extruded_broadcast.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ end
7474
z_topology = Topologies.IntervalTopology(context, z_mesh)
7575
cspace = Spaces.CenterFiniteDifferenceSpace(z_topology)
7676
f = Fields.Field(FT, cspace)
77+
@. f = FT(2.0)
7778
bc = @lazy @. f = FT(2.0)
7879
bc = Base.Broadcast.instantiate(bc)
7980
bc = DataLayouts.to_non_extruded_broadcasted(bc)
81+
# @test bc[1] == FT(2.0)
82+
# @test bc[2] == FT(2.0)
8083
end
8184

8285
@testset "Conceptual test (to compare against Base)" begin

0 commit comments

Comments
 (0)