JuliaApproximation / JuliaApproximation/ContinuumArrays.jl

Continuum indices

Open
#115 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
31
Forks
6
Avg merge
9d 22h
Merged PRs (30d)
2

Description

So I can define a function f(x)=x^2, x∈[0,1] by

julia> f=Inclusion(0..1).^2
(Inclusion(0..1)) .^ 2

Then I want to do composition, say, g(x)=f(f(x)). But currently I'm not allowed to do:

julia> g=f[f]
ERROR: MethodError: no method matching Int64(::Infinities.InfiniteCardinal{1})
Closest candidates are:
  (::Type{T})(::T) where T<:Number at boot.jl:760
  (::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
  (::Type{T})(::BigInt) where T<:Union{Int128, Int16, Int32, Int64, Int8} at gmp.jl:356
  ...
Stacktrace:
  [1] union!(s::Set{Float64}, itr::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}})
    @ Base .\abstractset.jl:93
  [2] Set{Float64}(itr::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}})
    @ Base .\set.jl:10
  [3] _Set(itr::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, #unused#::Base.HasEltype)
    @ Base .\set.jl:23
  [4] Set(itr::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}})
    @ Base .\set.jl:21
  [5] issubset(l::QuasiArrays.BroadcastQuasiVector{Float64, typeof(Base.literal_pow), Tuple{Base.RefValue{typeof(^)}, Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, Base.RefValue{Val{2}}}}, r::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}})
    @ Base .\abstractset.jl:279
  [6] checkindex(#unused#::Type{Bool}, inds::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, i::QuasiArrays.BroadcastQuasiVector{Float64, typeof(Base.literal_pow), Tuple{Base.RefValue{typeof(^)}, Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, Base.RefValue{Val{2}}}})
    @ QuasiArrays C:\Users\pty\.julia\packages\QuasiArrays\bxqu9\src\indices.jl:203
  [7] checkbounds_indices
    @ .\abstractarray.jl:642 [inlined]
  [8] checkbounds
    @ C:\Users\pty\.julia\packages\QuasiArrays\bxqu9\src\abstractquasiarray.jl:275 [inlined]
  [9] checkbounds
    @ C:\Users\pty\.julia\packages\QuasiArrays\bxqu9\src\abstractquasiarray.jl:287 [inlined]
 [10] view
    @ C:\Users\pty\.julia\packages\QuasiArrays\bxqu9\src\subquasiarray.jl:68 [inlined]
 [11] layout_getindex
    @ C:\Users\pty\.julia\packages\ArrayLayouts\3lnt1\src\ArrayLayouts.jl:109 [inlined]
 [12] _getindex(#unused#::Type, #unused#::IndexCartesian, A::QuasiArrays.BroadcastQuasiVector{Float64, typeof(Base.literal_pow), Tuple{Base.RefValue{typeof(^)}, Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, Base.RefValue{Val{2}}}}, I::Tuple{QuasiArrays.BroadcastQuasiVector{Float64, typeof(Base.literal_pow), Tuple{Base.RefValue{typeof(^)}, Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, Base.RefValue{Val{2}}}}})
    @ QuasiArrays C:\Users\pty\.julia\packages\QuasiArrays\bxqu9\src\abstractquasiarray.jl:384
 [13] _getindex
    @ C:\Users\pty\.julia\packages\QuasiArrays\bxqu9\src\abstractquasiarray.jl:375 [inlined]
 [14] getindex(A::QuasiArrays.BroadcastQuasiVector{Float64, typeof(Base.literal_pow), Tuple{Base.RefValue{typeof(^)}, Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, Base.RefValue{Val{2}}}}, I::QuasiArrays.BroadcastQuasiVector{Float64, typeof(Base.literal_pow), Tuple{Base.RefValue{typeof(^)}, Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, Base.RefValue{Val{2}}}})
    @ QuasiArrays C:\Users\pty\.julia\packages\QuasiArrays\bxqu9\src\abstractquasiarray.jl:370
 [15] top-level scope
    @ none:1

Can we have this feature?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with Inclusion(0..1).^2 and f[f], then inspect the QuasiArrays indexing path shown in src/indices.jl and src/abstractquasiarray.jl, along with the ArrayLayouts call site. The feature is done when composing the continuum-indexed function works without the reported InfiniteCardinal conversion error and existing indexing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
34/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.