I encountered this error message while using indexin
in a for loop. Here is an example
using Dates
indexin(DateTime(2024,1), DateTime(2024,1):Day(1):DateTime(2024,2))
ERROR: MethodError: no method matching length(::DateTime)
Closest candidates are:
length(::Union{Base.KeySet, Base.ValueIterator})
@ Base abstractdict.jl:58
length(::Union{SparseArrays.FixedSparseVector{Tv, Ti}, SparseArrays.SparseVector{Tv, Ti}} where {Tv, Ti})
@ SparseArrays /software/sse2/tetralith_el9/manual/julia/1.9.4/julia-1.9.4/share/julia/stdlib/v1.9/SparseArrays/src/sparsevector.jl:95
length(::Union{LinearAlgebra.Adjoint{T, <:Union{StaticArraysCore.StaticArray{Tuple{var"#s2"}, T, 1} where var"#s2", StaticArraysCore.StaticArray{Tuple{var"#s3", var"#s4"}, T, 2} where {var"#s3", var"#s4"}}}, LinearAlgebra.Diagonal{T, <:StaticArraysCore.StaticArray{Tuple{var"#s14"}, T, 1} where var"#s14"}, LinearAlgebra.Hermitian{T, <:StaticArraysCore.StaticArray{Tuple{var"#s11", var"#s12"}, T, 2} where {var"#s11", var"#s12"}}, LinearAlgebra.LowerTriangular{T, <:StaticArraysCore.StaticArray{Tuple{var"#s19", var"#s20"}, T, 2} where {var"#s19", var"#s20"}}, LinearAlgebra.Symmetric{T, <:StaticArraysCore.StaticArray{Tuple{var"#s8", var"#s9"}, T, 2} where {var"#s8", var"#s9"}}, LinearAlgebra.Transpose{T, <:Union{StaticArraysCore.StaticArray{Tuple{var"#s2"}, T, 1} where var"#s2", StaticArraysCore.StaticArray{Tuple{var"#s3", var"#s4"}, T, 2} where {var"#s3", var"#s4"}}}, LinearAlgebra.UnitLowerTriangular{T, <:StaticArraysCore.StaticArray{Tuple{var"#s25", var"#s26"}, T, 2} where {var"#s25", var"#s26"}}, LinearAlgebra.UnitUpperTriangular{T, <:StaticArraysCore.StaticArray{Tuple{var"#s22", var"#s23"}, T, 2} where {var"#s22", var"#s23"}}, LinearAlgebra.UpperTriangular{T, <:StaticArraysCore.StaticArray{Tuple{var"#s16", var"#s17"}, T, 2} where {var"#s16", var"#s17"}}, StaticArraysCore.StaticArray{Tuple{var"#s26"}, T, 1} where var"#s26", StaticArraysCore.StaticArray{Tuple{var"#s1", var"#s4"}, T, 2} where {var"#s1", var"#s4"}, StaticArraysCore.StaticArray{<:Tuple, T}} where T)
@ StaticArrays ~/.julia/packages/StaticArrays/MSJcA/src/abstractarray.jl:1
...
Stacktrace:
[1] _similar_shape(itr::DateTime, #unused#::Base.HasLength)
@ Base ./array.jl:658
[2] _array_for(#unused#::Type{Union{Nothing, Int64}}, itr::DateTime, isz::Base.HasLength)
@ Base ./array.jl:674
[3] indexin(a::DateTime, b::StepRange{DateTime, Day})
@ Base ./array.jl:2484
[4] top-level scope
@ REPL[64]:1
Would it be reasonable to expect Dates to provide a method for length(::DateTime)
?