fix doc domain
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Module for Intersection class."""
|
||||
"""Module for the Intersection Operation."""
|
||||
|
||||
import random
|
||||
import torch
|
||||
@@ -7,44 +7,43 @@ from .operation_interface import OperationInterface
|
||||
|
||||
|
||||
class Intersection(OperationInterface):
|
||||
"""
|
||||
PINA implementation of Intersection of Domains.
|
||||
r"""
|
||||
Implementation of the intersection operation between of a list of domains.
|
||||
|
||||
Given two sets :math:`A` and :math:`B`, define the intersection of the two
|
||||
sets as:
|
||||
|
||||
.. math::
|
||||
A \cap B = \{x \mid x \in A \land x \in B\},
|
||||
|
||||
where :math:`x` is a point in :math:`\mathbb{R}^N`.
|
||||
"""
|
||||
|
||||
def __init__(self, geometries):
|
||||
r"""
|
||||
Given two sets :math:`A` and :math:`B` then the
|
||||
domain difference is defined as:
|
||||
"""
|
||||
Initialization of the :class:`Intersection` class.
|
||||
|
||||
.. math::
|
||||
A \cap B = \{x \mid x \in A \land x \in B\},
|
||||
|
||||
with :math:`x` a point in :math:`\mathbb{R}^N` and :math:`N`
|
||||
the dimension of the geometry space.
|
||||
|
||||
:param list geometries: A list of geometries from ``pina.geometry``
|
||||
such as ``EllipsoidDomain`` or ``CartesianDomain``. The intersection
|
||||
will be taken between all the geometries in the list. The resulting
|
||||
geometry will be the intersection of all the geometries in the list.
|
||||
:param list[DomainInterface] geometries: A list of instances of the
|
||||
:class:`~pina.domain.DomainInterface` class on which the intersection
|
||||
operation is performed.
|
||||
|
||||
:Example:
|
||||
>>> # Create two ellipsoid domains
|
||||
>>> ellipsoid1 = EllipsoidDomain({'x': [-1, 1], 'y': [-1, 1]})
|
||||
>>> ellipsoid2 = EllipsoidDomain({'x': [0, 2], 'y': [0, 2]})
|
||||
>>> # Create a Intersection of the ellipsoid domains
|
||||
>>> # Define the intersection of the domains
|
||||
>>> intersection = Intersection([ellipsoid1, ellipsoid2])
|
||||
"""
|
||||
super().__init__(geometries)
|
||||
|
||||
def is_inside(self, point, check_border=False):
|
||||
"""
|
||||
Check if a point is inside the ``Intersection`` domain.
|
||||
Check if a point is inside the resulting domain.
|
||||
|
||||
:param point: Point to be checked.
|
||||
:type point: torch.Tensor
|
||||
:param bool check_border: If ``True``, the border is considered inside.
|
||||
:return: ``True`` if the point is inside the Intersection domain,
|
||||
``False`` otherwise.
|
||||
:param LabelTensor point: Point to be checked.
|
||||
:param bool check_border: If ``True``, the border is considered inside
|
||||
the domain. Default is ``False``.
|
||||
:return: ``True`` if the point is inside the domain, ``False`` otherwise.
|
||||
:rtype: bool
|
||||
"""
|
||||
flag = 0
|
||||
@@ -55,21 +54,21 @@ class Intersection(OperationInterface):
|
||||
|
||||
def sample(self, n, mode="random", variables="all"):
|
||||
"""
|
||||
Sample routine for ``Intersection`` domain.
|
||||
Sampling routine.
|
||||
|
||||
:param int n: Number of points to sample in the shape.
|
||||
:param str mode: Mode for sampling, defaults to ``random``. Available
|
||||
modes include: ``random``.
|
||||
:param variables: Variables to be sampled, defaults to ``all``.
|
||||
:type variables: str | list[str]
|
||||
:return: Returns ``LabelTensor`` of n sampled points.
|
||||
:param int n: Number of points to sample.
|
||||
:param str mode: Sampling method. Default is ``random``.
|
||||
Available modes: random sampling, ``random``;
|
||||
:param list[str] variables: variables to be sampled. Default is ``all``.
|
||||
:raises NotImplementedError: If the sampling method is not implemented.
|
||||
:return: Sampled points.
|
||||
:rtype: LabelTensor
|
||||
|
||||
:Example:
|
||||
>>> # Create two Cartesian domains
|
||||
>>> cartesian1 = CartesianDomain({'x': [0, 2], 'y': [0, 2]})
|
||||
>>> cartesian2 = CartesianDomain({'x': [1, 3], 'y': [1, 3]})
|
||||
>>> # Create a Intersection of the ellipsoid domains
|
||||
>>> # Define the intersection of the domains
|
||||
>>> intersection = Intersection([cartesian1, cartesian2])
|
||||
>>> # Sample
|
||||
>>> intersection.sample(n=5)
|
||||
@@ -80,7 +79,6 @@ class Intersection(OperationInterface):
|
||||
[1.9902, 1.4458]])
|
||||
>>> len(intersection.sample(n=5)
|
||||
5
|
||||
|
||||
"""
|
||||
if mode not in self.sample_modes:
|
||||
raise NotImplementedError(
|
||||
|
||||
Reference in New Issue
Block a user