]> gitweb.michael.orlitzky.com - dunshire.git/commitdiff
Add the random_game() function to test.randomgen.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 6 Dec 2016 16:27:47 +0000 (11:27 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 6 Dec 2016 16:27:47 +0000 (11:27 -0500)
test/randomgen.py

index bfc70f3cf320031f6c8b7047ebdf9746288c0882..3d6484a7d280385c88ae778eecce8f02b310f1c0 100644 (file)
@@ -387,6 +387,36 @@ def random_icecream_game():
         return random_icecream_game()
 
 
+def random_game():
+    """
+    Return a random game.
+
+    One of the functions,
+
+      1. :func:`random_orthant_game`
+      2. :func:`random_icecream_game`
+
+    is chosen at random and used to generate a random game.
+
+    Returns
+    -------
+
+    SymmetricLinearGame
+        A random game.
+
+    Examples
+    --------
+
+        >>> random_game()
+        <dunshire.games.SymmetricLinearGame object at 0x...>
+
+    """
+    cone_type = randint(0,1)
+    if cone_type == 0:
+        return random_orthant_game()
+    elif cone_type == 1:
+        return random_icecream_game()
+
 def random_ll_orthant_game():
     """
     Return a random Lyapunov game over some nonnegative orthant.