changeset 1640:8e28cadfefb3 bugfix/warnings

Move `monomial` in tests into a local scope to avoid overwriting warnings
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 25 Jun 2024 20:44:06 +0200
parents 61aacc51d38a
children fddd3a906535
files test/SbpOperators/volumeops/derivatives/dissipation_test.jl test/SbpOperators/volumeops/derivatives/first_derivative_test.jl
diffstat 2 files changed, 3 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/test/SbpOperators/volumeops/derivatives/dissipation_test.jl	Tue Jun 25 15:47:05 2024 +0200
+++ b/test/SbpOperators/volumeops/derivatives/dissipation_test.jl	Tue Jun 25 20:44:06 2024 +0200
@@ -13,20 +13,9 @@
 using Sbplib.SbpOperators: dissipation_lower_closure_stencils,dissipation_upper_closure_stencils
 using Sbplib.SbpOperators: dissipation_transpose_lower_closure_stencils, dissipation_transpose_upper_closure_stencils
 
-"""
-    monomial(x,k)
-
-Evaluates ``x^k/k!` with the convetion that it is ``0`` for all ``k<0``.
-Has the property that ``d/dx monomial(x,k) = monomial(x,k-1)``
-"""
-function monomial(x,k)
-    if k < 0
-        return zero(x)
-    end
-    x^k/factorial(k)
-end
 
 @testset "undivided_skewed04" begin
+    monomial(x,k) = k < 0 ? zero(x) : x^k/factorial(k)
     g = equidistant_grid(0., 11., 20)
     D,Dᵀ = undivided_skewed04(g, 1)
 
--- a/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl	Tue Jun 25 15:47:05 2024 +0200
+++ b/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl	Tue Jun 25 20:44:06 2024 +0200
@@ -7,19 +7,6 @@
 
 using Sbplib.SbpOperators: closure_size, Stencil, VolumeOperator
 
-"""
-    monomial(x,k)
-
-Evaluates ``x^k/k!` with the convetion that it is ``0`` for all ``k<0``.
-Has the property that ``d/dx monomial(x,k) = monomial(x,k-1)``
-"""
-function monomial(x,k)
-    if k < 0
-        return zero(x)
-    end
-    x^k/factorial(k)
-end
-
 @testset "first_derivative" begin
     @testset "Constructors" begin
         stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2)
@@ -39,6 +26,8 @@
     @testset "Accuracy conditions" begin
         N = 20
         g = equidistant_grid(0//1, 2//1, N)
+
+        monomial(x,k) = k < 0 ? zero(x) : x^k/factorial(k)
         @testset for order ∈ [2,4]
             stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order)
             D₁ = first_derivative(g, stencil_set)