Skip to content

Commit 0a99e55

Browse files
committed
Added support for begin/end indexing
1 parent 759aca8 commit 0a99e55

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FlexUnits"
22
uuid = "76e01b6b-c995-4ce6-8559-91e72a3d4e95"
33
authors = ["Ruben Gonzalez <[email protected]> and contributors"]
4-
version = "0.2.2"
4+
version = "0.2.3"
55

66
[compat]
77
julia = "1.10"

src/utils.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Base.getindex(q::Q) where Q<:AbstractQuantity = Q(getindex(ustrip(q)), unit(q))
2828
Base.getindex(q::Q, inds) where Q<:AbstractQuantity = quantity(getindex(ustrip(q), inds), unit(q))
2929
Base.getindex(q::Q, inds::CartesianIndex{0}) where Q<:AbstractQuantity = quantity(getindex(ustrip(q), inds), unit(q))
3030
Base.getindex(q::Q, ind::Integer, inds::Integer...) where Q<:AbstractQuantity = quantity(getindex(ustrip(q), ind, inds...), unit(q))
31+
Base.firstindex(q::Q) where Q<:AbstractQuantity = firstindex(ustrip(q))
32+
Base.lastindex(q::Q) where Q<:AbstractQuantity = lastindex(ustrip(q))
3133

3234
#=============================================================================================
3335
Displaying output

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const DEFAULT_DIM_TYPE = FlexUnits.dimtype(DEFAULT_UNIT_TYPE)
6565
@test vq[1] == 1*u"m/s"
6666
@test vq[CartesianIndex(1)] == 1*u"m/s"
6767
@test all([q for q in vq] .== vq)
68+
@test vq[begin] == 1*u"m/s"
69+
@test vq[end] == 2*u"m/s"
6870

6971
#Size indicators for quantities
7072
tx = [1, 3.6, 501.3]

0 commit comments

Comments
 (0)