RectGrid.is_subgrid

RectGrid.is_subgrid(self, other, atol=0.0)[source]

Return True if this grid is a subgrid of other.

Parameters
otherRectGrid

The other grid which is supposed to contain this grid

atolfloat, optional

Allow deviations up to this number in absolute value per coordinate vector entry.

Returns
is_subgridbool

True if all coordinate vectors of self are within absolute distance atol of the other grid, else False.

Examples

>>> rg = uniform_grid([-2, -2], [0, 4], (3, 4))
>>> rg.coord_vectors
(array([-2., -1.,  0.]), array([-2.,  0.,  2.,  4.]))
>>> rg_sub = uniform_grid([-1, 2], [0, 4], (2, 2))
>>> rg_sub.coord_vectors
(array([-1.,  0.]), array([ 2.,  4.]))
>>> rg_sub.is_subgrid(rg)
True

Fuzzy check is also possible. Note that the tolerance still applies to the coordinate vectors.

>>> rg_sub = uniform_grid([-1.015, 2], [0, 3.99], (2, 2))
>>> rg_sub.is_subgrid(rg, atol=0.01)
False
>>> rg_sub.is_subgrid(rg, atol=0.02)
True