Exclusion#
Module for the Exclusion set-operation.
- class Exclusion(geometries)[source]#
Bases:
BaseOperationImplementation of the exclusion operation defined on a list of domains.
Given multiple sets \(A_1, A_2, \ldots, A_n\), define their exclusion as:
\[\bigcup_{i=1}^{n} \big(A_i \setminus \bigcup_{j \neq i} A_j \big)\]In other words, the exclusion operation returns the set of points that belong to exactly one of the input sets.
In case of two sets, the exclusion corresponds to the symmetric difference.
No check is performed to ensure that the resulting domain is non-empty.
- Example:
>>> cartesian1 = CartesianDomain({'x': [0, 1], 'y': [0, 1]}) >>> cartesian2 = CartesianDomain({'x': [0, 1], 'y': [0.5, 1.5]}) >>> exclusion = Exclusion([cartesian1, cartesian2])
Initialization of the
OperationInterfaceclass.- Parameters:
geometries (list[BaseDomain] | tuple[BaseDomain]) – The list of domains on which to perform the set operation.
- Raises:
TypeError – If geometries is neither a list nor a tuple.
ValueError – If geometries elements are not instances of
BaseDomain.NotImplementedError – If the dimensions of the geometries are not consistent.
- is_inside(point, check_border=False)[source]#
Check if a point is inside the exclusion of the domains.
- Parameters:
point (LabelTensor) – The point to check.
check_border (bool) – If
True, the boundary is considered inside the domain. Default isFalse.
- Raises:
ValueError – If
pointis not aLabelTensor.ValueError – If the labels of
pointdiffer from the variables of the domain.
- Returns:
Whether the point is inside the domain or not.
- Return type:
- sample(n, mode='random', variables='all')[source]#
The sampling routine.
Note
This sampling method relies on rejection sampling. Points are drawn from the individual geometries, and only those that lie exclusively within one geometry are kept. When the exclusion domain is small relative to the combined area of the input domains, the method may become highly inefficient.
- Parameters:
- Raises:
AssertionError – If
nis not a positive integer.ValueError – If the sampling mode is invalid.
ValueError – If
variablesis neitherall, a string, nor a list/tuple of strings.ValueError – If any of the specified variables is unknown.
- Returns:
The sampled points.
- Return type:
- partial()[source]#
Return the boundary of the domain resulting from the operation.
- Raises:
NotImplementedError – The
partial()method is not implemented for exclusion domains. Please operate on the individual domains instead.