comparison src/Grids/equidistant_grid.jl @ 1248:a5f2372d0e87 refactor/grids

Add argument checking to equdistant_grid
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 22 Feb 2023 12:42:08 +0100
parents 2abec782cf5b
children 215f36712332
comparison
equal deleted inserted replaced
1247:2abec782cf5b 1248:a5f2372d0e87
92 completely integer grid, `equidistant_grid` will still return a floating point 92 completely integer grid, `equidistant_grid` will still return a floating point
93 grid. This simlifies the implementation and avoids certain surprise 93 grid. This simlifies the implementation and avoids certain surprise
94 behaviours. 94 behaviours.
95 """ 95 """
96 function equidistant_grid(size::Dims, limit_lower, limit_upper) 96 function equidistant_grid(size::Dims, limit_lower, limit_upper)
97 if any(size .<= 0)
98 throw(DomainError("all components of size must be postive"))
99 end
100
101 if any(limit_upper.-limit_lower .<= 0)
102 throw(DomainError("all side lengths must be postive"))
103 end
104
97 gs = map(size, limit_lower, limit_upper) do s,l,u 105 gs = map(size, limit_lower, limit_upper) do s,l,u
98 EquidistantGrid(range(l, u, length=s)) # TBD: Should it use LinRange instead? 106 EquidistantGrid(range(l, u, length=s)) # TBD: Should it use LinRange instead?
99 end 107 end
100 108
101 return TensorGrid(gs...) 109 return TensorGrid(gs...)