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

MethodError: no method matching similar(::Type{Array{Float64,N} where N}, ::Tuple{UnitRange{Int32}}) #34661

Open
omus opened this issue Feb 4, 2020 · 1 comment
Labels
32-bit Affects only 32-bit systems broadcast Applying a function over a collection dates Dates, times, and the Dates stdlib module

Comments

@omus
Copy link
Member

omus commented Feb 4, 2020

Julia 1.3.1 official binary for Linux x86:

julia> using Dates

julia> x = DateTime(2017, 11, 3):Day(1):DateTime(2018, 11, 3)
2017-11-03T00:00:00:1 day:2018-11-03T00:00:00

julia> sin.(1:length(x)) .* rand(length(x))
ERROR: MethodError: no method matching similar(::Type{Array{Float64,N} where N}, ::Tuple{UnitRange{Int32}})
Closest candidates are:
  similar(::AbstractArray{T,N} where N, ::Tuple) where T at abstractarray.jl:627
  similar(::Type{T}, ::Union{Integer, AbstractUnitRange}...) where T<:AbstractArray at abstractarray.jl:670
  similar(::Type{T}, ::Tuple{Vararg{Int32,N}} where N) where T<:AbstractArray at abstractarray.jl:672
  ...
Stacktrace:
 [1] similar(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Tuple{UnitRange{Int32}},typeof(*),Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(sin),Tuple{UnitRange{Int64}}},Array{Float64,1}}}, ::Type{Float64}) at ./broadcast.jl:196
 [2] copy at ./broadcast.jl:839 [inlined]
 [3] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(*),Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(sin),Tuple{UnitRange{Int64}}},Array{Float64,1}}}) at ./broadcast.jl:819
 [4] top-level scope at REPL[34]:1

There may be two bugs here. One is that ranges containing TimeTypes always return a length which is an Int64 and something inside the broadcasting code.

@omus omus added 32-bit Affects only 32-bit systems broadcast Applying a function over a collection dates Dates, times, and the Dates stdlib module labels Feb 4, 2020
@omus
Copy link
Member Author

omus commented Feb 4, 2020

The error does not occur on Julia 1.4.0-rc1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
32-bit Affects only 32-bit systems broadcast Applying a function over a collection dates Dates, times, and the Dates stdlib module
Projects
None yet
Development

No branches or pull requests

1 participant