Skip to content

Commit

Permalink
Add show for Momenta.
Browse files Browse the repository at this point in the history
  • Loading branch information
waltergu committed Dec 19, 2024
1 parent 46d1937 commit 87bf09a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/QuantumNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ struct Momenta{P<:𝕂} <: RepresentationSpace{P} end
@inline Base.convert(::Type{P}, index::CartesianIndex, ::Momenta{P}) where {P<:𝕂} = P(reverse(index.I)...)
@inline Base.:(==)(ms₁::Momenta, ms₂::Momenta) = periods(eltype(ms₁))==periods(eltype(ms₂))
@inline Base.isequal(ms₁::Momenta, ms₂::Momenta) = isequal(periods(eltype(ms₁)), periods(eltype(ms₂)))
@inline Base.show(io::IO, ms::Momenta) = @printf io "Momenta(%s)" eltype(ms)

"""
regularize!(quantumnumbers::Vector{<:AbelianQuantumNumber}, dimensions::Vector{Int}; check::Bool=false) -> Tuple{typeof(quantumnumbers), typeof(dimensions), Vector{Int}}
Expand Down
3 changes: 2 additions & 1 deletion test/QuantumNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ end
@test collect(momenta) == [𝕂²{2, 3}(0, 0), 𝕂²{2, 3}(0, 1), 𝕂²{2, 3}(0, 2), 𝕂²{2, 3}(1, 0), 𝕂²{2, 3}(1, 1), 𝕂²{2, 3}(1, 2)]
for momentum in momenta
@test momenta[convert(CartesianIndex, momentum, momenta)] == momentum
end
end
@test string(momenta) == "Momenta(𝕂²{2, 3})"
end

@testset "regularize" begin
Expand Down

0 comments on commit 87bf09a

Please sign in to comment.