comparison test/Grids/equidistant_grid_test.jl @ 1720:7fdc348f91ff feature/lazy_tensors/sparse_conversions

Merge with default
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Thu, 05 Sep 2024 08:26:57 -0700
parents b5690ab5f0b8
children 471a948cd2b2
comparison
equal deleted inserted replaced
1709:40dffe6e2ecb 1720:7fdc348f91ff
1 using Sbplib.Grids 1 using Sbplib.Grids
2 using Test 2 using Test
3 using Sbplib.RegionIndices
4 using Sbplib.LazyTensors 3 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
61 @test min_spacing(EquidistantGrid(0:0.1:10)) == 0.1 60 @test min_spacing(EquidistantGrid(0:0.1:10)) == 0.1
62 end 61 end
63 62
64 @testset "boundary_identifiers" begin 63 @testset "boundary_identifiers" begin
65 g = EquidistantGrid(0:0.1:10) 64 g = EquidistantGrid(0:0.1:10)
66 @test boundary_identifiers(g) == (Lower(), Upper()) 65 @test boundary_identifiers(g) == (LowerBoundary(), UpperBoundary())
67 @inferred boundary_identifiers(g) 66 @inferred boundary_identifiers(g)
68 end 67 end
69 68
70 @testset "boundary_grid" begin 69 @testset "boundary_grid" begin
71 g = EquidistantGrid(0:0.1:1) 70 g = EquidistantGrid(0:0.1:1)
72 @test boundary_grid(g, Lower()) == ZeroDimGrid(0.0) 71 @test boundary_grid(g, LowerBoundary()) == ZeroDimGrid(0.0)
73 @test boundary_grid(g, Upper()) == ZeroDimGrid(1.0) 72 @test boundary_grid(g, UpperBoundary()) == ZeroDimGrid(1.0)
74 end 73 end
75 74
76 @testset "boundary_indices" begin 75 @testset "boundary_indices" begin
77 g = EquidistantGrid(0:0.1:1) 76 g = EquidistantGrid(0:0.1:1)
78 @test boundary_indices(g, Lower()) == (1,) 77 @test boundary_indices(g, LowerBoundary()) == (1,)
79 @test boundary_indices(g, Upper()) == (11,) 78 @test boundary_indices(g, UpperBoundary()) == (11,)
80 79
81 g = EquidistantGrid(2:0.1:10) 80 g = EquidistantGrid(2:0.1:10)
82 @test boundary_indices(g, Lower()) == (1,) 81 @test boundary_indices(g, LowerBoundary()) == (1,)
83 @test boundary_indices(g, Upper()) == (81,) 82 @test boundary_indices(g, UpperBoundary()) == (81,)
84 83
85 end 84 end
86 85
87 @testset "refine" begin 86 @testset "refine" begin
88 g = EquidistantGrid(0:0.1:1) 87 g = EquidistantGrid(0:0.1:1)
110 109
111 110
112 @testset "equidistant_grid" begin 111 @testset "equidistant_grid" begin
113 @test equidistant_grid(0.0,1.0, 4) isa EquidistantGrid 112 @test equidistant_grid(0.0,1.0, 4) isa EquidistantGrid
114 @test equidistant_grid((0.0,0.0),(8.0,5.0), 4, 3) isa TensorGrid 113 @test equidistant_grid((0.0,0.0),(8.0,5.0), 4, 3) isa TensorGrid
114 @test equidistant_grid((0.0,),(8.0,), 4) isa TensorGrid
115 115
116 # constuctor 116 # constuctor
117 @test_throws DomainError equidistant_grid(0.0, 1.0, 0) 117 @test_throws DomainError equidistant_grid(0.0, 1.0, 0)
118 @test_throws DomainError equidistant_grid(1.0, 1.0, 1) 118 @test_throws DomainError equidistant_grid(1.0, 1.0, 1)
119 @test_throws DomainError equidistant_grid(1.0, -1.0, 1) 119 @test_throws DomainError equidistant_grid(1.0, -1.0, 1)