]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: allow Cartesian products to be returned from random_eja().
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 28 Feb 2021 14:50:37 +0000 (09:50 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 28 Feb 2021 14:50:37 +0000 (09:50 -0500)
mjo/eja/eja_algebra.py

index 799490044dbb4d0834577f435afd2dbc89429baf..5bb4cee119e31cde1fd17accc7cc6e0bdee7f041 100644 (file)
@@ -3480,17 +3480,15 @@ class RationalBasisCartesianProductEJA(CartesianProductEJA,
 
 RationalBasisEJA.CartesianProduct = RationalBasisCartesianProductEJA
 
-random_eja = ConcreteEJA.random_instance
-
-# def random_eja(*args, **kwargs):
-#     J1 = ConcreteEJA.random_instance(*args, **kwargs)
-
-#     # This might make Cartesian products appear roughly as often as
-#     # any other ConcreteEJA.
-#     if ZZ.random_element(len(ConcreteEJA.__subclasses__()) + 1) == 0:
-#         # Use random_eja() again so we can get more than two factors.
-#         J2 = random_eja(*args, **kwargs)
-#         J = cartesian_product([J1,J2])
-#         return J
-#     else:
-#         return J1
+def random_eja(*args, **kwargs):
+    J1 = ConcreteEJA.random_instance(*args, **kwargs)
+
+    # This might make Cartesian products appear roughly as often as
+    # any other ConcreteEJA.
+    if ZZ.random_element(len(ConcreteEJA.__subclasses__()) + 1) == 0:
+        # Use random_eja() again so we can get more than two factors.
+        J2 = random_eja(*args, **kwargs)
+        J = cartesian_product([J1,J2])
+        return J
+    else:
+        return J1