Fix doc condition
This commit is contained in:
committed by
Nicola Demo
parent
bce9eb66ae
commit
6f97799284
@@ -30,7 +30,7 @@ def warning_function(new, old):
|
||||
|
||||
class Condition:
|
||||
"""
|
||||
The class ``Condition`` is used to represent the constraints (physical
|
||||
The class `Condition` is used to represent the constraints (physical
|
||||
equations, boundary conditions, etc.) that should be satisfied in the
|
||||
problem at hand. Condition objects are used to formulate the
|
||||
PINA :obj:`pina.problem.abstract_problem.AbstractProblem` object.
|
||||
@@ -88,11 +88,16 @@ class Condition:
|
||||
"""
|
||||
Create a new condition object based on the keyword arguments passed.
|
||||
|
||||
- ``input`` and ``target``: :class:`InputTargetCondition`
|
||||
- ``domain`` and ``equation``: :class:`DomainEquationCondition`
|
||||
- ``input`` and ``equation``: :class:`InputEquationCondition`
|
||||
- ``input``: :class:`DataCondition`
|
||||
- ``input`` and ``conditional_variables``: :class:`DataCondition`
|
||||
- `input` and `target`:
|
||||
:class:`pina.condition.input_target_condition.InputTargetCondition`
|
||||
- `domain` and `equation`:
|
||||
:class:`pina.condition.domain_equation_condition.
|
||||
DomainEquationCondition`
|
||||
- `input` and `equation`: :class:`pina.condition.
|
||||
input_equation_condition.InputEquationCondition`
|
||||
- `input`: :class:`pina.condition.data_condition.DataCondition`
|
||||
- `input` and `conditional_variables`:
|
||||
:class:`pina.condition.data_condition.DataCondition`
|
||||
|
||||
:raises ValueError: No valid condition has been found.
|
||||
:return: A new condition instance belonging to the proper class.
|
||||
|
||||
@@ -41,14 +41,13 @@ class ConditionInterface(metaclass=ABCMeta):
|
||||
@staticmethod
|
||||
def _check_graph_list_consistency(data_list):
|
||||
"""
|
||||
Check if the list of :class:`torch_geometric.data.Data`/:class:`Graph`
|
||||
objects is consistent.
|
||||
Check if the list of :class:`~torch_geometric.data.Data` or
|
||||
class:`pina.graphGraph` objects is consistent.
|
||||
|
||||
:param data_list: List of graph type objects.
|
||||
:type data_list: torch_geometric.data.Data | Graph|
|
||||
list[torch_geometric.data.Data] | list[Graph]
|
||||
:type data_list: Data | Graph | list[Data] | list[Graph]
|
||||
|
||||
:raises ValueError: Input data must be either torch_geometric.data.Data
|
||||
:raises ValueError: Input data must be either Data
|
||||
or Graph objects.
|
||||
:raises ValueError: All elements in the list must have the same keys.
|
||||
:raises ValueError: Type mismatch in data tensors.
|
||||
|
||||
@@ -27,17 +27,15 @@ class DataCondition(ConditionInterface):
|
||||
|
||||
:param input: Input data for the condition.
|
||||
:type input: torch.Tensor | LabelTensor | Graph |
|
||||
torch_geometric.data.Data | list[Graph] |
|
||||
list[torch_geometric.data.Data] | tuple[Graph] |
|
||||
tuple[torch_geometric.data.Data]
|
||||
Data | list[Graph] | list[Data] | tuple[Graph] | tuple[Data]
|
||||
:param conditional_variables: Conditional variables for the condition.
|
||||
:type conditional_variables: torch.Tensor | LabelTensor
|
||||
:return: Subclass of DataCondition.
|
||||
:rtype: TensorDataCondition | GraphDataCondition
|
||||
|
||||
:raises ValueError: If input is not of type :class:`torch.Tensor`,
|
||||
:class:`LabelTensor`, :class:`Graph`, or
|
||||
:class:`torch_geometric.data.Data`.
|
||||
:class:`pina.label_tensor.LabelTensor`, :class:`pina.graph.Graph`,
|
||||
or :class:`~torch_geometric.data.Data`.
|
||||
|
||||
|
||||
"""
|
||||
@@ -59,21 +57,19 @@ class DataCondition(ConditionInterface):
|
||||
|
||||
def __init__(self, input, conditional_variables=None):
|
||||
"""
|
||||
Initialize the DataCondition, storing the input and conditional
|
||||
Initialize the object by storing the input and conditional
|
||||
variables (if any).
|
||||
|
||||
:param input: Input data for the condition.
|
||||
:type input: torch.Tensor | LabelTensor | Graph |
|
||||
torch_geometric.data.Data | list[Graph] |
|
||||
list[torch_geometric.data.Data] | tuple[Graph] |
|
||||
tuple[torch_geometric.data.Data]
|
||||
:type input: torch.Tensor | LabelTensor | Graph | Data | list[Graph] |
|
||||
list[Data] | tuple[Graph] | tuple[Data]
|
||||
:param conditional_variables: Conditional variables for the condition.
|
||||
:type conditional_variables: torch.Tensor or LabelTensor
|
||||
|
||||
.. note::
|
||||
If either `input` is composed by a list of :class:`Graph`/
|
||||
:class:`torch_geometric.data.Data` objects, all elements must have
|
||||
the same structure (keys and data types)
|
||||
If either `input` is composed by a list of :class:`pina.graph.Graph`
|
||||
or :class:`~torch_geometric.data.Data` objects, all elements must
|
||||
have the same structure (keys and data types)
|
||||
"""
|
||||
super().__init__()
|
||||
self.input = input
|
||||
@@ -82,11 +78,13 @@ class DataCondition(ConditionInterface):
|
||||
|
||||
class TensorDataCondition(DataCondition):
|
||||
"""
|
||||
DataCondition for torch.Tensor input data
|
||||
DataCondition for :class:`torch.Tensor` or
|
||||
:class:`pina.label_tensor.LabelTensor` input data
|
||||
"""
|
||||
|
||||
|
||||
class GraphDataCondition(DataCondition):
|
||||
"""
|
||||
DataCondition for Graph/Data input data
|
||||
DataCondition for :class:`pina.graph.Graph` or
|
||||
:class:`~torch_geometric.data.Data` input data
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ class DomainEquationCondition(ConditionInterface):
|
||||
|
||||
def __init__(self, domain, equation):
|
||||
"""
|
||||
Initialize the DomainEquationCondition, storing the domain and equation.
|
||||
Initialize the object by storing the domain and equation.
|
||||
|
||||
:param DomainInterface domain: Domain object containing the domain data.
|
||||
:param EquationInterface equation: Equation object containing the
|
||||
|
||||
@@ -32,9 +32,8 @@ class InputEquationCondition(ConditionInterface):
|
||||
:return: Subclass of InputEquationCondition, based on the input type.
|
||||
:rtype: InputTensorEquationCondition | InputGraphEquationCondition
|
||||
|
||||
:raises ValueError: If input is not of type :class:`torch.Tensor`,
|
||||
:class:`LabelTensor`, :class:`Graph`, or
|
||||
:class:`torch_geometric.data.Data`.
|
||||
:raises ValueError: If input is not of type
|
||||
:class:`pina.label_tensor.LabelTensor`, :class:`pina.graph.Graph`.
|
||||
"""
|
||||
|
||||
# If the class is already a subclass, return the instance
|
||||
@@ -66,10 +65,10 @@ class InputEquationCondition(ConditionInterface):
|
||||
equation function.
|
||||
|
||||
.. note::
|
||||
If ``input`` is composed by a list of :class:`Graph`/
|
||||
:class:`torch_geometric.data.Data` objects, all elements must have
|
||||
the same structure (keys and data types). Moreover, at least one
|
||||
attribute must be a :class:`LabelTensor`.
|
||||
If `input` is composed by a list of :class:`pina.graph.Graph`
|
||||
objects, all elements must have the same structure (keys and data
|
||||
types). Moreover, at least one attribute must be a
|
||||
:class:`pina.label_tensor.LabelTensor`.
|
||||
"""
|
||||
|
||||
super().__init__()
|
||||
@@ -89,19 +88,21 @@ class InputEquationCondition(ConditionInterface):
|
||||
|
||||
class InputTensorEquationCondition(InputEquationCondition):
|
||||
"""
|
||||
InputEquationCondition subclass for LabelTensor input data.
|
||||
InputEquationCondition subclass for :class:`pina.label_tensor.LabelTensor`
|
||||
input data.
|
||||
"""
|
||||
|
||||
|
||||
class InputGraphEquationCondition(InputEquationCondition):
|
||||
"""
|
||||
InputEquationCondition subclass for Graph input data.
|
||||
InputEquationCondition subclass for :class:`pina.graph.Graph` input data.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def _check_label_tensor(input):
|
||||
"""
|
||||
Check if at least one LabelTensor is present in the Graph object.
|
||||
Check if at least one :class:`pina.label_tensor.LabelTensor` is present
|
||||
in the :class:`pina.graph.Graph` object.
|
||||
|
||||
:param input: Input data.
|
||||
:type input: torch.Tensor | Graph | torch_geometric.data.Data
|
||||
|
||||
@@ -41,8 +41,8 @@ class InputTargetCondition(ConditionInterface):
|
||||
GraphInputGraphTargetCondition
|
||||
|
||||
:raises ValueError: If input and or target are not of type
|
||||
:class:`torch.Tensor`, :class:`LabelTensor`, :class:`Graph`, or
|
||||
:class:`torch_geometric.data.Data`.
|
||||
:class:`torch.Tensor`, :class:`pina.label_tensor.LabelTensor`,
|
||||
:class:`pina.graph.Graph`, or :class:`~torch_geometric.data.Data`.
|
||||
"""
|
||||
if cls != InputTargetCondition:
|
||||
return super().__new__(cls)
|
||||
@@ -82,23 +82,21 @@ class InputTargetCondition(ConditionInterface):
|
||||
|
||||
def __init__(self, input, target):
|
||||
"""
|
||||
Initialize the InputTargetCondition, storing the input and target data.
|
||||
Initialize the object storing the input and target data.
|
||||
|
||||
:param input: Input data for the condition.
|
||||
:type input: torch.Tensor | LabelTensor | Graph |
|
||||
torch_geometric.data.Data | list[Graph] |
|
||||
list[torch_geometric.data.Data] | tuple[Graph] |
|
||||
tuple[torch_geometric.data.Data]
|
||||
:type input: torch.Tensor | LabelTensor | Graph | Data | list[Graph] |
|
||||
list[Data] | tuple[Graph] |
|
||||
tuple[Data]
|
||||
:param target: Target data for the condition.
|
||||
:type target: torch.Tensor | LabelTensor | Graph |
|
||||
torch_geometric.data.Data | list[Graph] |
|
||||
list[torch_geometric.data.Data] | tuple[Graph] |
|
||||
tuple[torch_geometric.data.Data]
|
||||
:type target: torch.Tensor | LabelTensor | Graph | Data | list[Graph] |
|
||||
list[Data] | tuple[Graph] | tuple[Data]
|
||||
|
||||
.. note::
|
||||
If either ``input`` or ``target`` are composed by a list of
|
||||
:class:`Graph`/:class:`torch_geometric.data.Data` objects, all
|
||||
elements must have the same structure (keys and data types)
|
||||
If either `input` or `target` are composed by a list of
|
||||
:class:`pina.graph.Graph` or :class:`~torch_geometric.data.Data`
|
||||
objects, all elements must have the same structure (keys and data
|
||||
types)
|
||||
"""
|
||||
|
||||
super().__init__()
|
||||
@@ -120,28 +118,30 @@ class InputTargetCondition(ConditionInterface):
|
||||
|
||||
class TensorInputTensorTargetCondition(InputTargetCondition):
|
||||
"""
|
||||
InputTargetCondition subclass for :class:`torch.Tensor`/:class:`LabelTensor`
|
||||
input and target data.
|
||||
InputTargetCondition subclass for :class:`torch.Tensor` or
|
||||
:class:`pina.label_tensor.LabelTensor` input and target data.
|
||||
"""
|
||||
|
||||
|
||||
class TensorInputGraphTargetCondition(InputTargetCondition):
|
||||
"""
|
||||
InputTargetCondition subclass for :class:`torch.Tensor`/:class:`LabelTensor`
|
||||
input and :class:`Graph`/:class:`torch_geometric.data.Data` target data.
|
||||
InputTargetCondition subclass for :class:`torch.Tensor` or
|
||||
:class:`pina.label_tensor.LabelTensor` input and
|
||||
:class:`pina.graph.Graph` or :class:`~torch_geometric.data.Data` target
|
||||
data.
|
||||
"""
|
||||
|
||||
|
||||
class GraphInputTensorTargetCondition(InputTargetCondition):
|
||||
"""
|
||||
InputTargetCondition subclass for :class:`Graph`/
|
||||
:class:`torch_geometric.data.Data` input and :class:`torch.Tensor`/
|
||||
:class:`LabelTensor` target data.
|
||||
InputTargetCondition subclass for :class:`pina.graph.Graph` o
|
||||
:class:`~torch_geometric.data.Data` input and :class:`torch.Tensor` or
|
||||
:class:`pina.label_tensor.LabelTensor` target data.
|
||||
"""
|
||||
|
||||
|
||||
class GraphInputGraphTargetCondition(InputTargetCondition):
|
||||
"""
|
||||
InputTargetCondition subclass for :class:`Graph`/
|
||||
:class:`torch_geometric.data.Data` input and target data.
|
||||
InputTargetCondition subclass for :class:`pina.graph.Graph`/
|
||||
:class:`~torch_geometric.data.Data` input and target data.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user