codac4matlab 2.0.0.dev25__cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. codac4matlab/__init__.py +4 -0
  2. codac4matlab/_core.cpython-314-aarch64-linux-gnu.so +0 -0
  3. codac4matlab/_graphics.cpython-314-aarch64-linux-gnu.so +0 -0
  4. codac4matlab/_unsupported.cpython-314-aarch64-linux-gnu.so +0 -0
  5. codac4matlab/core/__init__.py +588 -0
  6. codac4matlab/empty.cpython-314-aarch64-linux-gnu.so +0 -0
  7. codac4matlab/graphics/__init__.py +1 -0
  8. codac4matlab/tests/__init__.py +1 -0
  9. codac4matlab/tests/test_AnalyticFunction.py +442 -0
  10. codac4matlab/tests/test_AnalyticTraj.py +62 -0
  11. codac4matlab/tests/test_Approx.py +27 -0
  12. codac4matlab/tests/test_BoolInterval.py +96 -0
  13. codac4matlab/tests/test_Color.py +77 -0
  14. codac4matlab/tests/test_ConvexPolygon.py +300 -0
  15. codac4matlab/tests/test_CtcAction.py +30 -0
  16. codac4matlab/tests/test_CtcCartProd.py +39 -0
  17. codac4matlab/tests/test_CtcCtcBoundary.py +48 -0
  18. codac4matlab/tests/test_CtcDeriv.py +434 -0
  19. codac4matlab/tests/test_CtcEval.py +214 -0
  20. codac4matlab/tests/test_CtcFixpoint.py +65 -0
  21. codac4matlab/tests/test_CtcInter.py +39 -0
  22. codac4matlab/tests/test_CtcInverse.py +213 -0
  23. codac4matlab/tests/test_CtcInverseNotIn.py +129 -0
  24. codac4matlab/tests/test_CtcLazy.py +50 -0
  25. codac4matlab/tests/test_CtcPolygon.py +91 -0
  26. codac4matlab/tests/test_CtcSegment.py +104 -0
  27. codac4matlab/tests/test_Ellipsoid.py +20 -0
  28. codac4matlab/tests/test_GaussJordan.py +34 -0
  29. codac4matlab/tests/test_IntFullPivLU.py +84 -0
  30. codac4matlab/tests/test_Interval.py +254 -0
  31. codac4matlab/tests/test_IntervalMatrix.py +664 -0
  32. codac4matlab/tests/test_IntervalVector.py +657 -0
  33. codac4matlab/tests/test_Interval_operations.py +293 -0
  34. codac4matlab/tests/test_Matrix.py +81 -0
  35. codac4matlab/tests/test_OctaSym.py +41 -0
  36. codac4matlab/tests/test_Parallelepiped.py +35 -0
  37. codac4matlab/tests/test_Parallelepiped_eval.py +62 -0
  38. codac4matlab/tests/test_Polygon.py +120 -0
  39. codac4matlab/tests/test_SampledTraj.py +135 -0
  40. codac4matlab/tests/test_Segment.py +138 -0
  41. codac4matlab/tests/test_SepCartProd.py +34 -0
  42. codac4matlab/tests/test_SepCtcBoundary.py +52 -0
  43. codac4matlab/tests/test_SepInverse.py +104 -0
  44. codac4matlab/tests/test_SepPolygon.py +102 -0
  45. codac4matlab/tests/test_SepProj.py +39 -0
  46. codac4matlab/tests/test_SepTransform.py +41 -0
  47. codac4matlab/tests/test_Slice.py +78 -0
  48. codac4matlab/tests/test_Slice_polygon.py +208 -0
  49. codac4matlab/tests/test_SlicedTube.py +562 -0
  50. codac4matlab/tests/test_SlicedTube_integral.py +380 -0
  51. codac4matlab/tests/test_TDomain.py +115 -0
  52. codac4matlab/tests/test_Vector.py +41 -0
  53. codac4matlab/tests/test_arithmetic_add.py +54 -0
  54. codac4matlab/tests/test_arithmetic_div.py +46 -0
  55. codac4matlab/tests/test_arithmetic_mul.py +114 -0
  56. codac4matlab/tests/test_arithmetic_sub.py +54 -0
  57. codac4matlab/tests/test_capd.py +19 -0
  58. codac4matlab/tests/test_cart_prod.py +38 -0
  59. codac4matlab/tests/test_eigen.py +19 -0
  60. codac4matlab/tests/test_geometry.py +136 -0
  61. codac4matlab/tests/test_hull.py +35 -0
  62. codac4matlab/tests/test_ibex.py +19 -0
  63. codac4matlab/tests/test_inversion.py +57 -0
  64. codac4matlab/tests/test_linear_ctc.py +77 -0
  65. codac4matlab/tests/test_operators.py +377 -0
  66. codac4matlab/tests/test_peibos.py +83 -0
  67. codac4matlab/tests/test_predefined_tubes.py +193 -0
  68. codac4matlab/tests/test_serialization.py +30 -0
  69. codac4matlab/tests/test_transformations.py +61 -0
  70. codac4matlab/tests/test_trunc.py +95 -0
  71. codac4matlab/unsupported/__init__.py +1 -0
  72. codac4matlab/version.py +1 -0
  73. codac4matlab-2.0.0.dev25.dist-info/METADATA +23 -0
  74. codac4matlab-2.0.0.dev25.dist-info/RECORD +76 -0
  75. codac4matlab-2.0.0.dev25.dist-info/WHEEL +6 -0
  76. codac4matlab-2.0.0.dev25.dist-info/top_level.txt +1 -0
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Simon Rohou
7
+ # \copyright Copyright 2024 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+ import unittest
11
+ from codac import *
12
+
13
+ class TestCtcInter(unittest.TestCase):
14
+
15
+ def test_CtcInter(self):
16
+
17
+ c1 = CtcWrapper([[-10,10],[-2,2]])
18
+ c2 = CtcWrapper([[-12,2],[0,4]])
19
+
20
+ c3 = c1 & c2
21
+
22
+ x = IntervalVector([[-oo,oo],[-oo,oo]])
23
+ c3.contract(x)
24
+ self.assertTrue(x == IntervalVector([[-10,2],[0,2]]))
25
+
26
+ x = IntervalVector([[-oo,0],[-oo,0]])
27
+ c3.contract(x)
28
+ self.assertTrue(x == IntervalVector([[-10,0],[0,0]]))
29
+
30
+ x = IntervalVector([[0,oo],[0,oo]])
31
+ c3.contract(x)
32
+ self.assertTrue(x == IntervalVector([[0,2],[0,2]]))
33
+
34
+ x = IntervalVector([[0,0],[0,0]])
35
+ c3.contract(x)
36
+ self.assertTrue(x == IntervalVector.zero(2))
37
+
38
+ if __name__ == '__main__':
39
+ unittest.main()
@@ -0,0 +1,213 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Simon Rohou
7
+ # \copyright Copyright 2024 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+ import unittest
11
+ from codac import *
12
+
13
+ class TestCtcInverse(unittest.TestCase):
14
+
15
+ # not supported (yet) in Python # Contractors based on functions with two variables
16
+ # not supported (yet) in Python x = ScalarVar()
17
+ # not supported (yet) in Python y = ScalarVar()
18
+ # not supported (yet) in Python f = AnalyticFunction([x,y], x-y)
19
+ # not supported (yet) in Python c = CtcInverse(f, Interval(0.))
20
+
21
+ def test_CtcInverse_1(self):
22
+
23
+ x = VectorVar(1)
24
+ f = AnalyticFunction([x], x[0]-42)
25
+ c = CtcInverse(f, Interval(0.))
26
+ a = IntervalVector(1)
27
+ c.contract(a)
28
+ self.assertTrue(a == IntervalVector([[42]]))
29
+
30
+ x = VectorVar(2)
31
+ f = AnalyticFunction([x], x[0]-x[1])
32
+ c = CtcInverse(f, 0)
33
+ self.assertTrue(c.fnc().input_size() == 2)
34
+
35
+ b = IntervalVector(2)
36
+
37
+ c.contract(b)
38
+ self.assertTrue(b == IntervalVector(2))
39
+
40
+ b = IntervalVector([[1,2],[1,2]])
41
+ c.contract(b)
42
+ self.assertTrue(b == IntervalVector([[1,2],[1,2]]))
43
+
44
+ b = IntervalVector([[1,oo],[1,oo]])
45
+ c.contract(b)
46
+ self.assertTrue(b == IntervalVector([[1,oo],[1,oo]]))
47
+
48
+ b = IntervalVector([[10],[10]])
49
+ c.contract(b)
50
+ self.assertTrue(b == IntervalVector([[10],[10]]))
51
+
52
+ b = IntervalVector([[1,5],[8,9]])
53
+ c.contract(b)
54
+ self.assertTrue(b == IntervalVector.empty(2))
55
+
56
+ def test_CtcInverse_2(self):
57
+
58
+ x = VectorVar(2)
59
+ f = AnalyticFunction([x], vec(x[0]-x[1]))
60
+ c = CtcInverse(f, [[0]])
61
+
62
+ b = IntervalVector(2)
63
+
64
+ c.contract(b)
65
+ self.assertTrue(b == IntervalVector(2))
66
+
67
+ b = IntervalVector([[1,2],[1,2]])
68
+ c.contract(b)
69
+ self.assertTrue(b == IntervalVector([[1,2],[1,2]]))
70
+
71
+ b = IntervalVector([[1,oo],[1,oo]])
72
+ c.contract(b)
73
+ self.assertTrue(b == IntervalVector([[1,oo],[1,oo]]))
74
+
75
+ b = IntervalVector([[10],[10]])
76
+ c.contract(b)
77
+ self.assertTrue(b == IntervalVector([[10],[10]]))
78
+
79
+ b = IntervalVector([[1,5],[8,9]])
80
+ c.contract(b)
81
+ self.assertTrue(b == IntervalVector.empty(2))
82
+
83
+ def test_CtcInverse_3(self):
84
+
85
+ x = VectorVar(2)
86
+ f = AnalyticFunction([x], vec(x[0],sqr(x[0]/7.)+sqr(x[1]/3.)))
87
+ c = CtcInverse(f, [[0,oo],[1]])
88
+
89
+ b = IntervalVector([[0,0.8],[-2.28,-1.56]])
90
+ c.contract(b)
91
+ self.assertTrue(b == IntervalVector.empty(2))
92
+
93
+ b = IntervalVector([[4,5.4],[-0.05,2.45]])
94
+ c.contract(b)
95
+ self.assertTrue(Approx(b,1e-2) == IntervalVector([[4.0397,5.40],[1.9089,2.45]]))
96
+
97
+ b = IntervalVector([[6.25,6.7],[0.9,1.85]])
98
+ c.contract(b)
99
+ self.assertTrue(Approx(b,1e-2) == IntervalVector([[6.25,6.67],[0.9,1.351]]))
100
+
101
+ b = IntervalVector([[-6,-5],[0,2]])
102
+ c.contract(b)
103
+ self.assertTrue(b == IntervalVector.empty(2))
104
+
105
+ b = IntervalVector([[2,3],[-1,1]])
106
+ c.contract(b)
107
+ self.assertTrue(b == IntervalVector.empty(2))
108
+
109
+ def test_CtcInverse_4(self):
110
+
111
+ x = VectorVar(2)
112
+ f = AnalyticFunction([x], vec(x[0],sqr(x[0]/7.)+sqr(x[1]/3.)))
113
+ c = CtcInverse(f, CtcWrapper([[0,oo],[1]]))
114
+
115
+ b = IntervalVector([[0,0.8],[-2.28,-1.56]])
116
+ c.contract(b)
117
+ self.assertTrue(b == IntervalVector.empty(2))
118
+
119
+ b = IntervalVector([[4,5.4],[-0.05,2.45]])
120
+ c.contract(b)
121
+ self.assertTrue(Approx(b,1e-2) == IntervalVector([[4.0397,5.40],[1.9089,2.45]]))
122
+
123
+ b = IntervalVector([[6.25,6.7],[0.9,1.85]])
124
+ c.contract(b)
125
+ self.assertTrue(Approx(b,1e-2) == IntervalVector([[6.25,6.67],[0.9,1.351]]))
126
+
127
+ b = IntervalVector([[-6,-5],[0,2]])
128
+ c.contract(b)
129
+ self.assertTrue(b == IntervalVector.empty(2))
130
+
131
+ b = IntervalVector([[2,3],[-1,1]])
132
+ c.contract(b)
133
+ self.assertTrue(b == IntervalVector.empty(2))
134
+
135
+ def test_ParabolasExample(self):
136
+
137
+ u = ScalarVar()
138
+ v = ScalarVar()
139
+ a = VectorVar(4)
140
+ a0 = VectorVar(3); a1 = VectorVar(3); a2 = VectorVar(3)
141
+ b0 = VectorVar(3); b1 = VectorVar(3); b2 = VectorVar(3)
142
+
143
+ b = AnalyticFunction([u,a0,a1,a2], sqr(1-u)*a0+2*u*(1-u)*a1+sqr(u)*a2)
144
+ f = AnalyticFunction([u,v,a0,a1,a2,b0,b1,b2], (1-v)*b(u,a0,a1,a2)+v*b(u,b0,b1,b2))
145
+
146
+ h = AnalyticFunction([a],
147
+ f(a[0],a[1],
148
+ IntervalVector([[0],[0],[0]]),IntervalVector([[1],[0],[1]]),IntervalVector([[2],[0],[0]]),
149
+ IntervalVector([[0],[2],[0]]),IntervalVector([[1],[2],[1]]),IntervalVector([[2],[2],[0]]))
150
+ -f(a[2],a[3],
151
+ IntervalVector([[0],[0],[0.55]]),IntervalVector([[0],[1],[-0.45]]),IntervalVector([[0],[2],[0.55]]),
152
+ IntervalVector([[2],[0],[0.55]]),IntervalVector([[2],[1],[-0.45]]),IntervalVector([[2],[2],[0.55]]))
153
+ )
154
+
155
+ ctc = CtcInverse(h, [0,0,0])
156
+ x0 = [[0,1],[0,1],[0.05,0.18],[0.05,0.18]]
157
+ #DefaultFigure.pave(x0, ctc, 0.001)
158
+ p = pave(x0, ctc, 0.01)
159
+ cs = p.connected_subsets()
160
+ self.assertTrue(len(cs) == 1)
161
+ hull = IntervalVector([[0.149199,0.182388],[0.148306,0.1826],[0.148054,0.18],[0.148732,0.18]])
162
+ hull.inflate(1e-4)
163
+ self.assertTrue(hull.is_superset(cs[0].box()))
164
+
165
+ def test_automatic_deduction_issue245(self):
166
+
167
+ s = VectorVar(2)
168
+ f = AnalyticFunction([s],[sqr(s[0])+sqr(s[1])-1.0])
169
+
170
+ # Compilation checks:
171
+
172
+ s1 = SepInverse(f,IntervalVector([0.0])*0.)
173
+ s2 = SepInverse(f,IntervalVector([0.0]))
174
+ s3 = SepInverse(f,Vector([0.0]))
175
+ s4 = SepInverse(f,[[0.0,0.0]])
176
+ s5 = SepInverse(f,[0.0])
177
+ s6 = SepInverse(f,[0])
178
+
179
+ c1 = CtcInverse(f,IntervalVector([0.0])*0.)
180
+ c2 = CtcInverse(f,IntervalVector([0.0]))
181
+ c3 = CtcInverse(f,Vector([0.0]))
182
+ c4 = CtcInverse(f,[[0.0,0.0]])
183
+ c5 = CtcInverse(f,[0.0])
184
+ c6 = CtcInverse(f,[0])
185
+
186
+ inner,outer = s1.separate(IntervalVector(2))
187
+ self.assertTrue(outer == IntervalVector([[-1,1],[-1,1]]))
188
+ inner,outer = s2.separate(IntervalVector(2))
189
+ self.assertTrue(outer == IntervalVector([[-1,1],[-1,1]]))
190
+ inner,outer = s3.separate(IntervalVector(2))
191
+ self.assertTrue(outer == IntervalVector([[-1,1],[-1,1]]))
192
+ inner,outer = s4.separate(IntervalVector(2))
193
+ self.assertTrue(outer == IntervalVector([[-1,1],[-1,1]]))
194
+ inner,outer = s5.separate(IntervalVector(2))
195
+ self.assertTrue(outer == IntervalVector([[-1,1],[-1,1]]))
196
+ inner,outer = s6.separate(IntervalVector(2))
197
+ self.assertTrue(outer == IntervalVector([[-1,1],[-1,1]]))
198
+
199
+ x = IntervalVector(2); c1.contract(x)
200
+ self.assertTrue(x == IntervalVector([[-1,1],[-1,1]]))
201
+ x = IntervalVector(2); c2.contract(x)
202
+ self.assertTrue(x == IntervalVector([[-1,1],[-1,1]]))
203
+ x = IntervalVector(2); c3.contract(x)
204
+ self.assertTrue(x == IntervalVector([[-1,1],[-1,1]]))
205
+ x = IntervalVector(2); c4.contract(x)
206
+ self.assertTrue(x == IntervalVector([[-1,1],[-1,1]]))
207
+ x = IntervalVector(2); c5.contract(x)
208
+ self.assertTrue(x == IntervalVector([[-1,1],[-1,1]]))
209
+ x = IntervalVector(2); c6.contract(x)
210
+ self.assertTrue(x == IntervalVector([[-1,1],[-1,1]]))
211
+
212
+ if __name__ == '__main__':
213
+ unittest.main()
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Simon Rohou
7
+ # \copyright Copyright 2024 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+ import unittest
11
+ from codac import *
12
+
13
+ class TestCtcInverseNotIn(unittest.TestCase):
14
+
15
+ # Multivariable functions not supported (yet) for CtcInverseNotInNotIn: ScalarVar x,y
16
+ # Multivariable functions not supported (yet) for CtcInverseNotInNotIn: AnalyticFunction f { {x,y}, x-y }
17
+ # Multivariable functions not supported (yet) for CtcInverseNotInNotIn: CtcInverseNotInNotIn<Interval> c(f, Interval(0.))
18
+
19
+ def test_CtcInverseNotIn_2(self):
20
+
21
+ # Test not really relevant, but copied from CtcInverse:
22
+
23
+ x = VectorVar(2)
24
+ f = AnalyticFunction([x], vec(x[0]-x[1]))
25
+ c = CtcInverseNotIn(f, [[0]])
26
+
27
+ #pave(IntervalVector([[-10,10],[-10,10]]), c, 0.1)
28
+
29
+ b = IntervalVector(2)
30
+
31
+ c.contract(b)
32
+ self.assertTrue(b == IntervalVector(2))
33
+
34
+ b = IntervalVector([[1,2],[1,2]])
35
+ c.contract(b)
36
+ self.assertTrue(b == IntervalVector([[1,2],[1,2]]))
37
+
38
+ b = IntervalVector([[1,oo],[1,oo]])
39
+ c.contract(b)
40
+ self.assertTrue(b == IntervalVector([[1,oo],[1,oo]]))
41
+
42
+ b = IntervalVector([[10],[10]])
43
+ c.contract(b)
44
+ self.assertTrue(b == IntervalVector([[10],[10]]))
45
+
46
+ b = IntervalVector([[1,5],[8,9]])
47
+ c.contract(b)
48
+ self.assertTrue(b == IntervalVector([[1,5],[8,9]]))
49
+
50
+ def test_CtcInverseNotIn_3(self):
51
+
52
+ x = VectorVar(2)
53
+ f = AnalyticFunction([x], vec(x[0],sqr(x[0]/7.)+sqr(x[1]/3.)))
54
+ c = CtcInverseNotIn(f, [[0,oo],[1]])
55
+
56
+ b = IntervalVector([[0,0.8],[-2.28,-1.56]])
57
+ c.contract(b)
58
+ self.assertTrue(b == IntervalVector([[0,0.8],[-2.28,-1.56]]))
59
+
60
+ b = IntervalVector([[4,5.4],[-0.05,2.45]])
61
+ c.contract(b)
62
+ self.assertTrue(Approx(b,1e-2) == IntervalVector([[4,5.4],[-0.05,2.45]]))
63
+
64
+ b = IntervalVector([[6.25,6.7],[0.9,1.85]])
65
+ c.contract(b)
66
+ self.assertTrue(Approx(b,1e-2) == IntervalVector([[6.25,6.70],[0.9,1.85]]))
67
+
68
+ b = IntervalVector([[-6,-5],[0,2]])
69
+ c.contract(b)
70
+ self.assertTrue(b == IntervalVector([[-6,-5],[0,2]]))
71
+
72
+ b = IntervalVector([[2,3],[-1,1]])
73
+ c.contract(b)
74
+ self.assertTrue(b == IntervalVector([[2,3],[-1,1]]))
75
+
76
+ # disabled: def tests_CtcInverseNotIn_3_CtcWrapper(self):
77
+ # disabled:
78
+ # disabled: x = VectorVar(2)
79
+ # disabled: f = AnalyticFunction([x], vec(x[0],sqr(x[0]/7.)+sqr(x[1]/3.)))
80
+ # disabled: c = CtcInverseNotIn(f, CtcWrapper([[0,oo],[1]]))
81
+ # disabled:
82
+ # disabled: b = IntervalVector([[0,0.8],[-2.28,-1.56]])
83
+ # disabled: c.contract(b)
84
+ # disabled: self.assertTrue(b == IntervalVector([[0,0.8],[-2.28,-1.56]]))
85
+ # disabled:
86
+ # disabled: b = IntervalVector([[4,5.4],[-0.05,2.45]])
87
+ # disabled: c.contract(b)
88
+ # disabled: self.assertTrue(Approx(b,1e-2) == IntervalVector([[4,5.4],[-0.05,2.45]]))
89
+ # disabled:
90
+ # disabled: b = IntervalVector([[6.25,6.7],[0.9,1.85]])
91
+ # disabled: c.contract(b)
92
+ # disabled: self.assertTrue(Approx(b,1e-2) == IntervalVector([[6.25,6.70],[0.9,1.85]]))
93
+ # disabled:
94
+ # disabled: b = IntervalVector([[-6,-5],[0,2]])
95
+ # disabled: c.contract(b)
96
+ # disabled: self.assertTrue(b == IntervalVector([[-6,-5],[0,2]]))
97
+ # disabled:
98
+ # disabled: b = IntervalVector([[2,3],[-1,1]])
99
+ # disabled: c.contract(b)
100
+ # disabled: self.assertTrue(b == IntervalVector([[2,3],[-1,1]]))
101
+
102
+ def test_CtcInverseNotIn_4(self):
103
+
104
+ v = VectorVar(1)
105
+ c = CtcInverseNotIn(AnalyticFunction([v], v), [[-1,1]])
106
+ x = IntervalVector(1)
107
+
108
+ c.contract(x)
109
+ self.assertTrue(x == IntervalVector(1))
110
+
111
+ x = IntervalVector([[0,8]])
112
+ c.contract(x)
113
+ self.assertTrue(x == IntervalVector([[1,8]]))
114
+
115
+ def test_CtcInverseNotIn_5(self):
116
+
117
+ v = VectorVar(2)
118
+ c = CtcInverseNotIn(AnalyticFunction([v], v), IntervalVector([[-1,1],[5,6]]))
119
+ x = IntervalVector(2)
120
+
121
+ c.contract(x)
122
+ self.assertTrue(x == IntervalVector(2))
123
+
124
+ x = IntervalVector([[0,8],[5.5,oo]])
125
+ c.contract(x)
126
+ self.assertTrue(x == IntervalVector([[0,8],[5.5,oo]])) # unchanged
127
+
128
+ if __name__ == '__main__':
129
+ unittest.main()
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Simon Rohou
7
+ # \copyright Copyright 2024 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+ import unittest
11
+ from codac import *
12
+
13
+
14
+ class CtcCustom(Ctc_IntervalVector):
15
+
16
+ def __init__(self):
17
+ Ctc_IntervalVector.__init__(self, 2)
18
+
19
+ def contract(self, x):
20
+ if x[0].rad() > 1.:
21
+ return IntervalVector(x.mid()).inflate(0.5*x.rad())
22
+ return x
23
+
24
+
25
+ class TestCtcLazy(unittest.TestCase):
26
+
27
+ def test_CtcLazy(self):
28
+
29
+ ctc_custom = CtcCustom()
30
+ x = IntervalVector([[-1000,1000],[-1000,1000]])
31
+ x = ctc_custom.contract(x)
32
+ self.assertTrue(Approx(x) == IntervalVector([[-500,500],[-500,500]]))
33
+ x = ctc_custom.contract(x)
34
+ self.assertTrue(Approx(x) == IntervalVector([[-250,250],[-250,250]]))
35
+ x = ctc_custom.contract(x)
36
+ self.assertTrue(Approx(x) == IntervalVector([[-125,125],[-125,125]]))
37
+
38
+ ctc_lazy = CtcLazy(ctc_custom)
39
+
40
+ x = IntervalVector([[-1000,1000],[-1000,1000]])
41
+ x = ctc_lazy.contract(x)
42
+ self.assertTrue(x == IntervalVector([[-250,250],[-250,250]]))
43
+
44
+ x = IntervalVector([[-500,500],[-500,500]])
45
+ x = ctc_lazy.contract(x)
46
+ self.assertTrue(x == IntervalVector([[-125,125],[-125,125]]))
47
+
48
+
49
+ if __name__ == '__main__':
50
+ unittest.main()
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Simon Rohou
7
+ # \copyright Copyright 2024 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+ import unittest
11
+ from codac import *
12
+
13
+ class TestCtcPolygon(unittest.TestCase):
14
+
15
+ def test_CtcPolygon(self):
16
+
17
+ # Polygon, defined as a list of vertices
18
+ c = CtcPolygon([[3,-1],[3,4],[5,6],[-1,1]])
19
+
20
+ x = IntervalVector(2)
21
+ c.contract(x)
22
+ self.assertTrue(x == IntervalVector([[-1,5],[-1,6]]))
23
+
24
+ x = IntervalVector([[3.02,3.16],[2.5,3.2]]) # possible bug
25
+ c.contract(x)
26
+ self.assertTrue(x.is_empty())
27
+
28
+ def test_CtcPolygon_fromCodac1(self):
29
+
30
+ # Polygone with hole, defined as a list of edges
31
+
32
+ c = CtcPolygon([
33
+ # external border
34
+ [[6,-6], [7,9]],
35
+ [[7,9], [0,5]],
36
+ [[0,5], [-9,8]],
37
+ [[-9,8], [-8,-9]],
38
+ [[-8,-9], [6,-6]],
39
+ # hole
40
+ [[-2,3], [3.5,2]],
41
+ [[3.5,2], [1.5,0.5]],
42
+ [[1.5,0.5], [3,-4]],
43
+ [[3,-4], [-3,-3]],
44
+ [[-3,-3], [-2,3]]
45
+ ])
46
+
47
+ #DefaultFigure.pave(IntervalVector([[-10,10],[-10,10]]), c, 0.1)
48
+
49
+ # Check a box inside the hole
50
+
51
+ x = IntervalVector([[0],[0]]).inflate(0.5)
52
+ #DefaultFigure.draw_box(x,Color::purple())
53
+ c.contract(x)
54
+ self.assertTrue(x.is_empty())
55
+
56
+ # Check a box inside the polygon
57
+
58
+ x = IntervalVector([[5],[-5]]).inflate(0.5)
59
+ _x = IntervalVector(x)
60
+ #DefaultFigure.draw_box(x,Color::purple())
61
+ c.contract(x)
62
+ self.assertTrue(x == _x)
63
+
64
+ # Check a box outside the polygon
65
+
66
+ x = IntervalVector([[-1],[8]]).inflate(0.5)
67
+ #DefaultFigure.draw_box(x,Color::purple())
68
+ c.contract(x)
69
+ self.assertTrue(x.is_empty())
70
+
71
+
72
+ # Other polygon, defined as a list of vertices
73
+
74
+ c = CtcPolygon([[6,-6],[7,9],[0,5],[-9,8],[-8,-9]])
75
+
76
+ # Check a box inside the polygon
77
+
78
+ x = IntervalVector([[5],[-5]]).inflate(0.5)
79
+ _x = IntervalVector(x)
80
+ c.contract(x)
81
+ self.assertTrue(x == _x)
82
+
83
+ # Check a box outside the polygon
84
+
85
+ x = IntervalVector([[-1],[8]]).inflate(0.5)
86
+ c.contract(x)
87
+ self.assertTrue(x.is_empty())
88
+
89
+
90
+ if __name__ == '__main__':
91
+ unittest.main()
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Simon Rohou
7
+ # \copyright Copyright 2024 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+ import unittest
11
+ from codac import *
12
+
13
+ class TestCtcSegment(unittest.TestCase):
14
+
15
+ def test_CtcSegment(self):
16
+
17
+ x = IntervalVector(2)
18
+ c = CtcSegment([[3],[-1]],[[3],[4]])
19
+
20
+ x = IntervalVector(2)
21
+ c.contract(x)
22
+ self.assertTrue(x == IntervalVector([[3,3],[-1,4]]))
23
+
24
+ x = IntervalVector([[3.0,3.16],[2.5,3.2]])
25
+ c.contract(x)
26
+ self.assertTrue(x == IntervalVector([[3,3],[2.5,3.2]]))
27
+
28
+ x = IntervalVector([[3.02,3.16],[2.5,3.2]])
29
+ c.contract(x)
30
+ self.assertTrue(x.is_empty())
31
+
32
+ x = IntervalVector(2)
33
+ c = CtcSegment([[-1],[-1]],[[1],[1]])
34
+
35
+ x = IntervalVector(2)
36
+ c.contract(x)
37
+ self.assertTrue(x == IntervalVector([[-1,1],[-1,1]]))
38
+
39
+ x = IntervalVector([[-oo,oo],[0]])
40
+ c.contract(x)
41
+ self.assertTrue(x == IntervalVector([[0],[0]]))
42
+
43
+ x = IntervalVector([[0,oo],[0,oo]])
44
+ c.contract(x)
45
+ self.assertTrue(x == IntervalVector([[0,1],[0,1]]))
46
+
47
+ x = IntervalVector([[2,oo],[2,oo]])
48
+ c.contract(x)
49
+ self.assertTrue(x.is_empty())
50
+
51
+ def test_CtcSegment_fromCodac1(self):
52
+
53
+ # Test_CtcSegment01
54
+
55
+ c = CtcSegment([[0],[0]], [[10],[20]])
56
+ x = IntervalVector([[-5,50],[-5, 50]])
57
+ c.contract(x)
58
+ self.assertTrue(x == IntervalVector([[0,10],[0,20]]))
59
+
60
+ # Test_CtcSegment02
61
+
62
+ c = CtcSegment([[0],[0]], [[10],[20]])
63
+ x = IntervalVector([[10,50],[20,50]])
64
+ c.contract(x)
65
+ self.assertTrue(x == IntervalVector([[10,10],[20,20]]))
66
+
67
+ # Test_contract_degenerate
68
+
69
+ c = CtcSegment([[5],[5]], [[5],[5]])
70
+ x = IntervalVector([[-5,50],[-5,50]])
71
+ c.contract(x)
72
+ self.assertTrue(x == IntervalVector([[5,5],[5,5]]))
73
+
74
+ # Test_contract_degenerate_x
75
+
76
+ c = CtcSegment([[5],[5]], [[10],[5]])
77
+ x = IntervalVector([[-50,50],[-50,50]])
78
+ c.contract(x)
79
+ self.assertTrue(x == IntervalVector([[5,10],[5,5]]))
80
+
81
+ # Test_contract_degenerate_y
82
+
83
+ c = CtcSegment([[-5],[-5]], [[-5],[15]])
84
+ x = IntervalVector([Interval(-50, 50), Interval(-50, 50)])
85
+ c.contract(x)
86
+ self.assertTrue(x == IntervalVector([[-5,-5],[-5,15]]))
87
+
88
+ # Test_contract_empty
89
+
90
+ c = CtcSegment([[0],[0]], [[10],[20]])
91
+ x = IntervalVector([[-5,-2],[-5,50]])
92
+ c.contract(x)
93
+ self.assertTrue(x.is_empty())
94
+
95
+ # Test_call_with_empty_x
96
+
97
+ c = CtcSegment([[0],[0]], [[10],[20]])
98
+ x = IntervalVector(2)
99
+ c.contract(x)
100
+ self.assertTrue(x == IntervalVector([[0,10],[0,20]]))
101
+
102
+
103
+ if __name__ == '__main__':
104
+ unittest.main()
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Morgan Louedec, (Simon Rohou)
7
+ # \copyright Copyright 2024 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+ import unittest
11
+ from codac import *
12
+
13
+ class TestEllipsoid(unittest.TestCase):
14
+
15
+ def test_Ellipsoid(self):
16
+
17
+ self.assertTrue(True)
18
+
19
+ if __name__ == '__main__':
20
+ unittest.main()
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2025
6
+ # \author Damien Massé
7
+ # \copyright Copyright 2025 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+ import unittest
11
+ from codac import *
12
+
13
+ class TestGaussJordan(unittest.TestCase):
14
+
15
+ def test_GaussJordan(self):
16
+
17
+ M = Matrix([
18
+ [ 1, -4, 6, 7, 6 ],
19
+ [ 2, 1, 3, 6, -2 ],
20
+ [ 5, 2, 2, 9, -1 ] ])
21
+ pre = gauss_jordan(M)
22
+ # check that pre*M is "band matrix" */
23
+ P = pre*M
24
+ mx = 0.0
25
+ for i in range(1,M.rows()-1):
26
+ for j in range(0,i-1):
27
+ mx = max(mx,abs(P(i,j)))
28
+ mx = max(mx,abs(P(M.rows()-1-i,M.cols()-1-j)))
29
+ self.assertTrue(mx<1e-10)
30
+
31
+
32
+ if __name__ == '__main__':
33
+ unittest.main()
34
+