grig.grid package

Submodules

grig.grid.base_grid module

class grig.grid.base_grid.BaseGrid(*grid, scale_factor=None, scale_offset=None, build_tree=False, tree_shape=None, dtype=None, **kwargs)[source]

Bases: object

Attributes:
features

Return the number of grid dimensions.

regular

Return whether the grid contains feature aligned grid coordinates.

scale_factor

Return the scaling factor between actual and grid coordinates.

scale_offset

Return the scaling offset between actual and grid coordinates.

shape

Return the shape of the grid.

singular

Return whether the grid consists of only a single output coordinate.

size

Return the number of grid vertices.

tree_class

Return the relevant tree class for this grid.

Methods

__call__()

Returns the grid.

get_class_for(thing)

Return a Grid class specific to a given tree, resampler, or name.

get_class_for_name(name)

Return a Grid class of the given name.

get_tree_class()

Return the relevant tree class for the grid.

rescale()

Re-apply the previous scaling factors and offsets if removed.

reshape_data(data)

Reshape data to the grid dimensions.

scale(factor, offset)

Apply a scaling factor and offset to the grid coordinates.

set_indexer([shape, build_tree, build_type])

Calculate the indexing mapping the grid coordinates to the tree.

unscale()

Unscale the grid coordinates.

property features

Return the number of grid dimensions.

Returns:
int
static get_class_for(thing)[source]

Return a Grid class specific to a given tree, resampler, or name.

Parameters:
thingBaseTree or ResampleBase or str

Either a sub-class of a BaseTree, ResampleBase, or a string.

Returns:
BaseTree subclass
static get_class_for_name(name)[source]

Return a Grid class of the given name.

Parameters:
namestr

The name of the grid.

Returns:
BaseGrid subclass
get_tree_class()[source]

Return the relevant tree class for the grid.

Returns:
BaseGrid subclass
property regular

Return whether the grid contains feature aligned grid coordinates.

Returns:
bool
rescale()[source]

Re-apply the previous scaling factors and offsets if removed.

Returns:
None
reshape_data(data)[source]

Reshape data to the grid dimensions.

Note that this will only reshape data if the grid is regular.

Parameters:
datanumpy.ndarray

Data of the shape (n_sets, grid.size) or (grid.size,).

Returns:
reshaped_datanumpy.ndarray

Data of shape (grid.shape).

scale(factor, offset)[source]

Apply a scaling factor and offset to the grid coordinates.

Parameters:
factornumpy.ndarray

A scaling factor of shape (n_features,).

offsetnumpy.ndarray

A scaling offset of shape (n_features,).

Returns:
None
property scale_factor

Return the scaling factor between actual and grid coordinates.

Returns:
numpy.ndarray (float)
property scale_offset

Return the scaling offset between actual and grid coordinates.

Returns:
numpy.ndarray (float)
set_indexer(shape=None, build_tree=False, build_type='hood', **kwargs)[source]

Calculate the indexing mapping the grid coordinates to the tree.

Parameters:
shapetuple (int), optional

The shape of the grid. If not supplied, uses the maximum internal grid coordinates + 1 in each dimension.

build_treebool, optional

If True, builds a neighborhood tree of the type build_type.

build_typestr, optional

Must be one of {‘hood’, ‘balltree’, ‘all’, None}. Please see BaseTree for further details. The default type necessary for resampling is ‘hood’.

kwargsdict, optional

Optional keyword arguments passed into the tree initialization.

Returns:
None
property shape

Return the shape of the grid.

Returns:
tuple (int)
property singular

Return whether the grid consists of only a single output coordinate.

Returns:
bool
property size

Return the number of grid vertices.

Returns:
int
property tree_class

Return the relevant tree class for this grid.

Returns:
BaseTree subclass
unscale()[source]

Unscale the grid coordinates.

Remove a scaling factor and offset if previously applied.

Returns:
None

grig.grid.kernel_grid module

class grig.grid.kernel_grid.KernelGrid(*grid, scale_factor=None, scale_offset=None, build_tree=False, tree_shape=None, dtype=None, **kwargs)[source]

Bases: BaseGrid

The polynomial grid contains a KernelTree instead of the BaseTree object.

Attributes:
features

Return the number of grid dimensions.

regular

Return whether the grid contains feature aligned grid coordinates.

scale_factor

Return the scaling factor between actual and grid coordinates.

scale_offset

Return the scaling offset between actual and grid coordinates.

shape

Return the shape of the grid.

singular

Return whether the grid consists of only a single output coordinate.

size

Return the number of grid vertices.

tree_class

Return the relevant tree class for this grid.

Methods

__call__()

Returns the grid.

get_class_for(thing)

Return a Grid class specific to a given tree, resampler, or name.

get_class_for_name(name)

Return a Grid class of the given name.

get_tree_class()

Return the relevant tree class for the grid.

rescale()

Re-apply the previous scaling factors and offsets if removed.

reshape_data(data)

Reshape data to the grid dimensions.

scale(factor, offset)

Apply a scaling factor and offset to the grid coordinates.

set_indexer([shape, build_tree, build_type])

Calculate the indexing mapping the grid coordinates to the tree.

unscale()

Unscale the grid coordinates.

grig.grid.polynomial_grid module

class grig.grid.polynomial_grid.PolynomialGrid(*grid, scale_factor=None, scale_offset=None, build_tree=False, tree_shape=None, dtype=None, **kwargs)[source]

Bases: BaseGrid

The polynomial grid contains a PolynomialTree instead of the BaseTree object.

Attributes:
features

Return the number of grid dimensions.

regular

Return whether the grid contains feature aligned grid coordinates.

scale_factor

Return the scaling factor between actual and grid coordinates.

scale_offset

Return the scaling offset between actual and grid coordinates.

shape

Return the shape of the grid.

singular

Return whether the grid consists of only a single output coordinate.

size

Return the number of grid vertices.

tree_class

Return the relevant tree class for this grid.

Methods

__call__()

Returns the grid.

get_class_for(thing)

Return a Grid class specific to a given tree, resampler, or name.

get_class_for_name(name)

Return a Grid class of the given name.

get_tree_class()

Return the relevant tree class for the grid.

rescale()

Re-apply the previous scaling factors and offsets if removed.

reshape_data(data)

Reshape data to the grid dimensions.

scale(factor, offset)

Apply a scaling factor and offset to the grid coordinates.

set_indexer([shape, build_tree, build_type])

Calculate the indexing mapping the grid coordinates to the tree.

unscale()

Unscale the grid coordinates.