diff --git a/pina/problem/abstract_problem.py b/pina/problem/abstract_problem.py index 90a33d9..e43ac24 100644 --- a/pina/problem/abstract_problem.py +++ b/pina/problem/abstract_problem.py @@ -273,7 +273,7 @@ class AbstractProblem(metaclass=ABCMeta): new_pts.labels = old_pts.labels # merging - merged_pts = torch.vstack([old_pts, new_points[location]]) + merged_pts = torch.vstack([old_pts, new_pts]) merged_pts.labels = old_pts.labels self.input_pts[location] = merged_pts diff --git a/tests/test_problem.py b/tests/test_problem.py index f75fd58..09133d4 100644 --- a/tests/test_problem.py +++ b/tests/test_problem.py @@ -130,4 +130,15 @@ def test_variables_correct_order_sampling(): locations=['D'], variables=['x']) assert poisson_problem.input_pts['D'].labels == sorted( - poisson_problem.input_variables) \ No newline at end of file + poisson_problem.input_variables) + +def test_add_points(): + poisson_problem = Poisson() + poisson_problem.discretise_domain(0, + 'random', + locations=['D'], + variables=['x','y']) + new_pts = LabelTensor(torch.tensor([[0.5,-0.5]]),labels=['x','y']) + poisson_problem.add_points({'D': new_pts}) + assert torch.isclose(poisson_problem.input_pts['D'].extract('x'),new_pts.extract('x')) + assert torch.isclose(poisson_problem.input_pts['D'].extract('y'),new_pts.extract('y'))