@@ -1776,6 +1776,25 @@ class CombinatorialFreeModule_CartesianProduct(CombinatorialFreeModule):
1776
1776
sage: S = cartesian_product([cartesian_product([F, G]), H]) # todo: not implemented
1777
1777
F (+) G (+) H
1778
1778
"""
1779
+ @staticmethod
1780
+ def __classcall_private__ (cls , modules , category , ** options ):
1781
+ """
1782
+ Dispatch to the appropriate class based on the input.
1783
+
1784
+ EXMAPLES::
1785
+
1786
+ sage: Q = RootSystem(['A',3]).root_space(GF(3))
1787
+ sage: W = WeylGroup(['A',3], prefix='s')
1788
+ sage: CP = cartesian_product([Q, W])
1789
+ sage: type(CP)
1790
+ <class 'sage.sets.cartesian_product.CartesianProduct_with_category'>
1791
+ """
1792
+ R = modules [0 ].base_ring ()
1793
+ Cat = ModulesWithBasis (R )
1794
+ if any (module not in Cat for module in modules ):
1795
+ from sage .sets .cartesian_product import CartesianProduct
1796
+ return CartesianProduct (modules , category , ** options )
1797
+ return super ().__classcall__ (cls , modules , category = category , ** options )
1779
1798
1780
1799
def __init__ (self , modules , ** options ):
1781
1800
r"""
@@ -1787,9 +1806,9 @@ def __init__(self, modules, **options):
1787
1806
Free module generated by {2, 4, 5} over Integer Ring (+) Free module generated by {2, 4, 7} over Integer Ring
1788
1807
sage: TestSuite(C).run()
1789
1808
"""
1790
- assert ( len (modules ) ) # TODO: generalize to a family or tuple
1809
+ assert len (modules ) # TODO: generalize to a family or tuple
1791
1810
R = modules [0 ].base_ring ()
1792
- assert ( all (module in ModulesWithBasis (R ) ) for module in modules )
1811
+ assert all (module in ModulesWithBasis (R ) for module in modules )
1793
1812
# should check the base ring
1794
1813
self ._sets = modules
1795
1814
CombinatorialFreeModule .__init__ (self , R ,
0 commit comments