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

Errors from findfirst(..., ::StepRange{Date,Year}) #35203

Open
mcabbott opened this issue Mar 21, 2020 · 1 comment · May be fixed by #35279
Open

Errors from findfirst(..., ::StepRange{Date,Year}) #35203

mcabbott opened this issue Mar 21, 2020 · 1 comment · May be fixed by #35279

Comments

@mcabbott
Copy link
Contributor

mcabbott commented Mar 21, 2020

This worked on Julia 1.0 and 1.1, but fails from 1.2 to 1.5:

using Dates
ys = Date(1852):Year(4):Date(1940)
y0 = ys[21+1]
findfirst(isequal(y0), ys) # MethodError: Cannot `convert` an object of type Day to an object of type Year

findfirst(isequal(y0), collect(ys)) # fine

This seems like a bug to me, as the range ought to be treated the same way as the collected array.

The method, which I think was added in #30778, is here:

function findfirst(p::Union{Fix2{typeof(isequal),T},Fix2{typeof(==),T}}, r::StepRange{T,S}) where {T,S}

It works fine for some dates, like DateTime(2017):Second(1):DateTime(2020) mentioned in the PR. But every second is the same length, while years vary.

@mcabbott
Copy link
Contributor Author

Notice that Base.RangeStepStyle(ys) == Base.RangeStepIrregular(). Perhaps this is the flag which #30778 ought to check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant