Add virtual properties for values and indices#318
Add virtual properties for values and indices#318mkitti wants to merge 1 commit intoJuliaArrays:masterfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #318 +/- ##
==========================================
- Coverage 98.67% 95.16% -3.52%
==========================================
Files 5 5
Lines 452 434 -18
==========================================
- Hits 446 413 -33
- Misses 6 21 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Looking at the example from #316, julia> Base.@kwdef struct MyIdOffsetRange
values::UnitRange
indices::UnitRange
end
MyIdOffsetRange
julia> x = MyIdOffsetRange(values=5:8, indices=5:8)
MyIdOffsetRange(5:8, 5:8)
julia> x.values
5:8
julia> x.values === x
falseIn this example, the returned results correspond exactly to the displayed ones, as both directly read the fields of the struct. However, for an julia> id
OffsetArrays.IdOffsetRange(values=5:8, indices=6:9)
julia> id.values
OffsetArrays.IdOffsetRange(values=5:8, indices=6:9)
julia> id.values === id
trueThis isn't an objection to the PR, but I wonder if we need to be consistent here? |
|
The consistency choice I made here was for
If you really wanted a UnitRange, this could work: For that reason, I added it to the documentation. |
This is a full implementation of #316. Virtual properties for
valuesandindicesare added and documented.This differs from the proposed implementation in #316 in that the properties return
IdOffsetArrayrather thanUnitRanges.Another discovered benefit is the ability to forward the properties to construct another
IdOffsetRange.