fix connection issue
This commit is contained in:
committed by
Giovanni Canali
parent
09596a912c
commit
4ad939fdb9
@@ -1,12 +1,25 @@
|
||||
from pina.problem.zoo import InversePoisson2DSquareProblem
|
||||
from pina.problem import InverseProblem, SpatialProblem
|
||||
import pytest
|
||||
|
||||
|
||||
def test_constructor():
|
||||
problem = InversePoisson2DSquareProblem()
|
||||
@pytest.mark.parametrize("load", [True, False])
|
||||
@pytest.mark.parametrize("data_size", [0.01, 0.05])
|
||||
def test_constructor(load, data_size):
|
||||
|
||||
# Define the problem with or without loading data
|
||||
problem = InversePoisson2DSquareProblem(load=load, data_size=data_size)
|
||||
|
||||
# Discretise the domain
|
||||
problem.discretise_domain(n=10, mode="random", domains="all")
|
||||
|
||||
# Check if the problem is correctly set up
|
||||
assert problem.are_all_domains_discretised
|
||||
assert isinstance(problem, InverseProblem)
|
||||
assert isinstance(problem, SpatialProblem)
|
||||
assert hasattr(problem, "conditions")
|
||||
assert isinstance(problem.conditions, dict)
|
||||
|
||||
# Should fail if data_size is not in the range [0.0, 1.0]
|
||||
with pytest.raises(ValueError):
|
||||
problem = InversePoisson2DSquareProblem(load=load, data_size=3.0)
|
||||
|
||||
@@ -20,15 +20,9 @@ from torch._dynamo.eval_frame import OptimizedModule
|
||||
# define problems
|
||||
problem = Poisson()
|
||||
problem.discretise_domain(10)
|
||||
inverse_problem = InversePoisson()
|
||||
inverse_problem = InversePoisson(load=True, data_size=0.01)
|
||||
inverse_problem.discretise_domain(10)
|
||||
|
||||
# reduce the number of data points to speed up testing
|
||||
if hasattr(inverse_problem.conditions, "data"):
|
||||
data_condition = inverse_problem.conditions["data"]
|
||||
data_condition.input = data_condition.input[:10]
|
||||
data_condition.target = data_condition.target[:10]
|
||||
|
||||
# add input-output condition to test supervised learning
|
||||
input_pts = torch.rand(10, len(problem.input_variables))
|
||||
input_pts = LabelTensor(input_pts, problem.input_variables)
|
||||
|
||||
@@ -31,15 +31,9 @@ class DummyTimeProblem(TimeDependentProblem):
|
||||
# define problems
|
||||
problem = Poisson()
|
||||
problem.discretise_domain(10)
|
||||
inverse_problem = InversePoisson()
|
||||
inverse_problem = InversePoisson(load=True, data_size=0.01)
|
||||
inverse_problem.discretise_domain(10)
|
||||
|
||||
# reduce the number of data points to speed up testing
|
||||
if hasattr(inverse_problem.conditions, "data"):
|
||||
data_condition = inverse_problem.conditions["data"]
|
||||
data_condition.input = data_condition.input[:10]
|
||||
data_condition.target = data_condition.target[:10]
|
||||
|
||||
# add input-output condition to test supervised learning
|
||||
input_pts = torch.rand(10, len(problem.input_variables))
|
||||
input_pts = LabelTensor(input_pts, problem.input_variables)
|
||||
|
||||
@@ -20,15 +20,9 @@ from torch._dynamo.eval_frame import OptimizedModule
|
||||
# define problems
|
||||
problem = Poisson()
|
||||
problem.discretise_domain(10)
|
||||
inverse_problem = InversePoisson()
|
||||
inverse_problem = InversePoisson(load=True, data_size=0.01)
|
||||
inverse_problem.discretise_domain(10)
|
||||
|
||||
# reduce the number of data points to speed up testing
|
||||
if hasattr(inverse_problem.conditions, "data"):
|
||||
data_condition = inverse_problem.conditions["data"]
|
||||
data_condition.input = data_condition.input[:10]
|
||||
data_condition.target = data_condition.target[:10]
|
||||
|
||||
# add input-output condition to test supervised learning
|
||||
input_pts = torch.rand(10, len(problem.input_variables))
|
||||
input_pts = LabelTensor(input_pts, problem.input_variables)
|
||||
|
||||
@@ -19,15 +19,9 @@ from torch._dynamo.eval_frame import OptimizedModule
|
||||
# define problems
|
||||
problem = Poisson()
|
||||
problem.discretise_domain(10)
|
||||
inverse_problem = InversePoisson()
|
||||
inverse_problem = InversePoisson(load=True, data_size=0.01)
|
||||
inverse_problem.discretise_domain(10)
|
||||
|
||||
# reduce the number of data points to speed up testing
|
||||
if hasattr(inverse_problem.conditions, "data"):
|
||||
data_condition = inverse_problem.conditions["data"]
|
||||
data_condition.input = data_condition.input[:10]
|
||||
data_condition.target = data_condition.target[:10]
|
||||
|
||||
# add input-output condition to test supervised learning
|
||||
input_pts = torch.rand(10, len(problem.input_variables))
|
||||
input_pts = LabelTensor(input_pts, problem.input_variables)
|
||||
|
||||
@@ -20,15 +20,9 @@ from torch._dynamo.eval_frame import OptimizedModule
|
||||
# define problems
|
||||
problem = Poisson()
|
||||
problem.discretise_domain(10)
|
||||
inverse_problem = InversePoisson()
|
||||
inverse_problem = InversePoisson(load=True, data_size=0.01)
|
||||
inverse_problem.discretise_domain(10)
|
||||
|
||||
# reduce the number of data points to speed up testing
|
||||
if hasattr(inverse_problem.conditions, "data"):
|
||||
data_condition = inverse_problem.conditions["data"]
|
||||
data_condition.input = data_condition.input[:10]
|
||||
data_condition.target = data_condition.target[:10]
|
||||
|
||||
# add input-output condition to test supervised learning
|
||||
input_pts = torch.rand(10, len(problem.input_variables))
|
||||
input_pts = LabelTensor(input_pts, problem.input_variables)
|
||||
|
||||
Reference in New Issue
Block a user