Skip to content

Commit ef15acc

Browse files
committed
Fix cyclic imports warning and other minor fixes
1 parent ce368f7 commit ef15acc

File tree

13 files changed

+33
-23
lines changed

13 files changed

+33
-23
lines changed

pina/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
Module for the Pina library.
3+
"""
4+
15
__all__ = [
26
"Trainer",
37
"LabelTensor",

pina/adaptive_function/adaptive_function.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ class AdaptiveSigmoid(AdaptiveActivationFunctionInterface):
5050
r"""
5151
Adaptive trainable :class:`~torch.nn.Sigmoid` activation function.
5252
53-
Given the function
53+
Given the function
5454
:math:`\text{Sigmoid}:\mathbb{R}^n\rightarrow\mathbb{R}^n`,
5555
the adaptive function
5656
:math:`\text{Sigmoid}_{\text{adaptive}}:\mathbb{R}^n\rightarrow\mathbb{R}^n`
5757
is defined as:
5858
5959
.. math::
60-
\text{Sigmoid}_{\text{adaptive}}({x})= \\
60+
\text{Sigmoid}_{\text{adaptive}}({x})=
6161
\alpha\,\text{Sigmoid}(\beta{x}+\gamma),
6262
6363
where :math:`\alpha,\,\beta,\,\gamma` are trainable parameters, and the
@@ -344,15 +344,15 @@ class AdaptiveSoftmin(AdaptiveActivationFunctionInterface):
344344
r"""
345345
Adaptive trainable :class:`~torch.nn.Softmin` activation function.
346346
347-
Given the function
347+
Given the function
348348
:math:`\text{Softmin}:\mathbb{R}^n\rightarrow\mathbb{R}^n`,
349349
the adaptive function
350350
:math:`\text{Softmin}_{\text{adaptive}}:\mathbb{R}^n\rightarrow\mathbb{R}^n`
351351
is defined as:
352352
353353
.. math::
354-
\text{Softmin}_{\text{adaptive}}({x})= \\
355-
\alpha\,\text{Softmin}(\beta{x}+\gamma),
354+
\text{Softmin}_{\text{adaptive}}({x})=\alpha\,
355+
\text{Softmin}(\beta{x}+\gamma),
356356
357357
where :math:`\alpha,\,\beta,\,\gamma` are trainable parameters, and the
358358
Softmin function is defined as:
@@ -387,15 +387,15 @@ class AdaptiveSoftmax(AdaptiveActivationFunctionInterface):
387387
r"""
388388
Adaptive trainable :class:`~torch.nn.Softmax` activation function.
389389
390-
Given the function
390+
Given the function
391391
:math:`\text{Softmax}:\mathbb{R}^n\rightarrow\mathbb{R}^n`,
392392
the adaptive function
393393
:math:`\text{Softmax}_{\text{adaptive}}:\mathbb{R}^n\rightarrow\mathbb{R}^n`
394394
is defined as:
395395
396396
.. math::
397-
\text{Softmax}_{\text{adaptive}}({x})= \\
398-
\alpha\,\text{Softmax}(\beta{x}+\gamma),
397+
\text{Softmax}_{\text{adaptive}}({x})=\alpha\,
398+
\text{Softmax}(\beta{x}+\gamma),
399399
400400
where :math:`\alpha,\,\beta,\,\gamma` are trainable parameters, and the
401401
Softmax function is defined as:

pina/domain/exclusion_domain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def __init__(self, geometries):
1818
domain difference is defined as:
1919
2020
.. math::
21-
A \setminus B = \{x \mid x \in A \land x \in B \land x \not\in \\
22-
(A \lor B)\},
21+
A \setminus B = \{x \mid x \in A \land x \in B \land
22+
x \not\in(A \lor B)\},
2323
2424
with :math:`x` a point in :math:`\mathbb{R}^N` and :math:`N`
2525
the dimension of the geometry space.

pina/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import torch
66
from torch_geometric.data import Data, Batch
77
from torch_geometric.utils import to_undirected
8-
from . import LabelTensor
8+
from .label_tensor import LabelTensor
99
from .utils import check_consistency, is_function
1010

1111

pina/loss/lp_loss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class LpLoss(LossInterface):
2525
2626
.. math::
2727
\ell(x, y) = L = \{l_1,\dots,l_N\}^\top, \quad
28-
l_n = \frac{ [\sum_{i=1}^{D} | x_n^i - y_n^i|^p] } \\
29-
{[\sum_{i=1}^{D}|y_n^i|^p]},
28+
l_n = \frac{ [\sum_{i=1}^{D} | x_n^i - y_n^i|^p] }
29+
{[\sum_{i=1}^{D}|y_n^i|^p]},
3030
3131
where :math:`N` is the batch size. If ``reduction`` is not ``none``
3232
(default ``mean``), then:

pina/model/block/gno_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(
3030
"""
3131
# Avoid circular import
3232
# pylint: disable=import-outside-toplevel
33-
from ...model import FeedForward
33+
from ...model.feed_forward import FeedForward
3434

3535
super().__init__(aggr="mean") # Uses PyG's default aggregation
3636
self.width = width

pina/model/graph_neural_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import torch
66
from torch.nn import Tanh
7-
from .block import GNOBlock
7+
from .block.gno_block import GNOBlock
88
from .kernel_neural_operator import KernelNeuralOperator
99

1010

pina/model/multi_feed_forward.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Module for Multi FeedForward model"""
22

3+
from abc import ABC, abstractmethod
34
import torch
4-
55
from .feed_forward import FeedForward
66

77

8-
class MultiFeedForward(torch.nn.Module):
8+
class MultiFeedForward(torch.nn.Module, ABC):
99
"""
1010
The PINA implementation of MultiFeedForward network.
1111
@@ -24,3 +24,9 @@ def __init__(self, ffn_dict):
2424

2525
for name, constructor_args in ffn_dict.items():
2626
setattr(self, name, FeedForward(**constructor_args))
27+
28+
@abstractmethod
29+
def forward(self, *args, **kwargs):
30+
"""
31+
TODO: Docstring
32+
"""

pina/problem/abstract_problem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ..utils import check_consistency
66
from ..domain import DomainInterface, CartesianDomain
77
from ..condition.domain_equation_condition import DomainEquationCondition
8-
from .. import LabelTensor
8+
from ..label_tensor import LabelTensor
99
from ..utils import merge_tensors
1010

1111

pina/solver/garom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def on_train_batch_end(self, outputs, batch, batch_idx):
184184
# increase by one the counter of optimization to save loggers
185185
(
186186
# Unavoidable long line
187-
# pylint: disable=line-too
187+
# pylint: disable=line-too-long
188188
self.trainer.fit_loop.epoch_loop.manual_optimization.optim_step_progress.total.completed
189189
) += 1
190190

0 commit comments

Comments
 (0)