Skip to content

Commit

Permalink
add tests, fix grid transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp committed Nov 2, 2023
1 parent ae67f6e commit 976d120
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/generic_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions test/test_generic_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 976d120

Please sign in to comment.