Skip to content

Commit 9f46607

Browse files
author
Release Manager
committed
sagemathgh-39724: Fixing the cartesian product of a CFM and a generic object. <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Fixes sagemath#39723 by dispatching to the appropriate class based on input. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39724 Reported by: Travis Scrimshaw Reviewer(s): Frédéric Chapoton
2 parents 083f840 + e32b11b commit 9f46607

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/sage/combinat/free_module.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)