Skip to content

Cartesian product of Combinations fails #39004

Open
@tye-singwa

Description

@tye-singwa

Steps To Reproduce

Try to compute cartesian product of Combinations

a = Combinations([1,2,3], 2)
cartesian_product([a, a])

Expected Behavior

Returns cartesian product of Combinations

Actual Behavior

Fails with stacktrace

File ~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/misc/cachefunc.pyx:610, in sage.misc.cachefunc.cache_key_unhashable (build/cythonized/sage/misc/cachefunc.c:6105)()
    [608](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/misc/cachefunc.pyx:610,%20in%20sage.misc.cachefunc.cache_key_unhashable%20(build/cythonized/sage/misc/cachefunc.c:608)     return tuple(cache_key(item) for item in o)
    [609](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/misc/cachefunc.pyx:610,%20in%20sage.misc.cachefunc.cache_key_unhashable%20(build/cythonized/sage/misc/cachefunc.c:609) try:
--> [610](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/misc/cachefunc.pyx:610,%20in%20sage.misc.cachefunc.cache_key_unhashable%20(build/cythonized/sage/misc/cachefunc.c:610)     k = o._cache_key()
    [611](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/misc/cachefunc.pyx:610,%20in%20sage.misc.cachefunc.cache_key_unhashable%20(build/cythonized/sage/misc/cachefunc.c:611) except AttributeError:
    [612](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/misc/cachefunc.pyx:610,%20in%20sage.misc.cachefunc.cache_key_unhashable%20(build/cythonized/sage/misc/cachefunc.c:612)     raise TypeError("unhashable type: {!r}".format(type(o).__name__))

File ~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/structure/sage_object.pyx:439, in sage.structure.sage_object.SageObject._cache_key (build/cythonized/sage/structure/sage_object.c:5084)()
    [437](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/structure/sage_object.pyx:439,%20in%20sage.structure.sage_object.SageObject._cache_key%20(build/cythonized/sage/structure/sage_object.c:437)     hash(self)
    [438](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/structure/sage_object.pyx:439,%20in%20sage.structure.sage_object.SageObject._cache_key%20(build/cythonized/sage/structure/sage_object.c:438) except TypeError:
--> [439](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/structure/sage_object.pyx:439,%20in%20sage.structure.sage_object.SageObject._cache_key%20(build/cythonized/sage/structure/sage_object.c:439)     raise TypeError("{} is not hashable and does not implement _cache_key()".format(type(self)))
    [440](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/structure/sage_object.pyx:439,%20in%20sage.structure.sage_object.SageObject._cache_key%20(build/cythonized/sage/structure/sage_object.c:440) else:
    [441](~/miniconda3/envs/sage/lib/python3.12/site-packages/sage/structure/sage_object.pyx:439,%20in%20sage.structure.sage_object.SageObject._cache_key%20(build/cythonized/sage/structure/sage_object.c:441)     assert False, "_cache_key() must not be called for hashable elements"

TypeError: <class 'sage.combinat.combination.Combinations_setk_with_category'> is not hashable and does not implement _cache_key()

Additional Information

I think _cache_key for Combinations_setk_with_category should be implemented

Environment

  • OS: Ubuntu 23.10
  • Sage Version: 10.3

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions