From 59e2fe649442094604a8b09d6192fb67dcfd96f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Gauth=C3=A9?= Date: Tue, 17 Dec 2024 14:17:04 +0100 Subject: [PATCH] Fix last label (#6) * Fix last label * Bump to v0.1.1 --- Project.toml | 2 +- src/gradedunitrange.jl | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 7b2cd01..c1d2e0c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GradedUnitRanges" uuid = "e2de450a-8a67-46c7-b59c-01d5a3d041c5" authors = ["ITensor developers and contributors"] -version = "0.1.0" +version = "0.1.1" [deps] BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" diff --git a/src/gradedunitrange.jl b/src/gradedunitrange.jl index ec4585c..92645ca 100644 --- a/src/gradedunitrange.jl +++ b/src/gradedunitrange.jl @@ -73,7 +73,9 @@ function BlockArrays.blockedrange(lblocklengths::AbstractVector{<:LabelledIntege return gradedrange(lblocklengths) end -Base.last(a::AbstractGradedUnitRange) = isempty(a.lasts) ? first(a) - 1 : last(a.lasts) +function Base.last(a::AbstractGradedUnitRange) + return isempty(a.lasts) ? labelled(first(a) - 1, label(first(a))) : last(a.lasts) +end function gradedrange(lblocklengths::AbstractVector{<:Pair{<:Any,<:Integer}}) return gradedrange(labelled.(last.(lblocklengths), first.(lblocklengths)))