Mercurial > repos > public > sbplib_julia
comparison test/Grids/equidistant_grid_test.jl @ 1829:871f3f1decea refactor/grids/iterable_boundary_indices
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 20 Oct 2024 21:38:09 +0200 |
parents | 98ae79eb0709 471a948cd2b2 |
children | edee7d677efb f93ba5832146 |
comparison
equal
deleted
inserted
replaced
1828:8adecef380b4 | 1829:871f3f1decea |
---|---|
1 using Sbplib.Grids | 1 using Diffinitive.Grids |
2 using Test | 2 using Test |
3 using Sbplib.RegionIndices | 3 using Diffinitive.LazyTensors |
4 using Sbplib.LazyTensors | |
5 | 4 |
6 | 5 |
7 @testset "EquidistantGrid" begin | 6 @testset "EquidistantGrid" begin |
8 @test EquidistantGrid(0:0.1:10) isa EquidistantGrid | 7 @test EquidistantGrid(0:0.1:10) isa EquidistantGrid |
9 @test EquidistantGrid(range(0,1,length=10)) isa EquidistantGrid | 8 @test EquidistantGrid(range(0,1,length=10)) isa EquidistantGrid |
54 @testset "inverse_spacing" begin | 53 @testset "inverse_spacing" begin |
55 @test inverse_spacing(EquidistantGrid(0:10)) == 1 | 54 @test inverse_spacing(EquidistantGrid(0:10)) == 1 |
56 @test inverse_spacing(EquidistantGrid(0:0.1:10)) == 10 | 55 @test inverse_spacing(EquidistantGrid(0:0.1:10)) == 10 |
57 end | 56 end |
58 | 57 |
58 @testset "min_spacing" begin | |
59 @test min_spacing(EquidistantGrid(0:10)) == 1 | |
60 @test min_spacing(EquidistantGrid(0:0.1:10)) == 0.1 | |
61 end | |
62 | |
59 @testset "boundary_identifiers" begin | 63 @testset "boundary_identifiers" begin |
60 g = EquidistantGrid(0:0.1:10) | 64 g = EquidistantGrid(0:0.1:10) |
61 @test boundary_identifiers(g) == (Lower(), Upper()) | 65 @test boundary_identifiers(g) == (LowerBoundary(), UpperBoundary()) |
62 @inferred boundary_identifiers(g) | 66 @inferred boundary_identifiers(g) |
63 end | 67 end |
64 | 68 |
65 @testset "boundary_grid" begin | 69 @testset "boundary_grid" begin |
66 g = EquidistantGrid(0:0.1:1) | 70 g = EquidistantGrid(0:0.1:1) |
67 @test boundary_grid(g, Lower()) == ZeroDimGrid(0.0) | 71 @test boundary_grid(g, LowerBoundary()) == ZeroDimGrid(0.0) |
68 @test boundary_grid(g, Upper()) == ZeroDimGrid(1.0) | 72 @test boundary_grid(g, UpperBoundary()) == ZeroDimGrid(1.0) |
69 end | 73 end |
70 | 74 |
71 @testset "boundary_indices" begin | 75 @testset "boundary_indices" begin |
72 g = EquidistantGrid(0:0.1:1) | 76 g = EquidistantGrid(0:0.1:1) |
73 @test boundary_indices(g, Lower()) == 1 | 77 @test boundary_indices(g, LowerBoundary()) == 1 |
74 @test boundary_indices(g, Upper()) == 11 | 78 @test boundary_indices(g, UpperBoundary()) == 11 |
75 | 79 |
76 gf = collect(g) | 80 gf = collect(g) |
77 @test gf[boundary_indices(g, Lower())] == gf[1] | 81 @test gf[boundary_indices(g, LowerBoundary())] == gf[1] |
78 @test gf[boundary_indices(g, Upper())] == gf[11] | 82 @test gf[boundary_indices(g, UpperBoundary())] == gf[11] |
79 | 83 |
80 g = EquidistantGrid(2:0.1:10) | 84 g = EquidistantGrid(2:0.1:10) |
81 @test boundary_indices(g, Lower()) == 1 | 85 @test boundary_indices(g, LowerBoundary()) == 1 |
82 @test boundary_indices(g, Upper()) == 81 | 86 @test boundary_indices(g, UpperBoundary()) == 81 |
83 end | 87 end |
84 | 88 |
85 @testset "refine" begin | 89 @testset "refine" begin |
86 g = EquidistantGrid(0:0.1:1) | 90 g = EquidistantGrid(0:0.1:1) |
87 @test refine(g, 1) == g | 91 @test refine(g, 1) == g |
108 | 112 |
109 | 113 |
110 @testset "equidistant_grid" begin | 114 @testset "equidistant_grid" begin |
111 @test equidistant_grid(0.0,1.0, 4) isa EquidistantGrid | 115 @test equidistant_grid(0.0,1.0, 4) isa EquidistantGrid |
112 @test equidistant_grid((0.0,0.0),(8.0,5.0), 4, 3) isa TensorGrid | 116 @test equidistant_grid((0.0,0.0),(8.0,5.0), 4, 3) isa TensorGrid |
117 @test equidistant_grid((0.0,),(8.0,), 4) isa TensorGrid | |
113 | 118 |
114 # constuctor | 119 # constuctor |
115 @test_throws DomainError equidistant_grid(0.0, 1.0, 0) | 120 @test_throws DomainError equidistant_grid(0.0, 1.0, 0) |
116 @test_throws DomainError equidistant_grid(1.0, 1.0, 1) | 121 @test_throws DomainError equidistant_grid(1.0, 1.0, 1) |
117 @test_throws DomainError equidistant_grid(1.0, -1.0, 1) | 122 @test_throws DomainError equidistant_grid(1.0, -1.0, 1) |