Closed cstjean closed 6 years ago
Simpler MWE:
julia> Zeros(3)[1]
ERROR: MethodError: getindex(::FillArrays.Zeros{Float64,1}, ::Int64) is ambiguous. Candidates:
getindex(F::FillArrays.AbstractFill{T,N}, kj::Vararg{Int64,N}) where {T, N} in FillArrays at /home/cst-jean/.julia/v0.6/FillArrays/src/FillArrays.jl:15
getindex(F::FillArrays.AbstractFill, k::Int64) in FillArrays at /home/cst-jean/.julia/v0.6/FillArrays/src/FillArrays.jl:10
Possible fix, define
getindex(::FillArrays.AbstractFill{T,1}, ::Int64)
EDIT: furthermore, importing FillArrays first (using FillArrays, Plots
) does not hit the ambiguity warning.
I'm not able to replicate this, has it been fixed?
I can't replicate either. Maybe something was wrong with my system at the time. Thank you for checking.
I can actually reproduce this.
$ julia --color=yes --print 'using Plots; using FillArrays; Zeros(3)[1]'
ERROR: MethodError: getindex(::FillArrays.Zeros{Float64,1}, ::Int64) is ambiguous. Candidates:
getindex(F::FillArrays.AbstractFill{T,N}, kj::Vararg{Int64,N}) where {T, N} in FillArrays at /home/takafumi/.julia/v0.6/FillArrays/src/FillArrays.jl:15
getindex(F::FillArrays.AbstractFill, k::Int64) in FillArrays at /home/takafumi/.julia/v0.6/FillArrays/src/FillArrays.jl:10
Possible fix, define
getindex(::FillArrays.AbstractFill{T,1}, ::Int64)
julia --color=yes --print 'using Plots; using FillArrays; Zeros(3)[1]'
$ julia --color=yes --print 'using FillArrays; Zeros(3)[1]'
0.0
$ julia
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.2 (2017-12-13 18:08 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-pc-linux-gnu
julia> versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
julia> Pkg.installed("Plots")
v"0.17.0"
julia> Pkg.installed("FillArrays")
v"0.0.1"
More info:
julia> import Plots
julia> import FillArrays
julia> for name in names(Main)
if getfield(Main, name) isa Module
version = try
Pkg.installed(string(name))
catch
continue
end
println(name, " => ", version)
end
end
ColorTypes => 0.6.7
Colors => 0.8.2
Compat => 0.64.0
DataStructures => 0.8.2
FileIO => 0.7.0
FillArrays => 0.0.1
FixedPointNumbers => 0.4.6
JSON => 0.17.2
Measures => 0.2.0
Missings => 0.2.9
NaNMath => 0.3.1
Nullables => 0.0.5
PlotThemes => 0.2.0
PlotUtils => 0.4.4
Plots => 0.17.0
RecipesBase => 0.3.1
Reexport => 0.1.0
Requires => 0.4.3
Showoff => 0.1.1
SortingAlgorithms => 0.2.1
StaticArrays => 0.7.0+
StatsBase => 0.22.0
So it looks like a minimal module for getting the error is StaticArrays
:
julia --color=yes --print 'import StaticArrays; import FillArrays; FillArrays.Zeros(3)[1]'
The StaticArrays version I was using above was 2a74b049b52bcf85032db43d85de91bf44a821f4 but I could actually reproduce the errror with StaticArrays v0.7.0.
Now, when I get the error, I have only those in Main:
Compat => 0.64.0
FillArrays => 0.0.1
StaticArrays => 0.7.0
Can you try adding the suggested function getindex(::AbstractFill{T,1}, k::Int)
to see if that resolves it?
Yes, it solves the issue:
julia> import StaticArrays
julia> import FillArrays
julia> FillArrays.getindex(F::FillArrays.AbstractFill{T, 1}, ::Int) where T =
FillArrays.getindex_value(F)
julia> FillArrays.Zeros(3)[1]
0.0
Mind making a PR?
Oops it was already fixed by d7ba08f749eb5216892b664ca8977b3493499f73. I was using FillArrays 0.0.1. Please close this issue.
I'll tag a new release now.
I see you've tagged a release, but Pkg.update
didn't update FillArrays
, and I can't find the PR on METADATA. Did attobot have a hiccup?
Ahh, this is due to https://github.com/JuliaArrays/BlockArrays.jl/issues/46
I'll have to do a manual PR when I get the chance.
I deleted the tag that didn't work
On 0.6,
I don't quite understand how
Plots
can introduce an ambiguity between two FillArrays methods...