-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Thanks for the nice library! I was writing a similar code to solve my inverse problem with PINNs when I stumbled upon your project, and decided to try using it, since it has nice sampling, domain creation, and conditions logic. However, I encounter a problem in a simple situation when I try to obtain points from a 2d domain which is a CutDomain:
import torchphysics as tp
X = tp.spaces.R2("x")
R = tp.domains.Parallelogram(X, [0, 0], [3, 0], [0, 3])
A = tp.domains.Parallelogram(X, [1, 1], [2, 1], [2, 2])
O = R - A
sampler = tp.samplers.RandomUniformSampler(O, n_points=100)
pts = sampler.sample_points()
This gives the assertion error in __torch_function__: assert len(spaces) > 0, asserted here.
Expected behavior:
Have 100 points from domain O, which is a subtraction of A from R.
Observed behavior:
sample_points() call runs sample_domain_uniform() and inside _random_points_inside() when there should be a check of what points belong to the region, there is a eventually a line torch.repeat_interleave(params, n, dim=0), which fails for params = Points.empty()
I would try to fix this issue myself, but I cannot understand the point of the function _repeat_params, and of the assertion. Perhaps you can help clarifying the issue of what the code tries to check and why? Then I'd be able to write up a working version of the code for the case of 2d regions.
Also, I stumbled somewhere that it might be not supported to sample from domains like that? Is that so?