dynabench.dataset.transforms

Functions

abstractmethod(funcobj)

A decorator indicating abstract methods.

copy(x)

Shallow copy operation on arbitrary Python objects.

Classes

ABC()

Helper class that provides a standard way to create an ABC using inheritance.

BaseTransform(**kwargs)

CloudDataItem(x[, y, pos, neighbors, ...])

Data class for 2D grid data.

Compose(transforms)

Compose function for combining multiple transforms.

DataItem(x[, y, pos])

Base class for data items.

DefaultTransform()

Default transformation for a data item.

EdgeList(k)

Create an edge list graph (src, dst) to use with PyG.

EdgeListFromKNN()

Create an edge list from the KNN graph.

Grid2Cloud()

Create a Cloud item from a grid data item

GridDataItem(x[, y, pos])

Data class for grid data.

GridDownsampleFFT([target_size])

Downsample the grid to a smaller size using FFT.

GridDownsampleFactor([factor])

Downsample the grid by a factor.

Iterable()

KDTree(data[, leafsize, compact_nodes, ...])

kd-tree for quick nearest-neighbor lookup.

KNNGraph(k[, grid_limits])

Create a KNN graph from the cloud data.

PointSampling([num_points])

Point sampling transform for the dataset.

ToDict()

Convert the data item to a dictionary.

TypeCaster(dtype)

Cast the data item to the correct type.

class dynabench.dataset.transforms.BaseTransform(**kwargs)[source]

Bases: ABC

class dynabench.dataset.transforms.Compose(transforms: List[BaseTransform])[source]

Bases: BaseTransform

Compose function for combining multiple transforms. Iterates over transformations and applies them to the data item.

Parameters:

transforms (List[BaseTransform]) – List of transforms to be applied to the data

class dynabench.dataset.transforms.DefaultTransform[source]

Bases: BaseTransform

Default transformation for a data item. Does not modify the data.

Parameters:

data_item (DataItem)

Returns:

transformed data_item

Return type:

DataItem

class dynabench.dataset.transforms.EdgeList(k: int)[source]

Bases: Compose

Create an edge list graph (src, dst) to use with PyG.

Parameters:

data_item (CloudItem)

Returns:

data_item with edge_list as knn_graph

Return type:

CloudItem

class dynabench.dataset.transforms.EdgeListFromKNN[source]

Bases: BaseTransform

Create an edge list from the KNN graph.

Parameters:

data_item (CloudItem)

Returns:

data_item with knn_graph

Return type:

CloudItem

check_if_valid()[source]
class dynabench.dataset.transforms.Grid2Cloud[source]

Bases: BaseTransform

Create a Cloud item from a grid data item

Parameters:

data_item (GridItem)

Returns:

data_item with cloud shape

Return type:

CloudItem

class dynabench.dataset.transforms.GridDownsampleFFT(target_size: Tuple[int, int] = (1.0, 1.0))[source]

Bases: BaseTransform

Downsample the grid to a smaller size using FFT.

Parameters:

target_size (Tuple[int, int]) – Target size of the grid.

class dynabench.dataset.transforms.GridDownsampleFactor(factor: int = 2)[source]

Bases: BaseTransform

Downsample the grid by a factor.

Parameters:

factor (int) – Factor by which to downsample the grid.

class dynabench.dataset.transforms.KNNGraph(k: int, grid_limits: Tuple[float] = (1.0, 1.0))[source]

Bases: BaseTransform

Create a KNN graph from the cloud data.

Parameters:

data_item (CloudItem)

Returns:

data_item with knn_graph

Return type:

CloudItem

check_if_valid()[source]
class dynabench.dataset.transforms.PointSampling(num_points: int = 900)[source]

Bases: BaseTransform

Point sampling transform for the dataset.

Parameters:
  • num_points (int) – Number of points to sample.

  • k (int) – Number of nearest neighbors to use for the KNN graph.

class dynabench.dataset.transforms.ToDict[source]

Bases: BaseTransform

Convert the data item to a dictionary.

Parameters:

data_item (DataItem)

Returns:

data_item as a dictionary

Return type:

dict

class dynabench.dataset.transforms.TypeCaster(dtype: ~numpy.dtype = <class 'numpy.float32'>)[source]

Bases: BaseTransform

Cast the data item to the correct type. (In place!!!)