Fix Codacy Warnings (#477)
--------- Co-authored-by: Dario Coscia <dariocos99@gmail.com>
This commit is contained in:
committed by
Nicola Demo
parent
e3790e049a
commit
4177bfbb50
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
Module for defining equations and system of equations.
|
||||
"""
|
||||
|
||||
__all__ = [
|
||||
"SystemEquation",
|
||||
"Equation",
|
||||
|
||||
@@ -4,10 +4,12 @@ from .equation_interface import EquationInterface
|
||||
|
||||
|
||||
class Equation(EquationInterface):
|
||||
"""
|
||||
Equation class for specifing any equation in PINA.
|
||||
"""
|
||||
|
||||
def __init__(self, equation):
|
||||
"""
|
||||
Equation class for specifing any equation in PINA.
|
||||
Each ``equation`` passed to a ``Condition`` object
|
||||
must be an ``Equation`` or ``SystemEquation``.
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
"""Module"""
|
||||
"""Module for defining different equations."""
|
||||
|
||||
from .equation import Equation
|
||||
from ..operator import grad, div, laplacian
|
||||
|
||||
|
||||
class FixedValue(Equation):
|
||||
"""
|
||||
Fixed Value Equation class.
|
||||
"""
|
||||
|
||||
def __init__(self, value, components=None):
|
||||
"""
|
||||
Fixed Value Equation class. This class can be
|
||||
This class can be
|
||||
used to enforced a fixed value for a specific
|
||||
condition, e.g. Dirichlet Boundary conditions.
|
||||
|
||||
@@ -29,11 +32,13 @@ class FixedValue(Equation):
|
||||
|
||||
|
||||
class FixedGradient(Equation):
|
||||
"""
|
||||
Fixed Gradient Equation class.
|
||||
"""
|
||||
|
||||
def __init__(self, value, components=None, d=None):
|
||||
"""
|
||||
Fixed Gradient Equation class. This class can be
|
||||
used to enforced a fixed gradient for a specific
|
||||
This class can beused to enforced a fixed gradient for a specific
|
||||
condition.
|
||||
|
||||
:param float value: Value to be mantained fixed.
|
||||
@@ -55,11 +60,13 @@ class FixedGradient(Equation):
|
||||
|
||||
|
||||
class FixedFlux(Equation):
|
||||
"""
|
||||
Fixed Flux Equation class.
|
||||
"""
|
||||
|
||||
def __init__(self, value, components=None, d=None):
|
||||
"""
|
||||
Fixed Flux Equation class. This class can be
|
||||
used to enforced a fixed flux for a specific
|
||||
This class can be used to enforced a fixed flux for a specific
|
||||
condition.
|
||||
|
||||
:param float value: Value to be mantained fixed.
|
||||
@@ -81,10 +88,13 @@ class FixedFlux(Equation):
|
||||
|
||||
|
||||
class Laplace(Equation):
|
||||
"""
|
||||
Laplace Equation class.
|
||||
"""
|
||||
|
||||
def __init__(self, components=None, d=None):
|
||||
"""
|
||||
Laplace Equation class. This class can be
|
||||
This class can be
|
||||
used to enforced a Laplace equation for a specific
|
||||
condition (force term set to zero).
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ class EquationInterface(metaclass=ABCMeta):
|
||||
Residual computation of the equation.
|
||||
|
||||
:param LabelTensor input_: Input points to evaluate the equation.
|
||||
:param LabelTensor output_: Output vectors given by my model (e.g., a ``FeedForward`` model).
|
||||
:param LabelTensor output_: Output vectors given by my model (e.g.,
|
||||
a ``FeedForward`` model).
|
||||
:param dict params_: Dictionary of unknown parameters, eventually
|
||||
related to an ``InverseProblem``.
|
||||
:return: The residual evaluation of the specified equation.
|
||||
:rtype: LabelTensor
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
"""Module for SystemEquation."""
|
||||
|
||||
import torch
|
||||
from .equation_interface import EquationInterface
|
||||
from .equation import Equation
|
||||
from ..utils import check_consistency
|
||||
|
||||
|
||||
class SystemEquation(Equation):
|
||||
class SystemEquation(EquationInterface):
|
||||
"""
|
||||
System of Equation class for specifing any system
|
||||
of equations in PINA.
|
||||
"""
|
||||
|
||||
def __init__(self, list_equation, reduction=None):
|
||||
"""
|
||||
System of Equation class for specifing any system
|
||||
of equations in PINA.
|
||||
Each ``equation`` passed to a ``Condition`` object
|
||||
must be an ``Equation`` or ``SystemEquation``.
|
||||
A ``SystemEquation`` is specified by a list of
|
||||
@@ -37,7 +40,7 @@ class SystemEquation(Equation):
|
||||
self.reduction = torch.mean
|
||||
elif reduction == "sum":
|
||||
self.reduction = torch.sum
|
||||
elif (reduction == None) or callable(reduction):
|
||||
elif (reduction is None) or callable(reduction):
|
||||
self.reduction = reduction
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
|
||||
Reference in New Issue
Block a user