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

AbstractVector{T} not accepting Vector{Any} as argument #838

Closed
jtancp opened this issue Nov 8, 2022 · 1 comment
Closed

AbstractVector{T} not accepting Vector{Any} as argument #838

jtancp opened this issue Nov 8, 2022 · 1 comment

Comments

@jtancp
Copy link

jtancp commented Nov 8, 2022

I am trying to work with the autocor function and am taking a column of a data frame and changing it to a vector. typeof(col) is telling me that it is Vector{Any}. When I pass the argument ACF = StatsBase.autocor(col, (1:18); demean = true)I get the error

ERROR: MethodError: no method matching autocor(::Vector{Any}, ::UnitRange{Int64})
Closest candidates are:
  autocor(::AbstractVector{T} where T<:Real, ::AbstractVector{T} where T<:Integer; demean) at ~/.julia/packages/StatsBase/XgjIN/src/signalcorr.jl:194

I am able to run the function after passing the argument col = Float64.(col) Does julia intentionally make you specify type or is this an issue.

@andreasnoack
Copy link
Member

We generally assume that the element types are more specific than Any. It's quite useful since we can then e.g. avoid considering complex numbers in the function. For performance, it's also beneficial if your element type is Float64 instead of Any.

@jtancp jtancp closed this as completed Nov 9, 2022
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

No branches or pull requests

2 participants