diff --git a/src/fixed.jl b/src/fixed.jl index dd1895b..1dcefda 100644 --- a/src/fixed.jl +++ b/src/fixed.jl @@ -24,6 +24,10 @@ end implicit_basis(basis::SimpleBasis) = SA.basis(first(basis.elements)) +# Needed by SumOfSquares' `_combine_with_gram` which calls `parent` on each +# gram basis to verify the algebras match. +Base.parent(b::SimpleBasis) = implicit_basis(b) + """ struct SemisimpleElement{P} elements::Vector{P} diff --git a/test/fixed.jl b/test/fixed.jl index 4c2dc47..00efb6b 100644 --- a/test/fixed.jl +++ b/test/fixed.jl @@ -25,6 +25,15 @@ end @test MA.promote_operation(MB.implicit_basis, typeof(sb)) == typeof(MB.implicit_basis(sb)) + @testset "parent" begin + # `Base.parent(::SimpleBasis)` is used by SumOfSquares' + # `_combine_with_gram` to check that the gram basis lives in the + # same algebra as the polynomial basis. + @test parent(sb) === MB.implicit_basis(sb) + sb1 = MB.SimpleBasis([ae1]) + @test parent(sb1) === MB.implicit_basis(sb1) + end + @testset "length" begin @test length(sb) == 3 end diff --git a/test/lagrange.jl b/test/lagrange.jl index c84215d..56857d1 100644 --- a/test/lagrange.jl +++ b/test/lagrange.jl @@ -11,14 +11,14 @@ function _test(B::Type) implicit = MB.ImplicitLagrangeBasis(x, MB.BoxSampling([-1, -1], UInt32[1, 1])) point = zeros(2) - poly = implicit[x => point] + poly = implicit[x=>point] @test poly isa MB.LagrangePolynomial @test poly.variables == x @test poly.point === point err = ErrorException( "Variables `$([x[1]])` do not match Lagrange basis variables `$x`", ) - @test_throws err implicit[[x[1]] => [0.0]] + @test_throws err implicit[[x[1]]=>[0.0]] monos = monomials(x, 0:2) coeffs = collect(eachindex(monos)) sub = MB.SubBasis{B}(monos)