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

Cartesian product of Combinations fails #39004

Open
2 tasks done
tye-singwa opened this issue Nov 20, 2024 · 1 comment
Open
2 tasks done

Cartesian product of Combinations fails #39004

tye-singwa opened this issue Nov 20, 2024 · 1 comment
Labels

Comments

@tye-singwa
Copy link

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
@maxale
Copy link
Contributor

maxale commented Nov 20, 2024

Tuples(a,2) fails as well, but with a different error:

TypeError: unhashable type: 'list'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants