-
-
Notifications
You must be signed in to change notification settings - Fork 56
Use default getindex for vector[face]
when no Polytope is generated
#246
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
Conversation
That seems pretty breaking to me! |
The only thing that changes is that a tuple becomes a Vector |
vector[face]
when no Polytope is generated
But that code path is usually used in high performance situations (e.g. iterating over all face indices)... |
Ok, I think this is the right approach to fix #249 and #247 @propagate_inbounds function Base.getindex(points::AbstractVector{P}, face::F) where {P<: Point, F <: AbstractFace}
return Polytope(P, F)(map(i-> points[i], face.data))
end
@propagate_inbounds function Base.getindex(elements::AbstractVector, face::F) where {F <: AbstractFace}
return map(i-> elements[i], face.data)
end Looks like that was the behaviour before, and I dont see a good reason why whe should deviate from the previous behavior. |
I guess the tests should be: f = QuadFace{Int64}(1,2,3,4) # Some face
@test f[f.!=3] isa AbstractVector{Int} # [email protected] had Vector, but maybe SVector would be better here
V = Point{3, Float64}[[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0]]
@test V[f] isa typeof(V) # 0.4 returned Vector |
@ffreyer yep this seems to fix those issues, thanks!
|
We decided to keep it like this for now to just recover the old behaviour as quickly as possible.. |
This allows things like
f[f .== 1]