1- """
2- Condition module.
3- """
1+ """Condition module."""
42
53import warnings
64from .data_condition import DataCondition
1513
1614
1715def warning_function (new , old ):
18- """
19- Handle the deprecation warning.
16+ """Handle the deprecation warning.
2017
21- :param str new: Object to use instead of the old one.
22- :param str old: Object to deprecate.
18+ :param new: Object to use instead of the old one.
19+ :type new: str
20+ :param old: Object to deprecate.
21+ :type old: str
2322 """
2423 warnings .warn (
2524 f"'{ old } ' is deprecated and will be removed "
@@ -30,49 +29,58 @@ def warning_function(new, old):
3029
3130class Condition :
3231 """
33- The class `Condition` is used to represent the constraints (physical
32+ The class `` Condition` ` is used to represent the constraints (physical
3433 equations, boundary conditions, etc.) that should be satisfied in the
3534 problem at hand. Condition objects are used to formulate the
3635 PINA :obj:`pina.problem.abstract_problem.AbstractProblem` object.
3736 Conditions can be specified in four ways:
3837
39- 1. By specifying the input and output points of the condition; in such a
38+ 1. By specifying the input and target of the condition; in such a
4039 case, the model is trained to produce the output points given the input
41- points. Those points can either be torch.Tensor, LabelTensors, Graph
40+ points. Those points can either be torch.Tensor, LabelTensors, Graph.
41+ Based on the type of the input and target, there are different
42+ implementations of the condition. For more details, see
43+ :class:`~pina.condition.input_target_condition.InputTargetCondition`.
4244
43- 2. By specifying the location and the equation of the condition; in such
45+ 2. By specifying the domain and the equation of the condition; in such
4446 a case, the model is trained to minimize the equation residual by
45- evaluating it at some samples of the location .
47+ evaluating it at some samples of the domain .
4648
47- 3. By specifying the input points and the equation of the condition; in
49+ 3. By specifying the input and the equation of the condition; in
4850 such a case, the model is trained to minimize the equation residual by
4951 evaluating it at the passed input points. The input points must be
50- a LabelTensor.
52+ a LabelTensor. Based on the type of the input, there are different
53+ implementations of the condition. For more details, see
54+ :class:`~pina.condition.input_equation_condition.InputEquationCondition`
55+ .
5156
52- 4. By specifying only the data matrix ; in such a case the model is
57+ 4. By specifying only the input data ; in such a case the model is
5358 trained with an unsupervised costum loss and uses the data in training.
5459 Additionaly conditioning variables can be passed, whenever the model
55- has extra conditioning variable it depends on.
60+ has extra conditioning variable it depends on. Based on the type of the
61+ input, there are different implementations of the condition. For more
62+ details, see :class:`~pina.condition.data_condition.DataCondition`.
5663
5764 Example::
5865
59- >>> from pina import Condition
60- >>> condition = Condition(
61- ... input=input,
62- ... target=target
63- ... )
64- >>> condition = Condition(
65- ... domain=location,
66- ... equation=equation
67- ... )
68- >>> condition = Condition(
69- ... input=input,
70- ... equation=equation
71- ... )
72- >>> condition = Condition(
73- ... input=data,
74- ... conditional_variables=conditional_variables
75- ... )
66+ >>> from pina import Condition
67+ >>> condition = Condition(
68+ ... input=input,
69+ ... target=target
70+ ... )
71+ >>> condition = Condition(
72+ ... domain=location,
73+ ... equation=equation
74+ ... )
75+ >>> condition = Condition(
76+ ... input=input,
77+ ... equation=equation
78+ ... )
79+ >>> condition = Condition(
80+ ... input=data,
81+ ... conditional_variables=conditional_variables
82+ ... )
83+
7684 """
7785
7886 __slots__ = list (
@@ -86,24 +94,14 @@ class Condition:
8694
8795 def __new__ (cls , * args , ** kwargs ):
8896 """
89- Create a new condition object based on the keyword arguments passed.
90-
91- - `input` and `target`:
92- :class:`~pina.condition.input_target_condition.InputTargetCondition`
93- - `domain` and `equation`:
94- :class:`~pina.condition.domain_equation_condition.
95- DomainEquationCondition`
96- - `input` and `equation`: :class:`~pina.condition.
97- input_equation_condition.InputEquationCondition`
98- - `input`: :class:`~pina.condition.data_condition.DataCondition`
99- - `input` and `conditional_variables`:
100- :class:`~pina.condition.data_condition.DataCondition`
101- :return: A new condition instance belonging to the proper class.
102- :rtype: InputTargetCondition | DomainEquationCondition |
103- InputEquationCondition | DataCondition
104-
105- :raises ValueError: No valid condition has been found.
97+ Check the input arguments and return the appropriate Condition object.
98+
99+ :raises ValueError: If no keyword arguments are passed.
100+ :raises ValueError: If the keyword arguments are invalid.
101+ :return: The appropriate Condition object.
102+ :rtype: ConditionInterface
106103 """
104+
107105 if len (args ) != 0 :
108106 raise ValueError (
109107 "Condition takes only the following keyword "
0 commit comments