Skip to content

Commit 9454ebc

Browse files
Merge branch 'main' into glw/better-nan-checker
2 parents 3d73e48 + 2dc85f0 commit 9454ebc

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/BoundaryConditions/fill_halo_regions_zipper.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ end
7777

7878
# We substitute the redundant part of the last row to ensure consistency
7979
@inbounds u[i, Ny, k] = ifelse(i > Nx ÷ 2, sign * u[i′, Ny, k], u[i, Ny, k])
80+
8081
return nothing
8182
end
8283

src/Fields/field.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,10 @@ for reduction in (:sum, :maximum, :minimum, :all, :any, :prod)
722722
end
723723
end
724724

725+
# Improve me! We can should both the extrama in one single reduction instead of two
726+
Base.extrema(c::AbstractField; kwargs...) = (minimum(c; kwargs...), maximum(c; kwargs...))
727+
Base.extrema(f, c::AbstractField; kwargs...) = (minimum(f, c; kwargs...), maximum(f, c; kwargs...))
728+
725729
function Statistics._mean(f, c::AbstractField, ::Colon; condition = nothing, mask = 0)
726730
operator = condition_operand(f, c, condition, mask)
727731
return sum(operator) / conditional_length(operator)

src/MultiRegion/multi_region_field.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ end
120120
set!(mrf::MultiRegionField, v) = apply_regionally!(set!, mrf, v)
121121
fill!(mrf::MultiRegionField, v) = apply_regionally!(fill!, mrf, v)
122122

123+
set!(mrf::MultiRegionField, a::Number) = apply_regionally!(set!, mrf, a)
124+
fill!(mrf::MultiRegionField, a::Number) = apply_regionally!(fill!, mrf, a)
125+
123126
set!(mrf::MultiRegionField, f::Function) = apply_regionally!(set!, mrf, f)
124127
set!(u::MultiRegionField, v::MultiRegionField) = apply_regionally!(set!, u, v)
125128
compute!(mrf::GriddedMultiRegionField, time=nothing) = apply_regionally!(compute!, mrf, time)

test/test_field.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ function run_field_reduction_tests(FT, arch)
9292
@test maximum(abs, ϕ) maximum(abs, ϕ_vals) atol=ε
9393
@test mean(abs2, ϕ) mean(abs2, ϕ) atol=ε
9494

95+
@test extrema(ϕ) == (minimum(ϕ), maximum(ϕ))
96+
@test extrema(, ϕ) == (minimum(, ϕ), maximum(, ϕ))
97+
9598
for dims in dims_to_test
9699
@test all(isapprox(minimum(ϕ, dims=dims), minimum(ϕ_vals, dims=dims), atol=4ε))
97100
@test all(isapprox(maximum(ϕ, dims=dims), maximum(ϕ_vals, dims=dims), atol=4ε))
@@ -630,4 +633,4 @@ end
630633
@test_throws BoundsError cvvv[:, :, k_top-2:k_top]
631634
end
632635
end
633-
end
636+
end

0 commit comments

Comments
 (0)