JuliaArrays / JuliaArrays/OffsetArrays.jl

Constrain the types dispatched on in Base functions like fill, ones, zeros, trues, falses

Open
#117 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
212
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Currently the function signature for fill is

https://github.com/JuliaArrays/OffsetArrays.jl/blob/7294f3dcab6e6117b15eea3b98ce2c2175d08194/src/OffsetArrays.jl#L212-L213

However the function clearly only works with integral values, as the OffsetArray constructor only accepts Ints. Something like this will fail:

julia> fill(3.0,UnitRange(3.0,5.0))
ERROR: MethodError: no method matching OffsetArray(::Array{Float64,1}, ::Tuple{Float64})

Should the types dispatched upon be constrained to UnitRange{<:Integer}? This will also allow other packages to define these methods for various other UnitRange types.

The same for other functions like zeros, ones, trues, falses.

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

Read src/OffsetArrays.jl around lines 212-213, starting with the fill signature and then inspect the related zeros, ones, trues, and falses methods. Check how their UnitRange dispatch relates to OffsetArray construction; done means the listed Base functions have appropriately constrained dispatch and the behavior is covered by relevant tests, although no test file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.