sisl / AutomotiveDrivingModels.jl

Driving simulation architecture for Julia
Other
63 stars 29 forks source link

fix malformed bounds error #54

Closed mattuntergassmair closed 4 years ago

mattuntergassmair commented 4 years ago

Same fix as in Records.jl, see https://github.com/sisl/Records.jl/pull/8

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.07%) to 81.946% when pulling fe545503e9296f82f2fb355c052752617f0d2cc9 on mattuntergassmair:master into 62fe41016a0bc0c34c448b19855e523deb21c7ef on sisl:master.

MaximeBouton commented 4 years ago

Do we really need two functions?

function id2index(frame::EntityFrame{S,D,I}, id::I) where {S,D,I}
    entity_index = findfirst(id, frame)
    if entity_index == nothing
        throw(BoundsError(frame, id))
    end
    return entity_index
end
function Records.id2index(frame::Frame{A}, id) where {A<:EntityAction}
    entity_index = findfirst(id, frame)
    if (entity_index === nothing) throw(BoundsError(frame, id)) end
    return entity_index
end

It seems like having frame::Frame{E} where E should be enough?

(feel free to merge this PR and leave this for later)