-
Notifications
You must be signed in to change notification settings - Fork 87
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
Should we avoid Vec constructor for AbstractVector? #398
Comments
@ErickChacon thank you for sharing this information. I think it makes sense to follow the suggestion in StaticArrays.jl, mind submitting a PR? |
@juliohm, happy to submit a PR. If we remove the constructor for import ArchGDAL as AG
import GeoInterface as GI
using Meshes
mypoint = AG.createpoint(1.0, 5.0)
function topoint(geom)
coords = GI.coordinates(geom)
Meshes.Point(coords...)
end
topoint(mypoint) |
I understood that the idea was not to remove the constructor with AbstractVector, but to use the length function inside the function body with D=1,2,3, right? That doesn't solve the problem? |
Yes, limiting to 1d, 2d, 3d solves the problem. However, I thought it would be good idea to follow |
Oh I got it now. Can you remove the constructor with AbstractVector then to see if the test suite passes? I think we should follow StaticArrays.jl suggestion. |
I am removing the AbstractVector constructor, but I also will need to change some some tests. Is that ok? |
It sounds correct to me. Let's see what is the impact of removing this constructor in the PR and then we can figure out what is the best way forward. It should probably be fine to eliminate this constructor everywhere. |
Great, I will remove it everywhere. There are also several tests that fails in |
For collections we have this constructor Line 56 in cb556d3
that needs Vec for AbstractVector . Any suggestion?
|
Should we convert the columns to tuples before sending to Point?
Em sex., 28 de abr. de 2023 11:53, Dr. Erick A. Chacón Montalván <
***@***.***> escreveu:
… For collections we have this constructor
https://github.com/JuliaGeometry/Meshes.jl/blob/cb556d34900c64b6f40ac827360039c0fb3549f3/src/collections.jl#L56
that needs Vec for AbstractVector. Any suggestion?
—
Reply to this email directly, view it on GitHub
<#398 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZQW3LHRGZXOM3RQDUTCKTXDPKXTANCNFSM6AAAAAAXOOQQRI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Maybe something like the following? PointSet(coords::AbstractMatrix) = PointSet(Point.(Tuple.(eachcol(coords)))) |
I would just do: PointSet(coords::AbstractMatrix) = PointSet(Tuple.(eachcol(coords))) given that there is another constructor for it already. Try to reduce to one of the previous constructors. |
The following operation does not work. Meshes.jl/src/intersections/lines.jl Line 66 in cb556d3
Where It can be solved by using λ = A \ SVector(y.coords) Is there a beteer approach? |
Maybe we should convert A and y in the very beginning of the algorithm to make them vanilla StaticVector and StaticMatrix? That way the entire code will work and we won't hit weird performance bugs. |
Yes, that would be better. I am almost done, so I will start the pull request and move the discussion there. |
This is related to JuliaEarth/GeoTables.jl#13, but in general it seems that is not a good idea to have non typestable contructor like the one defined for
Vec
overAbstracVector
:Meshes.jl/src/vectors.jl
Line 66 in cb556d3
For example,
StaticArrays.jl
avoids it (https://github.com/JuliaArrays/StaticArrays.jl/blob/ed92217f94e2d70847bcf2b7716f47a410d52d25/docs/src/pages/api.md?plain=1#L237-L239).@juliohm Should we avoid using the constructor for
AbstractVector
or limit it for few dimensions?The text was updated successfully, but these errors were encountered: