Embedding Grid
Grid embeddings are utility classes to ease the manipulation of point coordinates in the d-dimensional integer grid. An embedding has a shape (height and width in 2 dimensions).
For a given dimension \(N\in\{1,2,3,4,5\}\), there is a specific grid embedding class called EmbeddingGridNd
.
All the specific grid embedding classes implement the same interface.
- class EmbeddingGrid2d
- __init__(self: higra.higram.EmbeddingGrid2d, shape: numpy.ndarray[numpy.int64]) None
Create a new grid embedding. Shape must be a 1d array with striclty positive values.
- __reduce__()
Helper for pickle.
- contains(*args, **kwargs)
Overloaded function.
contains(self: higra.higram.EmbeddingGrid2d, coordinates: list[int]) -> bool
Takes a list or tuple representing the coordinates of a point and returns true if the point is contained in the embedding.
contains(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int8]) -> numpy.ndarray[bool]
Takes a n1 x n2 x … nk array, with nk = self.dimension(), and returns a boolean array of dimension n1 x n2 x … n(k-1) indicating if each point is contained in the embedding.
contains(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int16]) -> numpy.ndarray[bool]
contains(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int32]) -> numpy.ndarray[bool]
contains(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int64]) -> numpy.ndarray[bool]
- dimension(self: higra.higram.EmbeddingGrid2d) int
Get the dimension of the embedding (aka self.shape().size()).
- grid2lin(*args, **kwargs)
Overloaded function.
grid2lin(self: higra.higram.EmbeddingGrid2d, coordinates: list[int]) -> int
Compute the linear coordinate of a point given its nd coordinates.
grid2lin(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int8]) -> numpy.ndarray[numpy.uint64]
Takes a n1 x n2 x … nk array, with nk = self.dimension(), and returns a uint64 array of dimension n1 x n2 x … n(k-1) giving the linear coordinate of each point.
grid2lin(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int16]) -> numpy.ndarray[numpy.uint64]
grid2lin(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int32]) -> numpy.ndarray[numpy.uint64]
grid2lin(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int64]) -> numpy.ndarray[numpy.uint64]
- lin2grid(*args, **kwargs)
Overloaded function.
lin2grid(self: higra.higram.EmbeddingGrid2d, index: int) -> numpy.ndarray[numpy.int64]
Compute the nd coordinates of a point given its linear coordinate.
lin2grid(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int8]) -> numpy.ndarray[numpy.int64]
Takes a n1 x n2 x … nk array, and returns an array of dimension n1 x n2 x … nk x self.dimension() where each value, seen as the linear coordinates of a point, has been replaced by the corresponding nd coordinates.
lin2grid(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int16]) -> numpy.ndarray[numpy.int64]
lin2grid(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int32]) -> numpy.ndarray[numpy.int64]
lin2grid(self: higra.higram.EmbeddingGrid2d, points: numpy.ndarray[numpy.int64]) -> numpy.ndarray[numpy.int64]
- shape(self: higra.higram.EmbeddingGrid2d) numpy.ndarray[numpy.int64]
Get the shape/dimensions of the grid embedding
- size(self: higra.higram.EmbeddingGrid2d) int
Get the total number of points contained in the embedding.