Skip to content

Commit

Permalink
Use === for parent checks
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Jul 21, 2023
1 parent e7f6534 commit 479ff29
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/AbstractLieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function lie_algebra(
basis::Vector{AbstractLieAlgebraElem{C}}; check::Bool=true
) where {C<:RingElement}
parent_L = parent(basis[1])
@req all(parent(x) == parent_L for x in basis) "Elements not compatible."
@req all(parent(x) === parent_L for x in basis) "Elements not compatible."
R = coefficient_ring(parent_L)
basis_matrix = if length(basis) == 0
matrix(R, 0, dim(L), C[])
Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/LieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ end
Return `x`. Fails if `x` is not an element of `L`.
"""
function (L::LieAlgebra{C})(x::LieAlgebraElem{C}) where {C<:RingElement}
@req L == parent(x) "Incompatible modules."
@req L === parent(x) "Incompatible modules."
return x
end

Expand Down Expand Up @@ -313,7 +313,7 @@ end
Return the centralizer of `xs` in `L`, i.e. $\{y \in L \mid [x, y] = 0 \forall x \in xs\}$.
"""
function centralizer(L::LieAlgebra, xs::AbstractVector{<:LieAlgebraElem})
@req all(x -> parent(x) == L, xs) "Incompatible Lie algebras."
@req all(x -> parent(x) === L, xs) "Incompatible Lie algebras."

mat = zero_matrix(coefficient_ring(L), dim(L), dim(L) * length(xs))
for (i, bi) in enumerate(basis(L))
Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/LieAlgebraIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Return the normalizer of `I` in `L`, i.e. $\{x \in L \mid [x, I] \subseteq I\} =
As `I` is an ideal in `L`, this is just `L`.
"""
function normalizer(L::LieAlgebra, I::LieAlgebraIdeal)
@req base_lie_algebra(I) == L "Incompatible Lie algebras."
@req base_lie_algebra(I) === L "Incompatible Lie algebras."
return sub(L)
end

Expand Down
14 changes: 7 additions & 7 deletions experimental/LieAlgebras/src/LieAlgebraModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ Return `v`. Fails, in general, if `v` is not an element of `V`.
If `V` is the dual module of the parent of `v`, return the dual of `v`.
"""
function (V::LieAlgebraModule{C})(v::LieAlgebraModuleElem{C}) where {C<:RingElement}
if is_dual(V) && base_module(V) == parent(v)
if is_dual(V) && base_module(V) === parent(v)
return V(coefficients(v))
end
@req V == parent(v) "Incompatible modules."
@req V === parent(v) "Incompatible modules."
return v
end

Expand All @@ -352,7 +352,7 @@ function (V::LieAlgebraModule{C})(
) where {T<:LieAlgebraModuleElem{C}} where {C<:RingElement}
if is_direct_sum(V) || is_tensor_product(V)
@req length(a) == length(base_modules(V)) "Length of vector does not match."
@req all(i -> parent(a[i]) == base_modules(V)[i], 1:length(a)) "Incompatible modules."
@req all(i -> parent(a[i]) === base_modules(V)[i], 1:length(a)) "Incompatible modules."
if is_direct_sum(V)
return V(vcat([coefficients(x) for x in a]...))
elseif is_tensor_product(V)
Expand All @@ -364,7 +364,7 @@ function (V::LieAlgebraModule{C})(
end
elseif is_exterior_power(V) || is_symmetric_power(V) || is_tensor_power(V)
@req length(a) == get_attribute(V, :power) "Length of vector does not match power."
@req all(x -> parent(x) == base_module(V), a) "Incompatible modules."
@req all(x -> parent(x) === base_module(V), a) "Incompatible modules."
mat = zero_matrix(coefficient_ring(V), 1, dim(V))
if is_exterior_power(V)
for (i, _inds) in enumerate(get_attribute(V, :ind_map)),
Expand Down Expand Up @@ -492,7 +492,7 @@ function Base.:*(x::LieAlgebraElem{C}, v::LieAlgebraModuleElem{C}) where {C<:Rin
end

function action(x::LieAlgebraElem{C}, v::LieAlgebraModuleElem{C}) where {C<:RingElement}
@req parent(x) == base_lie_algebra(parent(v)) "Incompatible Lie algebras."
@req parent(x) === base_lie_algebra(parent(v)) "Incompatible Lie algebras."

cx = coefficients(x)
V = parent(v)
Expand Down Expand Up @@ -733,7 +733,7 @@ function direct_sum(
V::LieAlgebraModule{C}, Vs::LieAlgebraModule{C}...
) where {C<:RingElement}
L = base_lie_algebra(V)
@req all(x -> base_lie_algebra(x) == L, Vs) "All modules must have the same base Lie algebra."
@req all(x -> base_lie_algebra(x) === L, Vs) "All modules must have the same base Lie algebra."

dim_direct_sum_V = dim(V) + sum(dim, Vs; init=0)
transformation_matrices = map(1:dim(L)) do i
Expand Down Expand Up @@ -769,7 +769,7 @@ function tensor_product(
V::LieAlgebraModule{C}, Vs::LieAlgebraModule{C}...
) where {C<:RingElement}
L = base_lie_algebra(V)
@req all(x -> base_lie_algebra(x) == L, Vs) "All modules must have the same base Lie algebra."
@req all(x -> base_lie_algebra(x) === L, Vs) "All modules must have the same base Lie algebra."

dim_tensor_product_V = dim(V) * prod(dim, Vs; init=1)
ind_map = collect(reverse.(ProductIterator([1:dim(Vi) for Vi in reverse([V, Vs...])])))
Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/LieSubalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ end
Return the normalizer of `S` in `L`, i.e. $\{x \in L \mid [x, S] \subseteq S\}$.
"""
function normalizer(L::LieAlgebra, S::LieSubalgebra)
@req base_lie_algebra(S) == L "Incompatible Lie algebras."
@req base_lie_algebra(S) === L "Incompatible Lie algebras."

mat = zero_matrix(coefficient_ring(L), dim(L) + dim(S)^2, dim(L) * dim(S))
for (i, bi) in enumerate(basis(L))
Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/LinearLieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function lie_algebra(
basis::Vector{LinearLieAlgebraElem{C}}; check::Bool=true
) where {C<:RingElement}
parent_L = parent(basis[1])
@req all(parent(x) == parent_L for x in basis) "Elements not compatible."
@req all(parent(x) === parent_L for x in basis) "Elements not compatible."
R = coefficient_ring(parent_L)
n = parent_L.n
s = map(AbstractAlgebra.obj_to_string, basis)
Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/test/iso_gap_oscar-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Oscar: GAPWrap

function test_iso_gap_oscar(LG, oscarT; num_random_tests::Int=10)
iso = Oscar.iso_gap_oscar(LG)
@test domain(iso) == LG
@test domain(iso) === LG
LO = codomain(iso)
@test LO isa oscarT

Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/test/iso_oscar_gap-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Oscar: GAPWrap

function test_iso_oscar_gap(LO::LieAlgebra; num_random_tests::Int=10)
iso = Oscar.iso_oscar_gap(LO)
@test domain(iso) == LO
@test domain(iso) === LO
LG = codomain(iso)
@test GAPWrap.IsLieAlgebra(LG)
# @test codomain(Oscar.iso_gap_oscar(LG)) === LO
Expand Down

0 comments on commit 479ff29

Please sign in to comment.