Union#

Module for the Union operation.

class Union(geometries)[source]#

Bases: BaseOperation

Implementation of the union operation defined on a list of domains.

Given multiple sets \(A_1, A_2, \ldots, A_n\), define their union as:

\[\bigcup_{i=1}^{n} A_i = \{x \mid \exists i: x \in A_i \}\]
Example:
>>> cartesian1 = CartesianDomain({'x': [0, 1], 'y': [0, 1]})
>>> cartesian2 = CartesianDomain({'x': [0, 1], 'y': [1, 2]})
>>> union = Union([cartesian1, cartesian2])

Initialization of the OperationInterface class.

Parameters:

geometries (list[BaseDomain] | tuple[BaseDomain]) – The list of domains on which to perform the set operation.

Raises:
is_inside(point, check_border=False)[source]#

Check if a point is inside the union of the domains.

Parameters:
  • point (LabelTensor) – The point to check.

  • check_border (bool) – If True, the boundary is considered inside the domain. Default is False.

Raises:
  • ValueError – If point is not a LabelTensor.

  • ValueError – If the labels of point differ from the variables of the domain.

Returns:

Whether the point is inside the domain or not.

Return type:

bool

sample(n, mode='random', variables='all')[source]#

The sampling routine.

Parameters:
  • n (int) – The number of samples to generate.

  • mode (str) – The sampling method. Default is random.

  • variables (list[str] | str) – The list of variables to sample. If all, all variables are sampled. Default is all.

Raises:
  • AssertionError – If n is not a positive integer.

  • ValueError – If the sampling mode is invalid.

  • ValueError – If variables is neither all, a string, nor a list/tuple of strings.

  • ValueError – If any of the specified variables is unknown.

Returns:

The sampled points.

Return type:

LabelTensor

partial()[source]#

Return the boundary of the domain resulting from the operation.

Raises:

NotImplementedError – The partial() method is not implemented for union domains. Please operate on the individual domains instead.