sisl / GridInterpolations.jl

Multidimensional grid interpolation in arbitrary dimensions
Other
52 stars 12 forks source link

Add function to get vertices of grid #19

Closed Shushman closed 6 years ago

Shushman commented 6 years ago

The function vertices(::AbstractGrid is added in GridInterpolations.jl to allow the caller to obtain a Vector of size length(grid) where each element is one of the vertices of the grid. The order of vertices is deterministically generated.

E.g.

julia> grid = RectangleGrid([0., 0.5],[0., 0.5, 1.])
GridInterpolations.RectangleGrid with 6 points

julia> vs = vertices(grid)
6-element Array{Array{Float64,1},1}:
 [0.0, 0.0]
 [0.5, 0.0]
 [0.0, 0.5]
 [0.5, 0.5]
 [0.0, 1.0]
 [0.5, 1.0]
coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 97.059% when pulling 1e9ea4e67903c9c2d557afcd7aac86211357925c on Shushman:feature/vertices into c7fb0515c7827df8861f564c6682ad5344c7c4d1 on sisl:master.

Shushman commented 6 years ago

Do not merge - I need ensure the ordering of vertices is consistent with grid data.

Shushman commented 6 years ago

Based on some simple tests, it seems the order of grid data is consistent with the order of vertices, i.e. the first dimension is the least significant bit. Can someone please confirm?

mykelk commented 6 years ago

Can you add a test?

Shushman commented 6 years ago

I have added a test_vertices_ordering() method that compares the members and ordering of the result of vertices() on a grid with a call to ind2x for each valid vertex index.

mykelk commented 6 years ago

I think the function comment needs to be updated?

Shushman commented 6 years ago

Modified function comment to reflect change. Thanks for catching that @mykelk !