DimensionalData.jl icon indicating copy to clipboard operation
DimensionalData.jl copied to clipboard

`intersect` on DimUnitRanges returns a Base `UnitRange`

Open asinghvi17 opened this issue 1 year ago • 4 comments

MWE:

julia> import DimensionalData as DD; using DimensionalData

julia> intersect(DD.Dimensions.DimUnitRange(1:5, X()), DD.Dimensions.DimUnitRange(3:7, X()))
3:5

julia> typeof(ans)
UnitRange{Int64}

Ideally this should return a DimUnitRange. Maybe it could also check that dimensions match. Let me know if this makes sense, and I can PR it.

asinghvi17 avatar Nov 09 '24 15:11 asinghvi17

Probably makes sense

rafaqz avatar Nov 09 '24 16:11 rafaqz

Also, should dims2indices on an extent return a DimUnitRange?

asinghvi17 avatar Nov 10 '24 02:11 asinghvi17

That would mean selectors also returning DimUnitRange.

There's a compilation overhead to doing that.

What would be the benefit?

rafaqz avatar Nov 10 '24 10:11 rafaqz

We will need to use promote_dim on the dimensions to get the right type back.

And also check that the lookup values match after the intersection.

rafaqz avatar Dec 13 '24 23:12 rafaqz