Fix bug in add_points method
* solving `add_points` --------- Co-authored-by: Gabriele Codega <gcodega@pascal.maths.sissa.it>
This commit is contained in:
@@ -273,7 +273,7 @@ class AbstractProblem(metaclass=ABCMeta):
|
|||||||
new_pts.labels = old_pts.labels
|
new_pts.labels = old_pts.labels
|
||||||
|
|
||||||
# merging
|
# merging
|
||||||
merged_pts = torch.vstack([old_pts, new_points[location]])
|
merged_pts = torch.vstack([old_pts, new_pts])
|
||||||
merged_pts.labels = old_pts.labels
|
merged_pts.labels = old_pts.labels
|
||||||
self.input_pts[location] = merged_pts
|
self.input_pts[location] = merged_pts
|
||||||
|
|
||||||
|
|||||||
@@ -130,4 +130,15 @@ def test_variables_correct_order_sampling():
|
|||||||
locations=['D'],
|
locations=['D'],
|
||||||
variables=['x'])
|
variables=['x'])
|
||||||
assert poisson_problem.input_pts['D'].labels == sorted(
|
assert poisson_problem.input_pts['D'].labels == sorted(
|
||||||
poisson_problem.input_variables)
|
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'))
|
||||||
|
|||||||
Reference in New Issue
Block a user