Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
9 changes: 9 additions & 0 deletions test/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/lagrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading