Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the cartesian product of a CFM and a generic object. #39724

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/sage/combinat/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,25 @@ class CombinatorialFreeModule_CartesianProduct(CombinatorialFreeModule):
sage: S = cartesian_product([cartesian_product([F, G]), H]) # todo: not implemented
F (+) G (+) H
"""
@staticmethod
def __classcall_private__(cls, modules, category, **options):
"""
Dispatch to the appropriate class based on the input.

EXMAPLES::

sage: Q = RootSystem(['A',3]).root_space(GF(3))
sage: W = WeylGroup(['A',3], prefix='s')
sage: CP = cartesian_product([Q, W])
sage: type(CP)
<class 'sage.sets.cartesian_product.CartesianProduct_with_category'>
"""
R = modules[0].base_ring()
Cat = ModulesWithBasis(R)
if any(module not in Cat for module in modules):
from sage.sets.cartesian_product import CartesianProduct
return CartesianProduct(modules, category, **options)
return super().__classcall__(cls, modules, category=category, **options)

def __init__(self, modules, **options):
r"""
Expand All @@ -1787,9 +1806,9 @@ def __init__(self, modules, **options):
Free module generated by {2, 4, 5} over Integer Ring (+) Free module generated by {2, 4, 7} over Integer Ring
sage: TestSuite(C).run()
"""
assert (len(modules)) # TODO: generalize to a family or tuple
assert len(modules) # TODO: generalize to a family or tuple
R = modules[0].base_ring()
assert (all(module in ModulesWithBasis(R)) for module in modules)
assert all(module in ModulesWithBasis(R) for module in modules)
# should check the base ring
self._sets = modules
CombinatorialFreeModule.__init__(self, R,
Expand Down
Loading