You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe I am missing something, but I don't understand why Base.in and Base.findfirst are currently implemented so that they expect an item of the same eltype of the UniqueVector, and they perform a conversion when this does not hold:
in(item::T, uv::UniqueVector{T}) where {T} = haskey(uv.lookup, item)
in(item, uv::UniqueVector{T}) where {T} = in(convert(T, item), uv)
findfirst(p::EqualTo{<:T}, uv::UniqueVector{T}) where {T} = get(uv.lookup, p.x, nothing)
findfirst(p::EqualTo, uv::UniqueVector{T}) where {T} = findfirst(isequal(convert(T, p.x)), uv)
I'd like Base.in and Base.findfirst to be a little more flexible. Here are the errors I would like not to show up:
Hi,
Maybe I am missing something, but I don't understand why
Base.in
andBase.findfirst
are currently implemented so that they expect an item of the sameeltype
of theUniqueVector
, and they perform a conversion when this does not hold:I'd like
Base.in
andBase.findfirst
to be a little more flexible. Here are the errors I would like not to show up:My desire is in line with the behavior of other
AbstractVector
s:If I add these two methods, it's probably type piracy, and I get a warning, but then I manage to get what I want:
Wouldn't it be correct to have them in the package?
Thank you,
GP
The text was updated successfully, but these errors were encountered: