Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jishnub opened this issue Jun 12, 2020 · 0 comments · May be fixed by #118
Open

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

jishnub opened this issue Jun 12, 2020 · 0 comments · May be fixed by #118

Comments

@jishnub
Copy link
Member

jishnub commented Jun 12, 2020

Currently the function signature for fill is

Base.fill(x, inds::Tuple{UnitRange,Vararg{UnitRange}}) =
fill!(OffsetArray{typeof(x)}(undef, inds), x)

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.

@jishnub jishnub linked a pull request Jun 12, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant