Skip to content

Commit

Permalink
throw error when wrong arguments are given to oblique stencil
Browse files Browse the repository at this point in the history
  • Loading branch information
Korbinian Eckstein committed Jul 26, 2024
1 parent 2720e6a commit 34dacb7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ jobs:
matrix:
version:
- '1.7'
- '1.8'
- '1.9'
- '1.10'
os:
- ubuntu-latest
arch:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantitativeSusceptibilityMappingTGV"
uuid = "bd393529-335a-4aed-902f-5de61cc7ff49"
authors = ["Korbinian Eckstein korbinian90@gmail.com"]
version = "0.5.0"
version = "0.5.1"

[deps]
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Expand Down
4 changes: 4 additions & 0 deletions src/oblique_stencil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ function dipole(x, y, z, r_treshold, direction=(0, 0, 1))
end

function stencil(; st=27, res=(1.0, 1.0, 1.0), singularity_cutout=4, direction=(0, 0, 1), gridsize=(64, 64, 64))
if any(res .== 0) || all(direction .== 0) || any(gridsize .== 0)
error("Please check the input parameters to the stencil computation. res $res, gridsize $gridsize and direction $direction must not be: any(res .== 0) || all(direction .== 0) || any(gridsize .== 0)")
end

middle = floor.(Int, gridsize ./ 2) .+ 1

coord = [((1:gridsize[i]) .- middle[i]) for i in 1:3]
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ end
@test chi_3 != chi_romeo
end

@testitem "Stencil wrong settings Error" begin
@test_throws ErrorException stencil(; res=(3,2,0))
@test_throws ErrorException stencil(; direction=(0,0,0))
@test_throws ErrorException stencil(; gridsize=(64,64,0))
@test stencil() isa Array
end

@testitem "Aqua" begin
using Aqua
Aqua.test_ambiguities(QuantitativeSusceptibilityMappingTGV)
Expand Down

1 comment on commit 34dacb7

@korbinian90
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegister register

Please sign in to comment.