Code Monkey home page Code Monkey logo

Comments (3)

kahaaga avatar kahaaga commented on June 21, 2024

This is also the case for Counts:

julia> c = counts(Dispersion(), rand(50))
 Counts{Int64,1} over 9 outcomes
 [1, 1]  5
 [1, 2]  2
 [1, 3]  7
 [2, 1]  2
 [2, 2]  8
 [2, 3]  6
 [3, 1]  7
 [3, 2]  6
 [3, 3]  6
 
julia> eachindex(c)
ERROR: MethodError: eachindex(::Counts{Int64, 1, Symbol}) is ambiguous.

Candidates:
  eachindex(A::AbstractArray, B::AbstractArray...)
    @ Base abstractarray.jl:377
  eachindex(c::Counts, args...)
    @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/counts.jl:92
  eachindex(A::AbstractVector)
    @ Base abstractarray.jl:314
  eachindex(A::AbstractArray)
    @ Base abstractarray.jl:371

Possible fix, define
  eachindex(::Counts{T, 1} where T<:Integer)

Stacktrace:
 [1] top-level scope
   @ REPL[8]:1

from complexitymeasures.jl.

kahaaga avatar kahaaga commented on June 21, 2024

Some hints:

julia> using ComplexityMeasures

julia> using Test; detect_ambiguities(ComplexityMeasures)
9-element Vector{Tuple{Method, Method}}:
 (eachindex(d::Probabilities{T, N, S}, args...) where {T, N, S} @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/probabilities.jl:97, eachindex(A::AbstractArray, B::AbstractArray) @ Base abstractarray.jl:373)
 (probabilities(x, est::OutcomeSpace) @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/deprecations.jl:49, probabilities(est::ValueBinning, x) @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/outcome_spaces/value_binning.jl:66)
 (eachindex(c::Counts{T, N}, args...) where {T<:Integer, N} @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/counts.jl:92, eachindex(A::AbstractArray, B::AbstractArray) @ Base abstractarray.jl:373)
 (information(est::DifferentialInfoEstimator, args...) @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/information_functions.jl:267, information(est::InformationMeasureEstimator, probest::ProbabilitiesEstimator, args...) @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/information_measures.jl:91)
 ((var"#ctor-self#"::Type{Outcome{T}} where T<:Integer)(num) @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/outcome.jl:14, (::Type{T})(x::Base.TwicePrecision) where T<:Number @ Base twiceprecision.jl:266)
 (probabilities(o::OutcomeSpace, x) @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/probabilities.jl:261, probabilities(x, est::OutcomeSpace) @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/deprecations.jl:49)
 (eachindex(c::Counts{T, N}, args...) where {T<:Integer, N} @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/counts.jl:92, eachindex(A::AbstractArray, B::AbstractArray...) @ Base abstractarray.jl:377)
 (eachindex(d::Probabilities{T, N, S}, args...) where {T, N, S} @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/probabilities.jl:97, eachindex(A::AbstractArray, B::AbstractArray...) @ Base abstractarray.jl:377)
 ((var"#ctor-self#"::Type{Outcome{T}} where T<:Integer)(num) @ ComplexityMeasures ~/Documents/Repos/ComplexityMeasures.jl/src/core/outcome.jl:14, (::Type{T})(x::AbstractChar) where T<:Union{AbstractChar, Number} @ Base char.jl:50)

from complexitymeasures.jl.

kahaaga avatar kahaaga commented on June 21, 2024

The problem was that the generic @eval Base.$(f)(d::Probabilities{T, N, S}, args...) where {T, N, S} = $(f)(d.p, args...) with the extra args leads to a conflict with eachindex(A::AbstractArray, B::AbstractArray...) in base. The same is the case for Counts.

By excluding :eachindex from the list of symbols to be eval-ed and manually defining Base.eachindex(p::Probabilities) = eachindex(p.p), the issue is solved:

julia> c = counts(Dispersion(), rand(50))
 Counts{Int64,1} over 9 outcomes
 [1, 1]   9
 [1, 2]   3
 [1, 3]   7
 [2, 1]   3
 [2, 2]   2
 [2, 3]   3
 [3, 1]   7
 [3, 2]   3
 [3, 3]  12

julia> eachindex(c)
Base.OneTo(9)

julia> p = probabilities(Dispersion(), rand(50))
 Probabilities{Float64,1} over 9 outcomes
 [1, 1]  0.10204081632653061
 [1, 2]  0.14285714285714285
 [1, 3]  0.08163265306122448
 [2, 1]  0.10204081632653061
 [2, 2]  0.02040816326530612
 [2, 3]  0.10204081632653061
 [3, 1]  0.12244897959183673
 [3, 2]  0.061224489795918366
 [3, 3]  0.2653061224489796

julia> eachindex(p)
Base.OneTo(9)

from complexitymeasures.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.