@@ -315,6 +315,8 @@ def test_cartesian_sx(self):
315315 _sqd_sx = cartesian .distance_squared (u_sx )
316316 u_mx = cs .SX .sym ("u" , 9 , 1 )
317317 _sqd_mx = cartesian .distance_squared (u_mx )
318+ self .assertEqual (2 , cartesian .segment_dimension (0 ))
319+ self .assertEqual (3 , cartesian .segment_dimension (1 ))
318320
319321 def test_cartesian_segments_not_increasing (self ):
320322 no_constraints = og .constraints .NoConstraints ()
@@ -343,6 +345,24 @@ def test_cartesian_segments_empty_args(self):
343345 with self .assertRaises (ValueError ) as __context :
344346 og .constraints .CartesianProduct ([], sets )
345347
348+ def test_cartesian_convex (self ):
349+ ball_inf = og .constraints .BallInf (None , 1 )
350+ ball_eucl = og .constraints .Ball2 (None , 1 )
351+ cartesian = og .constraints .CartesianProduct (
352+ [5 , 10 ], [ball_inf , ball_eucl ])
353+ self .assertTrue (cartesian .is_convex ())
354+ self .assertTrue (cartesian .is_compact ())
355+
356+ finite_set = og .constraints .FiniteSet ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
357+ cartesian = og .constraints .CartesianProduct (
358+ [5 , 10 , 13 ], [ball_inf , ball_eucl , finite_set ])
359+ self .assertFalse (cartesian .is_convex ())
360+
361+ free = og .constraints .NoConstraints ()
362+ cartesian = og .constraints .CartesianProduct (
363+ [5 , 10 , 11 ], [ball_inf , ball_eucl , free ])
364+ self .assertFalse (cartesian .is_compact ())
365+
346366 # -----------------------------------------------------------------------
347367 # Finite Set
348368 # -----------------------------------------------------------------------
@@ -375,6 +395,10 @@ def test_finite_set_compact(self):
375395 c = og .constraints .FiniteSet ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
376396 self .assertTrue (c .is_compact ())
377397
398+ def test_finite_set_dimension (self ):
399+ c = og .constraints .FiniteSet ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
400+ self .assertEqual (3 , c .dimension ())
401+
378402 # -----------------------------------------------------------------------
379403 # Halfspaces
380404 # -----------------------------------------------------------------------
@@ -513,6 +537,12 @@ def test_sphere2_sq_distance_symbolic(self):
513537 z = fun ([1 , 1 , 0 , 0 ])
514538 self .assertAlmostEqual (0.835786437626905 , z , places = 12 )
515539
540+ def test_sphere2_no_center (self ):
541+ sphere = og .constraints .Sphere2 (radius = 0.5 )
542+ u = [0 , 0 , 0 , 0 ]
543+ dist = sphere .distance_squared (u )
544+ self .assertAlmostEqual (0.25 , dist , places = 12 )
545+
516546
517547if __name__ == '__main__' :
518548 unittest .main ()
0 commit comments