diff --git a/src/MultivariateBases.jl b/src/MultivariateBases.jl index c204c76..c03ac5a 100644 --- a/src/MultivariateBases.jl +++ b/src/MultivariateBases.jl @@ -22,7 +22,10 @@ MP.monomial_type(::Type{<:Algebra{B}}) where {B} = MP.monomial_type(B) function MP.polynomial_type(::Type{<:Algebra{B}}, ::Type{T}) where {B,T} return MP.polynomial_type(B, T) end -function MA.promote_operation(::typeof(SA.basis), ::Type{<:Algebra{B}}) where {B} +function MA.promote_operation( + ::typeof(SA.basis), + ::Type{<:Algebra{B}}, +) where {B} return B end SA.basis(a::Algebra) = a.basis diff --git a/src/arithmetic.jl b/src/arithmetic.jl index 3ff2693..e613c3d 100644 --- a/src/arithmetic.jl +++ b/src/arithmetic.jl @@ -4,16 +4,28 @@ const _AE = SA.AlgebraElement{<:Algebra} for op in [:+, :-, :*] @eval begin - function MA.promote_operation(::typeof($op), ::Type{P}, ::Type{Q}) where {P<:_APL,Q<:_AE} + function MA.promote_operation( + ::typeof($op), + ::Type{P}, + ::Type{Q}, + ) where {P<:_APL,Q<:_AE} return MA.promote_operation($op, P, MP.polynomial_type(Q)) end Base.$op(p::_APL, q::_AE) = $op(p, MP.polynomial(q)) - function MA.promote_operation(::typeof($op), ::Type{P}, ::Type{Q}) where {P<:_AE,Q<:_APL} + function MA.promote_operation( + ::typeof($op), + ::Type{P}, + ::Type{Q}, + ) where {P<:_AE,Q<:_APL} return MA.promote_operation($op, MP.polynomial_type(P), Q) end Base.$op(p::_AE, q::_APL) = $op(MP.polynomial(p), q) # Break ambiguity between the two defined below and the generic one in SA - function MA.promote_operation(::typeof($op), ::Type{P}, ::Type{Q}) where {P<:_AE,Q<:_AE} + function MA.promote_operation( + ::typeof($op), + ::Type{P}, + ::Type{Q}, + ) where {P<:_AE,Q<:_AE} return SA.algebra_promote_operation($op, P, Q) end function Base.$op(p::_AE, q::_AE) @@ -23,11 +35,18 @@ for op in [:+, :-, :*] end for op in [:+, :-] @eval begin - function MA.promote_operation(::typeof($op), ::Type{P}, ::Type{Q}) where {P,Q<:_AE} + function MA.promote_operation( + ::typeof($op), + ::Type{P}, + ::Type{Q}, + ) where {P,Q<:_AE} I = MA.promote_operation(implicit, Q) return MA.promote_operation( $op, - constant_algebra_element_type(MA.promote_operation(SA.basis, I), P), + constant_algebra_element_type( + MA.promote_operation(SA.basis, I), + P, + ), I, ) end @@ -35,12 +54,19 @@ for op in [:+, :-] i = implicit(q) return $op(constant_algebra_element(typeof(SA.basis(i)), p), i) end - function MA.promote_operation(::typeof($op), ::Type{P}, ::Type{Q}) where {P<:_AE,Q} + function MA.promote_operation( + ::typeof($op), + ::Type{P}, + ::Type{Q}, + ) where {P<:_AE,Q} I = MA.promote_operation(implicit, P) return MA.promote_operation( $op, I, - constant_algebra_element_type(MA.promote_operation(SA.basis, I), Q), + constant_algebra_element_type( + MA.promote_operation(SA.basis, I), + Q, + ), ) end function Base.$op(p::_AE, q) diff --git a/test/hermite.jl b/test/hermite.jl index 6142456..c72c97e 100644 --- a/test/hermite.jl +++ b/test/hermite.jl @@ -48,6 +48,8 @@ end M = typeof(x^2) mono = MB.FullBasis{MB.Monomial,M}() basis = MB.FullBasis{MB.PhysicistsHermite,M}() - err = ErrorException("Convertion from `$mono` to `$basis` not implemented yet") + err = ErrorException( + "Convertion from `$mono` to `$basis` not implemented yet", + ) @test_throws err SA.coeffs(MB.algebra_element(x + 1), basis) end diff --git a/test/runtests.jl b/test/runtests.jl index dbb5a26..569f942 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,10 +15,9 @@ end function _test_basis(basis) B = typeof(basis) - @test typeof(MB.algebra(basis)) == - MA.promote_operation(MB.algebra, B) + @test typeof(MB.algebra(basis)) == MA.promote_operation(MB.algebra, B) @test typeof(MB.constant_algebra_element(B, 1)) == - MB.constant_algebra_element_type(B, Int) + MB.constant_algebra_element_type(B, Int) end function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree)