Mercurial > repos > public > sbplib_julia
comparison test/Grids/grid_test.jl @ 1397:86026367a9ff feature/grids/scalar_eval_on
Support evaluating scalars on grids
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Tue, 15 Aug 2023 22:55:25 +0200 |
| parents | fa3695f634de |
| children | 276c38a48aac d50ea06813d5 |
comparison
equal
deleted
inserted
replaced
| 1384:851d1e4ab3de | 1397:86026367a9ff |
|---|---|
| 36 @test eval_on(ZeroDimGrid(@SVector[3.,2.]), x̄->x̄[1]+x̄[2]) == fill(5.) | 36 @test eval_on(ZeroDimGrid(@SVector[3.,2.]), x̄->x̄[1]+x̄[2]) == fill(5.) |
| 37 | 37 |
| 38 @test eval_on(ZeroDimGrid(1.), x̄->2x̄) isa LazyArray | 38 @test eval_on(ZeroDimGrid(1.), x̄->2x̄) isa LazyArray |
| 39 @test eval_on(ZeroDimGrid(1.), x̄->2x̄) == fill(2.) | 39 @test eval_on(ZeroDimGrid(1.), x̄->2x̄) == fill(2.) |
| 40 | 40 |
| 41 @test eval_on(ZeroDimGrid(@SVector[1.,2.]), π) isa LazyArray | |
| 42 @test eval_on(ZeroDimGrid(@SVector[1.,2.]), π) == fill(π) | |
| 43 | |
| 41 @test eval_on(EquidistantGrid(range(0,1,length=4)), x->2x) isa LazyArray | 44 @test eval_on(EquidistantGrid(range(0,1,length=4)), x->2x) isa LazyArray |
| 42 @test eval_on(EquidistantGrid(range(0,1,length=4)), x->2x) == 2 .* range(0,1,length=4) | 45 @test eval_on(EquidistantGrid(range(0,1,length=4)), x->2x) == 2 .* range(0,1,length=4) |
| 43 | 46 |
| 44 | 47 |
| 45 g = equidistant_grid((5,3), (0.0,0.0), (2.0,1.0)) | 48 g = equidistant_grid((5,3), (0.0,0.0), (2.0,1.0)) |
| 46 | 49 |
| 47 @test eval_on(g, x̄ -> 0.) isa LazyArray | 50 @test eval_on(g, x̄ -> 0.) isa LazyArray |
| 48 @test eval_on(g, x̄ -> 0.) == fill(0., (5,3)) | 51 @test eval_on(g, x̄ -> 0.) == fill(0., (5,3)) |
| 49 | 52 |
| 50 @test eval_on(g, x̄ -> sin(x̄[1])*cos(x̄[2])) == map(x̄->sin(x̄[1])*cos(x̄[2]), g) | 53 @test eval_on(g, x̄ -> sin(x̄[1])*cos(x̄[2])) == map(x̄->sin(x̄[1])*cos(x̄[2]), g) |
| 54 | |
| 55 @test eval_on(g, π) == fill(π, (5,3)) | |
| 51 | 56 |
| 52 # Vector valued function | 57 # Vector valued function |
| 53 @test eval_on(g, x̄ -> @SVector[x̄[2], x̄[1]]) isa LazyArray{SVector{2,Float64}} | 58 @test eval_on(g, x̄ -> @SVector[x̄[2], x̄[1]]) isa LazyArray{SVector{2,Float64}} |
| 54 @test eval_on(g, x̄ -> @SVector[x̄[2], x̄[1]]) == map(x̄ -> @SVector[x̄[2], x̄[1]], g) | 59 @test eval_on(g, x̄ -> @SVector[x̄[2], x̄[1]]) == map(x̄ -> @SVector[x̄[2], x̄[1]], g) |
| 55 | 60 |
