Documentation for v0.1 version (#199)
* Adding Equations, solving typos * improve _code.rst * the team rst and restuctore index.rst * fixing errors --------- Co-authored-by: Dario Coscia <dariocoscia@dhcp-015.eduroam.sissa.it>
This commit is contained in:
committed by
Nicola Demo
parent
3f9305d475
commit
8b7b61b3bd
@@ -5,25 +5,63 @@ from pina.geometry import Difference, EllipsoidDomain, CartesianDomain
|
||||
|
||||
|
||||
def test_constructor_two_CartesianDomains():
|
||||
Difference([CartesianDomain({'x': [0, 2], 'y': [0, 2]}),
|
||||
CartesianDomain({'x': [1, 3], 'y': [1, 3]})])
|
||||
Difference([
|
||||
CartesianDomain({
|
||||
'x': [0, 2],
|
||||
'y': [0, 2]
|
||||
}),
|
||||
CartesianDomain({
|
||||
'x': [1, 3],
|
||||
'y': [1, 3]
|
||||
})
|
||||
])
|
||||
|
||||
|
||||
def test_constructor_two_3DCartesianDomain():
|
||||
Difference([CartesianDomain({'x': [0, 2], 'y': [0, 2], 'z': [0, 2]}),
|
||||
CartesianDomain({'x': [1, 3], 'y': [1, 3], 'z': [1, 3]})])
|
||||
Difference([
|
||||
CartesianDomain({
|
||||
'x': [0, 2],
|
||||
'y': [0, 2],
|
||||
'z': [0, 2]
|
||||
}),
|
||||
CartesianDomain({
|
||||
'x': [1, 3],
|
||||
'y': [1, 3],
|
||||
'z': [1, 3]
|
||||
})
|
||||
])
|
||||
|
||||
|
||||
def test_constructor_three_CartesianDomains():
|
||||
Difference([CartesianDomain({'x': [0, 2], 'y': [0, 2]}), CartesianDomain(
|
||||
{'x': [1, 3], 'y': [1, 3]}), CartesianDomain({'x': [2, 4], 'y': [2, 4]})])
|
||||
Difference([
|
||||
CartesianDomain({
|
||||
'x': [0, 2],
|
||||
'y': [0, 2]
|
||||
}),
|
||||
CartesianDomain({
|
||||
'x': [1, 3],
|
||||
'y': [1, 3]
|
||||
}),
|
||||
CartesianDomain({
|
||||
'x': [2, 4],
|
||||
'y': [2, 4]
|
||||
})
|
||||
])
|
||||
|
||||
|
||||
def test_is_inside_two_CartesianDomains():
|
||||
pt_1 = LabelTensor(torch.tensor([[0.5, 0.5]]), ['x', 'y'])
|
||||
pt_2 = LabelTensor(torch.tensor([[-1, -0.5]]), ['x', 'y'])
|
||||
domain = Difference([CartesianDomain({'x': [0, 2], 'y': [0, 2]}),
|
||||
CartesianDomain({'x': [1, 3], 'y': [1, 3]})])
|
||||
domain = Difference([
|
||||
CartesianDomain({
|
||||
'x': [0, 2],
|
||||
'y': [0, 2]
|
||||
}),
|
||||
CartesianDomain({
|
||||
'x': [1, 3],
|
||||
'y': [1, 3]
|
||||
})
|
||||
])
|
||||
assert domain.is_inside(pt_1) == True
|
||||
assert domain.is_inside(pt_2) == False
|
||||
|
||||
@@ -31,16 +69,34 @@ def test_is_inside_two_CartesianDomains():
|
||||
def test_is_inside_two_3DCartesianDomain():
|
||||
pt_1 = LabelTensor(torch.tensor([[0.5, 0.5, 0.5]]), ['x', 'y', 'z'])
|
||||
pt_2 = LabelTensor(torch.tensor([[-1, -0.5, -0.5]]), ['x', 'y', 'z'])
|
||||
domain = Difference([CartesianDomain({'x': [0, 2], 'y': [0, 2], 'z': [
|
||||
0, 2]}), CartesianDomain({'x': [1, 3], 'y': [1, 3], 'z': [1, 3]})])
|
||||
domain = Difference([
|
||||
CartesianDomain({
|
||||
'x': [0, 2],
|
||||
'y': [0, 2],
|
||||
'z': [0, 2]
|
||||
}),
|
||||
CartesianDomain({
|
||||
'x': [1, 3],
|
||||
'y': [1, 3],
|
||||
'z': [1, 3]
|
||||
})
|
||||
])
|
||||
assert domain.is_inside(pt_1) == True
|
||||
assert domain.is_inside(pt_2) == False
|
||||
|
||||
|
||||
def test_sample():
|
||||
n = 100
|
||||
domain = Difference([EllipsoidDomain(
|
||||
{'x': [-1, 1], 'y': [-1, 1]}), CartesianDomain({'x': [-0.5, 0.5], 'y': [-0.5, 0.5]})])
|
||||
domain = Difference([
|
||||
EllipsoidDomain({
|
||||
'x': [-1, 1],
|
||||
'y': [-1, 1]
|
||||
}),
|
||||
CartesianDomain({
|
||||
'x': [-0.5, 0.5],
|
||||
'y': [-0.5, 0.5]
|
||||
})
|
||||
])
|
||||
pts = domain.sample(n)
|
||||
assert isinstance(pts, LabelTensor)
|
||||
assert pts.shape[0] == n
|
||||
|
||||
Reference in New Issue
Block a user