]> gitweb.michael.orlitzky.com - dunshire.git/commitdiff
Add more doctest examples to the randomgen module.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 1 Nov 2016 22:58:18 +0000 (18:58 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 1 Nov 2016 22:58:18 +0000 (18:58 -0400)
test/__init__.py
test/randomgen.py

index 074b2b13b3a24fe1c94447ce317e9781ac35d517..0f6f15c665da78f61effd04e9159e5bf50b9ef56 100644 (file)
@@ -28,7 +28,7 @@ def build_suite():
     suite.addTest(DocTestSuite(games, optionflags=ELLIPSIS))
     suite.addTest(DocTestSuite(matrices, optionflags=ELLIPSIS))
     suite.addTest(DocTestSuite(symmetric_linear_game_test))
-    suite.addTest(DocTestSuite(randomgen))
+    suite.addTest(DocTestSuite(randomgen, optionflags=ELLIPSIS))
     slg_tests = TestLoader().loadTestsFromModule(symmetric_linear_game_test)
     suite.addTest(slg_tests)
     mat_tests = TestLoader().loadTestsFromModule(matrices_test)
index 395408c6626ec4ee48dcb95e3b2e684daea88f4a..9510c04767150b967283f62f72d7e7a88f112186 100644 (file)
@@ -314,6 +314,12 @@ def random_orthant_game():
     SymmetricLinearGame
         A random game over some nonnegative orthant.
 
+    Examples
+    --------
+
+        >>> random_orthant_game()
+        <dunshire.games.SymmetricLinearGame object at 0x...>
+
     """
     ambient_dim = random_natural() + 1
     K = NonnegativeOrthant(ambient_dim)
@@ -343,6 +349,12 @@ def random_icecream_game():
     SymmetricLinearGame
         A random game over some ice-cream cone.
 
+    Examples
+    --------
+
+        >>> random_icecream_game()
+        <dunshire.games.SymmetricLinearGame object at 0x...>
+
     """
     # Use a minimum dimension of two to avoid divide-by-zero in
     # the fudge factor we make up later.
@@ -387,6 +399,12 @@ def random_ll_orthant_game():
         A random game over some nonnegative orthant whose ``payoff`` method
         is based on a Lyapunov-like ``L`` operator.
 
+    Examples
+    --------
+
+        >>> random_ll_orthant_game()
+        <dunshire.games.SymmetricLinearGame object at 0x...>
+
     """
     G = random_orthant_game()
     L = random_diagonal_matrix(G._K.dimension())
@@ -419,6 +437,12 @@ def random_ll_icecream_game():
         A random game over some ice-cream cone whose ``payoff`` method
         is based on a Lyapunov-like ``L`` operator.
 
+    Examples
+    --------
+
+        >>> random_ll_icecream_game()
+        <dunshire.games.SymmetricLinearGame object at 0x...>
+
     """
     G = random_icecream_game()
     L = random_lyapunov_like_icecream(G._K.dimension())
@@ -452,6 +476,12 @@ def random_positive_orthant_game():
         A random game over some nonnegative orthant whose ``payoff`` method
         is based on a positive ``L`` operator.
 
+    Examples
+    --------
+
+        >>> random_positive_orthant_game()
+        <dunshire.games.SymmetricLinearGame object at 0x...>
+
     """
 
     G = random_orthant_game()
@@ -487,6 +517,22 @@ def random_nn_scaling(G):
     (float, SymmetricLinearGame)
         A pair containing the both the scaling factor and the new scaled game.
 
+    Examples
+    --------
+
+        >>> from dunshire.matrices import norm
+        >>> from dunshire.options import ABS_TOL
+        >>> G = random_orthant_game()
+        >>> (alpha, H) = random_nn_scaling(G)
+        >>> alpha >= 0
+        True
+        >>> G._K == H._K
+        True
+        >>> norm(G._e1 - H._e1) < ABS_TOL
+        True
+        >>> norm(G._e2 - H._e2) < ABS_TOL
+        True
+
     """
     alpha = random_nn_scalar()
     H = SymmetricLinearGame(alpha*G._L.trans(), G._K, G._e1, G._e2)
@@ -518,6 +564,20 @@ def random_translation(G):
         A pair containing the both the translation distance and the new
         scaled game.
 
+    Examples
+    --------
+
+        >>> from dunshire.matrices import norm
+        >>> from dunshire.options import ABS_TOL
+        >>> G = random_orthant_game()
+        >>> (alpha, H) = random_translation(G)
+        >>> G._K == H._K
+        True
+        >>> norm(G._e1 - H._e1) < ABS_TOL
+        True
+        >>> norm(G._e2 - H._e2) < ABS_TOL
+        True
+
     """
     alpha = random_scalar()
     tensor_prod = G._e1 * G._e2.trans()