@@ -1776,6 +1776,25 @@ class CombinatorialFreeModule_CartesianProduct(CombinatorialFreeModule):
17761776 sage: S = cartesian_product([cartesian_product([F, G]), H]) # todo: not implemented
17771777 F (+) G (+) H
17781778 """
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 )
17791798
17801799 def __init__ (self , modules , ** options ):
17811800 r"""
@@ -1787,9 +1806,9 @@ def __init__(self, modules, **options):
17871806 Free module generated by {2, 4, 5} over Integer Ring (+) Free module generated by {2, 4, 7} over Integer Ring
17881807 sage: TestSuite(C).run()
17891808 """
1790- assert ( len (modules ) ) # TODO: generalize to a family or tuple
1809+ assert len (modules ) # TODO: generalize to a family or tuple
17911810 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 )
17931812 # should check the base ring
17941813 self ._sets = modules
17951814 CombinatorialFreeModule .__init__ (self , R ,
0 commit comments