From 976d12031c16023307f9ce125f22639e9eb12a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20K=2E=20Papp?= Date: Thu, 2 Nov 2023 17:05:35 +0100 Subject: [PATCH] add tests, fix grid transformation --- src/generic_api.jl | 4 ++-- test/test_generic_api.jl | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/generic_api.jl b/src/generic_api.jl index ce3b8a4..74432ff 100644 --- a/src/generic_api.jl +++ b/src/generic_api.jl @@ -266,7 +266,7 @@ function Base.:(∘)(parent::FunctionBasis, transformation) TransformedBasis(parent, transformation) end -domain(basis::TransformedBasis) = domain(basis.parent) +domain(basis::TransformedBasis) = domain(basis.transformation) dimension(basis::TransformedBasis) = dimension(basis.parent) @@ -278,7 +278,7 @@ end function grid(basis::TransformedBasis) (; parent, transformation) = basis d = domain(parent) - Iterators.map(x -> transform_to(d, transformation, x), grid(parent)) + Iterators.map(x -> transform_from(d, transformation, x), grid(parent)) end function Base.:(∘)(linear_combination::LinearCombination, transformation) diff --git a/test/test_generic_api.jl b/test/test_generic_api.jl index 18e986b..0812703 100644 --- a/test/test_generic_api.jl +++ b/test/test_generic_api.jl @@ -29,11 +29,16 @@ end @test_throws ArgumentError linear_combination(basis, bad_θ) end -@testset "transformed linear combinations" begin +@testset "transformed bases and linear combinations" begin N = 10 basis = Chebyshev(EndpointGrid(), N) - θ = randn(10) t = BoundedLinear(1.0, 2.0) + @test domain(basis ∘ t) == domain(t) + @test dimension(basis ∘ t) == dimension(basis) + @test collect(grid(basis ∘ t)) == + [transform_from(domain(basis), t, x) for x in grid(basis)] + + θ = randn(10) l1 = linear_combination(basis, θ) l2 = linear_combination(basis ∘ t, θ) l3 = linear_combination(basis, θ) ∘ t