Mercurial > repos > public > sbplib_julia
changeset 1575:efe1fc4cb6b0
Improve error message when giving arguments of different length to equidistant_grid()
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 25 Apr 2024 14:42:30 +0200 |
parents | ec5e7926c37b |
children | 7f5e4d2a5112 d68d02dd882f bb4c119e91fa |
files | src/Grids/equidistant_grid.jl test/Grids/equidistant_grid_test.jl |
diffstat | 2 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl Sat Apr 13 23:49:39 2024 +0200 +++ b/src/Grids/equidistant_grid.jl Thu Apr 25 14:42:30 2024 +0200 @@ -107,6 +107,9 @@ behaviors. """ function equidistant_grid(limit_lower, limit_upper, dims::Vararg{Int}) + if !(length(limit_lower) == length(limit_upper) == length(dims)) + throw(ArgumentError("All arguments must be of the same length")) + end gs = map(equidistant_grid, limit_lower, limit_upper, dims) return TensorGrid(gs...) end
--- a/test/Grids/equidistant_grid_test.jl Sat Apr 13 23:49:39 2024 +0200 +++ b/test/Grids/equidistant_grid_test.jl Thu Apr 25 14:42:30 2024 +0200 @@ -117,6 +117,8 @@ @test_throws DomainError equidistant_grid((1.0,1.0),(1.0,1.0), 1, 1) @test_throws DomainError equidistant_grid((1.0,1.0),(-1.0,-1.0), 1, 1) + @test_throws ArgumentError equidistant_grid((0.0,),(8.0,5.0), 4, 3, 4) + @testset "Base" begin @test eltype(equidistant_grid(0.0, 1.0, 4)) == Float64 @test eltype(equidistant_grid((0,0),(1,3), 4, 3)) <: AbstractVector{Float64}