Hello, in earlier versions of sage this worked:
Omega = Combinations([1, 2, 3, 4, 5, 6], 4) A1 = Combinations([1], 1) A2 = Combinations([2, 3, 4, 5, 6], 3) A = CartesianProduct(A1, A2) A.cardinality() / Omega.cardinality() which we used in book for high school students to illustrate basic probability examples. Now this fails with assertion error (and no explanation attached). Digging deeper gives: File "/usr/local/sage/sage-7.0/local/lib/python2.7/site-packages/sage/combinat/cartesian_product.py", line 102, in CartesianProduct return cartesian_product(iters) File "/usr/local/sage/sage-7.0/local/lib/python2.7/site-packages/sage/categories/cartesian_product.py", line 174, in __call__ return super(CartesianProductFunctor, self).__call__(args, **kwds) File "/usr/local/sage/sage-7.0/local/lib/python2.7/site-packages/sage/categories/covariant_functorial_construction.py", line 221, in __call__ assert(all( hasattr(arg, self._functor_name) for arg in args)) AssertionError Simply making A1 and A2 list fails as well, because Combinations iterates over lists, so list(A1) is list of lists. TypeError: unhashable type: 'list' Easiest way I found around this is: A = cartesian_product([[tuple(a1) for a1 in A1], [tuple(a2) for a2 in A2]]) there is a LOT of syntax noise compared to simply: A = CartesianProduct(A1, A2) And the meaning is slightly different (in A there are tuples, in Omega there are lists, so we are not comparing same objects). Is there any simpler way to product output of Combinations? Limiting syntax noise is very important for making mathematical packages approachable to young students, and this change is definiately not along the lines. Also, it is important that most use cases are with same syntax, so if we have A1 = [1,2,3] A2 = [4,5,6] A = cartesian_product([A1, A2]) it would be good if the syntax was same for Combinations and other objects. Is the current behaviour designed or bug? Regards, Andrzej. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.