Back compatibility 0.1

This commit is contained in:
Dario Coscia
2025-02-19 16:29:04 +01:00
committed by Nicola Demo
parent df673cad4e
commit 886bd23fdb
9 changed files with 114 additions and 8 deletions

View File

@@ -0,0 +1,13 @@
import warnings
from ..adaptive_function import *
from ..utils import custom_warning_format
# back-compatibility 0.1
# Set the custom format for warnings
warnings.formatwarning = custom_warning_format
warnings.filterwarnings("always", category=DeprecationWarning)
warnings.warn(
f"'pina.adaptive_functions' is deprecated and will be removed "
f"in future versions. Please use 'pina.adaptive_function' instead.",
DeprecationWarning)

View File

@@ -0,0 +1,13 @@
import warnings
from ..callback import *
from ..utils import custom_warning_format
# back-compatibility 0.1
# Set the custom format for warnings
warnings.formatwarning = custom_warning_format
warnings.filterwarnings("always", category=DeprecationWarning)
warnings.warn(
f"'pina.callbacks' is deprecated and will be removed "
f"in future versions. Please use 'pina.callback' instead.",
DeprecationWarning)

View File

@@ -4,7 +4,12 @@ from .domain_equation_condition import DomainEquationCondition
from .input_equation_condition import InputPointsEquationCondition from .input_equation_condition import InputPointsEquationCondition
from .input_output_condition import InputOutputPointsCondition from .input_output_condition import InputOutputPointsCondition
from .data_condition import DataConditionInterface from .data_condition import DataConditionInterface
import warnings
from ..utils import custom_warning_format
# Set the custom format for warnings
warnings.formatwarning = custom_warning_format
warnings.filterwarnings("always", category=DeprecationWarning)
class Condition: class Condition:
""" """
@@ -50,7 +55,16 @@ class Condition:
raise ValueError("Condition takes only the following keyword " raise ValueError("Condition takes only the following keyword "
f"arguments: {Condition.__slots__}.") f"arguments: {Condition.__slots__}.")
# back-compatibility 0.1
if 'location' in kwargs.keys():
kwargs['domain'] = kwargs.pop('location')
warnings.warn(
f"'location' is deprecated and will be removed "
f"in future versions. Please use 'domain' instead.",
DeprecationWarning)
sorted_keys = sorted(kwargs.keys()) sorted_keys = sorted(kwargs.keys())
if sorted_keys == sorted(InputOutputPointsCondition.__slots__): if sorted_keys == sorted(InputOutputPointsCondition.__slots__):
return InputOutputPointsCondition(**kwargs) return InputOutputPointsCondition(**kwargs)
elif sorted_keys == sorted(InputPointsEquationCondition.__slots__): elif sorted_keys == sorted(InputPointsEquationCondition.__slots__):

17
pina/geometry/__init__.py Normal file
View File

@@ -0,0 +1,17 @@
import warnings
from ..domain import *
from ..utils import custom_warning_format
# back-compatibility 0.1
# creating alias
Location = DomainInterface
# Set the custom format for warnings
warnings.formatwarning = custom_warning_format
warnings.filterwarnings("always", category=DeprecationWarning)
warnings.warn(
"'pina.geometry' is deprecated and will be removed "
"in future versions. Please use 'pina.domain' instead. "
"Location moved to DomainInferface object.",
DeprecationWarning)

View File

@@ -0,0 +1,13 @@
import warnings
from ..block import *
from ...utils import custom_warning_format
# back-compatibility 0.1
# Set the custom format for warnings
warnings.formatwarning = custom_warning_format
warnings.filterwarnings("always", category=DeprecationWarning)
warnings.warn(
f"'pina.model.layers' is deprecated and will be removed "
f"in future versions. Please use 'pina.model.block' instead.",
DeprecationWarning)

13
pina/operators.py Normal file
View File

@@ -0,0 +1,13 @@
import warnings
from .operator import *
from .utils import custom_warning_format
# back-compatibility 0.1
# Set the custom format for warnings
warnings.formatwarning = custom_warning_format
warnings.filterwarnings("always", category=DeprecationWarning)
warnings.warn(
f"'pina.operators' is deprecated and will be removed "
f"in future versions. Please use 'pina.operator' instead.",
DeprecationWarning)

View File

@@ -41,10 +41,6 @@ class AbstractProblem(metaclass=ABCMeta):
self.domains[cond_name] = cond.domain self.domains[cond_name] = cond.domain
cond.domain = cond_name cond.domain = cond_name
# @property
# def collector(self):
# return self._collector
@property @property
def batching_dimension(self): def batching_dimension(self):
return self._batching_dimension return self._batching_dimension
@@ -53,10 +49,6 @@ class AbstractProblem(metaclass=ABCMeta):
def batching_dimension(self, value): def batching_dimension(self, value):
self._batching_dimension = value self._batching_dimension = value
@property
def discretised_domains(self):
return self._discretised_domains
# TODO this should be erase when dataloading will interface collector, # TODO this should be erase when dataloading will interface collector,
# kept only for back compatibility # kept only for back compatibility
@property @property
@@ -68,6 +60,10 @@ class AbstractProblem(metaclass=ABCMeta):
elif hasattr(cond, "domain"): elif hasattr(cond, "domain"):
to_return[cond_name] = self._discretised_domains[cond.domain] to_return[cond_name] = self._discretised_domains[cond.domain]
return to_return return to_return
@property
def discretised_domains(self):
return self._discretised_domains
def __deepcopy__(self, memo): def __deepcopy__(self, memo):
""" """

13
pina/solvers/__init__.py Normal file
View File

@@ -0,0 +1,13 @@
import warnings
from ..solver import *
from ..utils import custom_warning_format
# back-compatibility 0.1
# Set the custom format for warnings
warnings.formatwarning = custom_warning_format
warnings.filterwarnings("always", category=DeprecationWarning)
warnings.warn(
f"'pina.solvers' is deprecated and will be removed "
f"in future versions. Please use 'pina.solver' instead.",
DeprecationWarning)

View File

@@ -0,0 +1,14 @@
import warnings
from ...solver.physic_informed_solver import *
from ...utils import custom_warning_format
# back-compatibility 0.1
# Set the custom format for warnings
warnings.formatwarning = custom_warning_format
warnings.filterwarnings("always", category=DeprecationWarning)
warnings.warn(
"'pina.solvers.pinns' is deprecated and will be removed "
"in future versions. Please use "
"'pina.solver.physic_informed_solver' instead.",
DeprecationWarning)