You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sage: Q = RootSystem(['A',3]).root_space(GF(3))
sage: W = WeylGroup(['A',3], prefix='s')
sage: cartesian_product([W, Q])
The Cartesian product of (Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space), Root space over the Finite Field of size 3 of the Root system of type ['A', 3])
sage: cartesian_product([Q, W])
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~/sage/src/sage/misc/cachefunc.pyx:1019, in sage.misc.cachefunc.CachedFunction.__call__()
1018 try:
-> 1019 return self.cache[k]
1020 except TypeError: # k is not hashable
File ~/sage/src/sage/misc/weak_dict.pyx:709, in sage.misc.weak_dict.WeakValueDictionary.__getitem__()
708 if wr == NULL:
--> 709 raise KeyError(k)
710 out = PyWeakref_GetObject(wr)
KeyError: ((<class 'sage.combinat.free_module.CombinatorialFreeModule_CartesianProduct'>, (Root space over the Finite Field of size 3 of the Root system of type ['A', 3], Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space))), (('category', Category of Cartesian products of sets),))
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
File ~/sage/src/sage/structure/category_object.pyx:857, in sage.structure.category_object.CategoryObject.getattr_from_category()
856 try:
--> 857 return self._cached_methods[name]
858 except KeyError:
KeyError: 'basis'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
Cell In[17], line 1
----> 1 cartesian_product([Q, W])
File ~/sage/src/sage/categories/cartesian_product.py:194, in CartesianProductFunctor.__call__(self, args, **kwds)
191 elif self._forced_category is not None:
192 return super().__call__(args, category=self._forced_category, **kwds)
--> 194 return super().__call__(args, **kwds)
File ~/sage/src/sage/categories/covariant_functorial_construction.py:226, in CovariantFunctorialConstruction.__call__(self, args, **kwargs)
224 assert all(hasattr(arg, self._functor_name) for arg in args)
225 assert len(args) > 0
--> 226 return getattr(args[0], self._functor_name)(*args[1:], **kwargs)
File ~/sage/src/sage/categories/sets_cat.py:1601, in Sets.ParentMethods.cartesian_product(*parents, **kwargs)
1599 else:
1600 category = category & extra_category
-> 1601 return parents[0].CartesianProduct(parents, category=category, **kwargs)
File ~/sage/src/sage/misc/classcall_metaclass.pyx:321, in sage.misc.classcall_metaclass.ClasscallMetaclass.__call__()
319 """
320 if cls.classcall is not None:
--> 321 return cls.classcall(cls, *args, **kwds)
322 else:
323 # Fast version of type.__call__(cls, *args, **kwds)
File ~/sage/src/sage/misc/cachefunc.pyx:1024, in sage.misc.cachefunc.CachedFunction.__call__()
1022 return self.cache[k]
1023 except KeyError:
-> 1024 w = self.f(*args, **kwds)
1025 self.cache[k] = w
1026 return w
File ~/sage/src/sage/structure/unique_representation.py:1113, in CachedRepresentation.__classcall__(cls, *args, **options)
1098 @weak_cached_function(cache=128) # automatically a staticmethod
1099 def __classcall__(cls, *args, **options):
1100 """
1101 Construct a new object of this class or reuse an existing one.
1102
(...)
1111 True
1112 """
-> 1113 return super().__classcall__(cls, *args, **options)
File ~/sage/src/sage/structure/unique_representation.py:597, in WithPicklingByInitArgs.__classcall__(cls, *args, **options)
573 @staticmethod
574 def __classcall__(cls, *args, **options):
575 """
576 Construct a new object of this class and store the arguments passed to ``__init__``.
577
(...)
595 False
596 """
--> 597 instance = typecall(cls, *args, **options)
598 assert isinstance(instance, cls)
599 if instance.__class__.__reduce__ == WithPicklingByInitArgs.__reduce__:
File ~/sage/src/sage/misc/classcall_metaclass.pyx:472, in sage.misc.classcall_metaclass.typecall()
470 2
471 """
--> 472 return (<PyTypeObject*>type).tp_call(cls, args, kwds)
473
474
File ~/sage/src/sage/combinat/free_module.py:1797, in CombinatorialFreeModule_CartesianProduct.__init__(self, modules, **options)
1793 # should check the base ring
1794 self._sets = modules
1795 CombinatorialFreeModule.__init__(self, R,
1796 DisjointUnionEnumeratedSets(
-> 1797 [module.basis().keys() for module in modules], keepkey=True),
1798 **options)
File ~/sage/src/sage/structure/category_object.pyx:851, in sage.structure.category_object.CategoryObject.__getattr__()
849 AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
850 """
--> 851 return self.getattr_from_category(name)
852
853 cdef getattr_from_category(self, name):
File ~/sage/src/sage/structure/category_object.pyx:866, in sage.structure.category_object.CategoryObject.getattr_from_category()
864 cls = self._category.parent_class
865
--> 866 attr = getattr_from_other_class(self, cls, name)
867 self._cached_methods[name] = attr
868 return attr
File ~/sage/src/sage/cpython/getattr.pyx:358, in sage.cpython.getattr.getattr_from_other_class()
356 dummy_error_message.cls = type(self)
357 dummy_error_message.name = name
--> 358 raise AttributeError(dummy_error_message)
359 cdef PyObject* attr = instance_getattr(cls, name)
360 if attr is NULL:
AttributeError: 'WeylGroup_gens_with_category' object has no attribute 'basis'
The problem stems from the special implementation of Cartesian products for CFMs not checking the other inputs and falling back on the default/generic implementation.
The text was updated successfully, but these errors were encountered:
fchapoton
changed the title
cartesiean_product of a CombinatorialFreeAlgebra and a non-algebra fails
cartesian_product of a CombinatorialFreeAlgebra and a non-algebra fails
Mar 17, 2025
vbraun
pushed a commit
to vbraun/sage
that referenced
this issue
Mar 19, 2025
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 "Fixessagemath#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, "Fixessagemath#12345". -->
Fixessagemath#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
Specifically, if we do
The problem stems from the special implementation of Cartesian products for CFMs not checking the other inputs and falling back on the default/generic implementation.
The text was updated successfully, but these errors were encountered: