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,77 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Simon Rohou, Maël Godard
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 TestColor(unittest.TestCase):
15
+
16
+ def test_Color(self):
17
+
18
+ # Red
19
+
20
+ d_rgb = [255, 0, 0]
21
+ d_rgba = [255, 0, 0, 255]
22
+ d_hsv = [0, 100, 100]
23
+ d_hsva = [0, 100, 100, 100]
24
+
25
+ colors = [
26
+ Color(d_rgb, Model.RGB),
27
+ Color(d_rgba, Model.RGB),
28
+ Color(d_hsv, Model.HSV),
29
+ Color(d_hsva, Model.HSV),
30
+ Color("#FF0000")
31
+ ]
32
+
33
+ for c in colors:
34
+ self.assertTrue(Approx(c.rgb().vec(), 1.0)==Color([255, 0, 0]).rgb().vec())
35
+ self.assertTrue(Approx(c.rgb().vec(), 1.0)==Color([255, 0, 0, 255]).rgb().vec())
36
+ self.assertTrue(Approx(c.hsv().vec(), 1.0)==Color([0, 100, 100],Model.HSV).hsv().vec())
37
+ self.assertTrue(Approx(c.hsv().vec(), 1.0)==Color([0, 100, 100, 100],Model.HSV).hsv().vec())
38
+
39
+ # Pink full opacity
40
+
41
+ d_rgb = [229,128,255]
42
+ d_rgba = [229,128,255,255]
43
+ d_hsv = [288,50,100]
44
+ d_hsva = [288,50,100,100]
45
+
46
+ colors = [
47
+ Color(d_rgb, Model.RGB),
48
+ Color(d_rgba, Model.RGB),
49
+ Color(d_hsv, Model.HSV),
50
+ Color(d_hsva, Model.HSV),
51
+ Color("#E580FF")
52
+ ]
53
+
54
+ for c in colors:
55
+ self.assertTrue(Approx(c.rgb().vec(), 1.0)==Color([229,128,255]).rgb().vec())
56
+ self.assertTrue(Approx(c.rgb().vec(), 1.0)==Color([229,128,255,255]).rgb().vec())
57
+ self.assertTrue(Approx(c.hsv().vec(), 1.0)==Color([288,50,100],Model.HSV).hsv().vec())
58
+ self.assertTrue(Approx(c.hsv().vec(), 1.0)==Color([288,50,100,100],Model.HSV).hsv().vec())
59
+
60
+ # Pink 40% opacity
61
+
62
+ a_rgb=102
63
+ a_hsv=40
64
+ d_rgba = [229,128,255,a_rgb]
65
+ d_hsva = [288,50,100,a_hsv]
66
+
67
+ colors = [
68
+ Color(d_rgba, Model.RGB),
69
+ Color(d_hsva, Model.HSV),
70
+ Color("#E580FF66")
71
+ ]
72
+ for c in colors:
73
+ self.assertTrue(Approx(c.rgb().vec(), 1.0)==Color([229,128,255,a_rgb]).rgb().vec())
74
+ self.assertTrue(Approx(c.hsv().vec(), 1.0)==Color([288,50,100,a_hsv],Model.HSV).hsv().vec())
75
+
76
+ if __name__ == '__main__':
77
+ unittest.main()
@@ -0,0 +1,300 @@
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 TestConvexPolygon(unittest.TestCase):
14
+
15
+ def test_ConvexPolygon_degenerate_base(self):
16
+
17
+ p = ConvexPolygon([[1,2],[1,2]])
18
+ self.assertTrue(len(p.vertices()) == 1)
19
+
20
+ p = ConvexPolygon([[1,3],[1,2],[1,2]])
21
+ self.assertTrue(len(p.vertices()) == 2)
22
+
23
+ p = ConvexPolygon([[1,2],[1,3],[1,2],[1,2]])
24
+ self.assertTrue(len(p.vertices()) == 2)
25
+
26
+ p = ConvexPolygon([[1,2],[1,3],[1,3],[1,2],[1,2]])
27
+ self.assertTrue(len(p.vertices()) == 2)
28
+
29
+ self.assertTrue(len(convex_hull([[1,2],[1,2],[1,2]])) == 1)
30
+ p = ConvexPolygon([[1,2],[1,2],[1,2]])
31
+ self.assertTrue(len(p.vertices()) == 1)
32
+
33
+ p = ConvexPolygon([[1,2],[1,3]])
34
+ self.assertTrue(len(p.vertices()) == 2)
35
+
36
+ p = ConvexPolygon([[1,2],[1,3],[1,2]])
37
+ self.assertTrue(len(p.vertices()) == 2)
38
+
39
+ p = ConvexPolygon([[1,2],[1,3],[1,2],[1,2]])
40
+ self.assertTrue(len(p.vertices()) == 2)
41
+
42
+ p = ConvexPolygon([[1,2],[1,3],[1,3],[1,2]])
43
+ self.assertTrue(len(p.vertices()) == 2)
44
+
45
+ def test_ConvexPolygon_degenerate_cases(self):
46
+
47
+ p1 = ConvexPolygon([[0,4]])
48
+ self.assertTrue(len(p1.edges()) == 1)
49
+ self.assertTrue(p1.edges()[0][0] == IntervalVector([0,4]))
50
+ self.assertTrue(p1.edges()[0][1] == IntervalVector([0,4]))
51
+
52
+ p1 = ConvexPolygon([[0,4],[2,8]])
53
+ self.assertTrue(len(p1.edges()) == 1)
54
+ self.assertTrue(p1.edges()[0][0] == IntervalVector([0,4]))
55
+ self.assertTrue(p1.edges()[0][1] == IntervalVector([2,8]))
56
+ self.assertTrue(p1 == ConvexPolygon([[2,8],[0,4]]))
57
+
58
+ def test_ConvexPolygon_intersection(self):
59
+
60
+ p1 = ConvexPolygon([[0,4],[4,8],[7,0]])
61
+ p2 = ConvexPolygon([[-1,2],[-1,3],[5,3],[5,2]])
62
+ self.assertTrue((p1 & p2) == ConvexPolygon([
63
+ [3.5,2],[5,2],[5,3],[1.75,3]
64
+ ]))
65
+
66
+ p1 = ConvexPolygon([[3,2],[1,6],[6,5]])
67
+ p2 = ConvexPolygon(IntervalVector([[0,4],[0,4]]))
68
+ self.assertTrue((p1 & p2) == ConvexPolygon([
69
+ [3,2],[2,4],[4,4],[4,3]
70
+ ]))
71
+
72
+ p1 = ConvexPolygon([[1,2],[3,4],[5,1],[2,1]])
73
+ p2 = ConvexPolygon(IntervalVector([[2,6],[2,6]]))
74
+ self.assertTrue(Approx(p1 & p2) == ConvexPolygon([
75
+ [2,2],[2,3],[3,4],[4.+1./3.,2.]
76
+ ]))
77
+
78
+ # Big box
79
+ p1 = ConvexPolygon([[1,2],[3,4],[5,1],[2,1]])
80
+ p2 = ConvexPolygon(IntervalVector([[-10,10],[-10,10]]))
81
+ self.assertTrue((p1 & p2) == p1) # same polygon
82
+
83
+ # Inner box
84
+ p1 = ConvexPolygon([[1,2],[3,4],[5,1],[2,1]])
85
+ p2 = ConvexPolygon(IntervalVector([[2.8,3],[2.8,3]]))
86
+ self.assertTrue((p1 & p2) == p2) # same box
87
+
88
+ p1 = ConvexPolygon([[2,1],[3,1],[4,2],[4,3],[3,4],[2,4],[1,3],[1,2]])
89
+ p2 = ConvexPolygon(IntervalVector([[1,4],[1,4]]))
90
+ self.assertTrue((p1 & p2) == p1) # same polygon
91
+
92
+ # Shifted polygon points declaration
93
+ p1 = ConvexPolygon([[3,4],[2,4],[1,3],[1,2],[2,1],[3,1],[4,2],[4,3]])
94
+ p2 = ConvexPolygon(IntervalVector([[1,4],[1,4]]))
95
+ self.assertTrue((p1 & p2) == p1) # same polygon
96
+
97
+ # Degenerate case
98
+ p1 = ConvexPolygon([[4000,200]])
99
+ p2 = ConvexPolygon(IntervalVector([4000,200]))
100
+ self.assertTrue(p1.box() == IntervalVector([4000,200]))
101
+ self.assertTrue(p2.box() == IntervalVector([4000,200]))
102
+ self.assertTrue((p1 & p2) == p1) # same polygon
103
+
104
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
105
+ p2 = ConvexPolygon(IntervalVector([[2,6],[1,5]]))
106
+ q = p1 & p2
107
+ self.assertTrue(Approx(q) == Polygon([[2,1.2],[6,2],[6,4.8],[2,4]]))
108
+ self.assertTrue(len(q.edges()) == 4)
109
+ self.assertTrue(len(q.vertices()) == 4)
110
+
111
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
112
+ p2 = ConvexPolygon(IntervalVector([[3,5],[1,5]]))
113
+ q = p1 & p2
114
+ self.assertTrue(Approx(q) == Polygon([[3,1.4],[5,1.8],[5,4.6],[3,4.2]]))
115
+ self.assertTrue(len(q.edges()) == 4)
116
+ self.assertTrue(len(q.vertices()) == 4)
117
+
118
+ # Degenerated box
119
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
120
+ p2 = ConvexPolygon(IntervalVector([[4],[1,5]]))
121
+
122
+ self.assertTrue(p1.edges()[0] == Segment([[1,1],[6,2]]))
123
+ self.assertTrue(p1.edges()[1] == Segment([[6,2],[7,5]]))
124
+ self.assertTrue(p1.edges()[2] == Segment([[7,5],[2,4]]))
125
+ self.assertTrue(p1.edges()[3] == Segment([[2,4],[1,1]]))
126
+ self.assertTrue(len(p1.edges()) == 4)
127
+
128
+ self.assertTrue(p2.edges()[0] == Segment([[4,1],[4,5]]))
129
+ self.assertTrue(len(p2.edges()) == 1)
130
+
131
+ self.assertTrue((p1.edges()[1] & p2.edges()[0]) == IntervalVector.empty(2))
132
+ self.assertTrue(Approx(p1.edges()[0] & p2.edges()[0]) == IntervalVector([4,1.6]))
133
+ self.assertTrue((p1.edges()[3] & p2.edges()[0]) == IntervalVector.empty(2))
134
+ self.assertTrue(Approx(p1.edges()[2] & p2.edges()[0]) == IntervalVector([4,4.4]))
135
+
136
+ q = p1 & p2
137
+ self.assertTrue(Approx(q) == Polygon([[4,4.4],[4,1.6]]))
138
+ self.assertTrue(len(q.vertices()) == 2)
139
+
140
+ # Degenerated polygon
141
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
142
+ p2 = ConvexPolygon([[4,1],[4,5]])
143
+ q = p1 & p2
144
+ self.assertTrue(Approx(q) == Polygon([[4,4.4],[4,1.6]]))
145
+ self.assertTrue(len(q.vertices()) == 2)
146
+
147
+ # Point intersection
148
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
149
+ p2 = ConvexPolygon([[2,4],[-4,4],[0,8]])
150
+ q = p1 & p2
151
+ self.assertTrue(q == Polygon([[2,4]]))
152
+ self.assertTrue(len(q.vertices()) == 1)
153
+
154
+ # Point intersection, line polygon
155
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
156
+ p2 = ConvexPolygon([[2,4],[-4,4]])
157
+ q = p1 & p2
158
+ self.assertTrue(q == Polygon([[2,4]]))
159
+ self.assertTrue(len(q.vertices()) == 1)
160
+
161
+ # Empty intersection
162
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
163
+ p2 = ConvexPolygon([[5,1.5],[8,2],[8,0],[5,0]])
164
+ q = p1 & p2
165
+ self.assertTrue(q == Polygon.empty())
166
+ self.assertTrue(len(q.vertices()) == 0)
167
+ self.assertTrue(q.is_empty())
168
+
169
+ # Empty intersection, degenerate case
170
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
171
+ p2 = ConvexPolygon([[5,1.5],[80,2]])
172
+ q = p1 & p2
173
+ self.assertTrue(q == Polygon.empty())
174
+ self.assertTrue(len(q.vertices()) == 0)
175
+ self.assertTrue(q.is_empty())
176
+
177
+ # Intersection of empty polygons
178
+ p1 = ConvexPolygon.empty()
179
+ p2 = ConvexPolygon.empty()
180
+ q = p1 & p2
181
+ self.assertTrue(q == Polygon.empty())
182
+ self.assertTrue(q.is_empty())
183
+
184
+ # Intersection of a polygon and one empty polygon
185
+ p1 = ConvexPolygon([[1,1],[2,4],[7,5],[6,2]])
186
+ p2 = ConvexPolygon.empty()
187
+ q = p1 & p2
188
+ self.assertTrue(q == Polygon.empty())
189
+ self.assertTrue(q.is_empty())
190
+
191
+ # Intersection of a polygon and one empty polygon (line)
192
+ p1 = ConvexPolygon([[5,1.5],[80,2]])
193
+ p2 = ConvexPolygon.empty()
194
+ q = p1 & p2
195
+ self.assertTrue(q == Polygon.empty())
196
+ self.assertTrue(q.is_empty())
197
+
198
+ # Other test with inflated points
199
+ p1 = ConvexPolygon(IntervalVector([[-4,4],[-3,3]]))
200
+ a1,a2 = IntervalVector([-4,-6]), IntervalVector([-4,6])
201
+ a1.inflate(1e-10)
202
+ a2.inflate(1e-10)
203
+ p2 = ConvexPolygon([Segment(a1,a2)])
204
+ q = p1 & p2
205
+ self.assertTrue(len(q.edges()) == 1)
206
+ self.assertTrue(Approx(q.edges()[0][0],1e-5) == IntervalVector([-4,-3]))
207
+ self.assertTrue(Approx(q.edges()[0][1],1e-5) == IntervalVector([-4,3]))
208
+
209
+ # Parallel edges
210
+ p1 = ConvexPolygon([
211
+ [-1,-10],
212
+ [3,-10],
213
+ [3,1],
214
+ [-1,6],
215
+ ])
216
+ p2 = ConvexPolygon([
217
+ [-1,10],
218
+ [-1,-1],
219
+ [3,-6],
220
+ [3,10],
221
+ ])
222
+ q = p1 & p2
223
+ self.assertTrue(q == ConvexPolygon([
224
+ [3,-6],
225
+ [3,1],
226
+ [-1,6],
227
+ [-1,-1],
228
+ ]))
229
+
230
+ # Parallel edges towards infinity
231
+ p1 = ConvexPolygon([
232
+ [-1,next_float(-oo)],
233
+ [3,next_float(-oo)],
234
+ [3,1],
235
+ [-1,6],
236
+ ])
237
+ p2 = ConvexPolygon([
238
+ [-1,prev_float(oo)],
239
+ [-1,-1],
240
+ [3,-6],
241
+ [3,prev_float(oo)],
242
+ ])
243
+ q = p1 & p2
244
+ self.assertTrue(q == ConvexPolygon([
245
+ [3,-6],
246
+ [3,1],
247
+ [-1,6],
248
+ [-1,-1],
249
+ ]))
250
+
251
+ p1 = ConvexPolygon([[4,3.5],[5,4],[4,4.5]])
252
+ p2 = ConvexPolygon([[4,3.5],[5,3.5],[5,4.25],[4.5,4.25],[4,4]])
253
+ self.assertTrue(Approx(p1 & p2) == ConvexPolygon([[4,4],[4,3.5],[5,4],[4.5,4.25]]))
254
+
255
+ p1 = ConvexPolygon([[4,4],[4,3.5],[5,4],[4.5,4.25]])
256
+ p2 = ConvexPolygon(IntervalVector([[4,5],[4.1]]))
257
+ self.assertTrue(Approx(p1 & p2, 1e-10) == ConvexPolygon(IntervalVector([[4.2,4.8],[4.1]])))
258
+
259
+ p1 = ConvexPolygon([[4,4],[4,3.5],[5,4],[4.5,4.25]])
260
+ p2 = ConvexPolygon(IntervalVector([[4,5],Interval(41)/10]))
261
+ self.assertTrue(Approx(p1 & p2, 1e-10) == ConvexPolygon(IntervalVector([[4.2,4.8],Interval(41)/10])))
262
+
263
+ p1 = ConvexPolygon([
264
+ IntervalVector([[0.0999999, 0.100001],[0.989016, 0.989017]]),
265
+ IntervalVector([[0.0999999, 0.100001],[1.0015, 1.00151]]),
266
+ IntervalVector([[0, 0],[0.999999, 1]]),
267
+ IntervalVector([[0, 0],[1, 1.00001]])
268
+ ])
269
+
270
+ p2 = ConvexPolygon([
271
+ IntervalVector([[0, 0],[0.987514, 0.987515]]),
272
+ IntervalVector([[0.1, 0.100001],[0.989016, 0.989017]]),
273
+ IntervalVector([[0.1, 0.100001],[1.0015, 1.00151]]),
274
+ IntervalVector([[0, 0],[1.01248, 1.01249]]),
275
+ ])
276
+
277
+ self.assertTrue(Approx(p1 & p2, 1e-5) == ConvexPolygon([
278
+ [[0.0997289, 0.100002],[0.989016, 0.989938]],
279
+ [[0.0995829, 0.100002],[1.00059, 1.00151]],
280
+ [[0, 0],[0.999547, 1.00047]]
281
+ ]))
282
+
283
+ p1 &= p2
284
+
285
+ m = IntervalVector([6.5,1])
286
+ p1 = ConvexPolygon(m)
287
+ p2 = ConvexPolygon([
288
+ [[6.49999, 6.50001],[0.759358, 0.759359]],
289
+ [[6.49999, 6.50001],[1.19382, 1.19383]],
290
+ [[6.4, 6.40001],[1.20537, 1.20538]],
291
+ [[6.4, 6.40001],[0.78097, 0.780971]],
292
+ ])
293
+
294
+ s = Segment(IntervalVector([[6.49999, 6.50001],[0.759358, 0.759359]]), IntervalVector([[6.49999, 6.50001],[1.19382, 1.19383]]))
295
+ self.assertTrue(s.contains(m) == BoolInterval.UNKNOWN)
296
+ self.assertTrue((p1 & p2) == ConvexPolygon([m]))
297
+
298
+
299
+ if __name__ == '__main__':
300
+ unittest.main()
@@ -0,0 +1,30 @@
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 TestCtcAction(unittest.TestCase):
14
+
15
+ def test_CtcAction(self):
16
+
17
+ x = VectorVar(2)
18
+ c1 = CtcInverse(AnalyticFunction([x], x-IntervalVector([[1,5],[8,6]])), IntervalVector([[0],[0]]))
19
+
20
+ b = IntervalVector(2)
21
+ c1.contract(b)
22
+ self.assertTrue(b == IntervalVector([[1,5],[8,6]]))
23
+
24
+ c2 = CtcAction(c1, [2,-1])
25
+ b = IntervalVector(2)
26
+ c2.contract(b)
27
+ self.assertTrue(b == IntervalVector([[8,6],[-5,1]]))
28
+
29
+ if __name__ == '__main__':
30
+ unittest.main()
@@ -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 TestCtcCartProd(unittest.TestCase):
14
+
15
+ def test_CtcCartProd(self):
16
+
17
+ v = VectorVar(1)
18
+ c1 = CtcInverse(AnalyticFunction([v], v), IntervalVector([[-1,1]]))
19
+ c2 = CtcInverse(AnalyticFunction([v], v), IntervalVector([[5,6]]))
20
+
21
+ a = IntervalVector(1)
22
+ b = IntervalVector(1)
23
+ c1.contract(a)
24
+ self.assertTrue(a == IntervalVector([[-1,1]]))
25
+ c2.contract(b)
26
+ self.assertTrue(b == IntervalVector([[5,6]]))
27
+
28
+ x = IntervalVector(2)
29
+ c3 = CtcCartProd(c1,c2)
30
+ c3.contract(x)
31
+ self.assertTrue(x == IntervalVector([[-1,1],[5,6]]))
32
+
33
+ y = IntervalVector(2)
34
+ c4 = cart_prod(c1,c2)
35
+ c4.contract(y)
36
+ self.assertTrue(y == IntervalVector([[-1,1],[5,6]]))
37
+
38
+ if __name__ == '__main__':
39
+ unittest.main()
@@ -0,0 +1,48 @@
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
+ def test_inside_diamond(x):
14
+ if (x[1] < x[0]+1) and (x[1] > x[0]-1) and (x[1] < -x[0]+1) and (x[1] > -x[0]-1):
15
+ return BoolInterval.TRUE
16
+ elif not(x[1] < x[0]+1) or not(x[1] > x[0]-1) or not(x[1] < -x[0]+1) or not(x[1] > -x[0]-1):
17
+ return BoolInterval.FALSE
18
+ else:
19
+ return BoolInterval.UNKNOWN
20
+
21
+ class TestCtcCtcBoundary(unittest.TestCase):
22
+
23
+ def test_CtcCtcBoundary(self):
24
+
25
+ ctc_bound_diamond = CtcSegment([[-1],[0]], [[0],[-1]]) | CtcSegment([[0],[-1]], [[1],[0]]) \
26
+ | CtcSegment([[1],[0]], [[0],[1]]) | CtcSegment([[0],[1]], [[-1],[0]])
27
+
28
+ ctc_diamond = CtcCtcBoundary(ctc_bound_diamond,test_inside_diamond)
29
+ #DefaultFigure.pave(IntervalVector([[-2,2],[-2,2]]), ctc_diamond, 0.1)
30
+
31
+ x = IntervalVector(2)
32
+ ctc_diamond.contract(x)
33
+ #self.assertTrue(x == IntervalVector([[-1,1],[-1,1]]))
34
+
35
+ x = IntervalVector([[0,10],[0,10]])
36
+ ctc_diamond.contract(x)
37
+ #self.assertTrue(x == IntervalVector([[0,1],[0,1]]))
38
+
39
+ x = IntervalVector([[0.2,10],[0.2,10]])
40
+ ctc_diamond.contract(x)
41
+ #self.assertTrue(x == IntervalVector([[0.2,0.8],[0.2,0.8]]))
42
+
43
+ x = IntervalVector([[0.5,10],[0.5,10]])
44
+ ctc_diamond.contract(x)
45
+ #self.assertTrue(x == IntervalVector([[0.5],[0.5]]))
46
+
47
+ if __name__ == '__main__':
48
+ unittest.main()