Opened 7 years ago

Closed 4 years ago

#14224 closed defect (fixed)

`cartesian_product` AssertionError

Reported by: eviatarbach Owned by: sage-combinat
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: combinatorics Keywords:
Cc: Merged in:
Authors: Reviewers: Frédéric Chapoton, Vincent Delecroix
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

As of now, passing a list, tuple, or set to cartesian_product returns an AssertionError?.

sage: cartesian_product([[0,1]])
AssertionError: 
sage: cartesian_product([FiniteEnumeratedSet([0,1])])  
The cartesian product of ({0, 1},)

I understand that this function can construct Cartesian products on different categories, so I see why it requires specific types. However, the error message should be more descriptive, especially considering that cartesian_product_iterator([[0,1]]), CartesianProduct([0,1]), and permutations([[0,1]]) all work.

Change History (7)

comment:1 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:2 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 4 years ago by vdelecroix

  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

Hello,

I propose to close this one as duplicate since with #18411 tuple/list input are automatically converted into FiniteEnumeratedSet and set/frozenset converted to Set

sage: C = cartesian_product([[1,2], (3,4), set([1,2,3]), frozenset([1,2])])
The cartesian product of ({1, 2}, {3, 4}, {1, 2, 3}, {1, 2})
sage: for c in C.cartesian_factors():
....:     print c.__class__.__name__
FiniteEnumeratedSet_with_category
FiniteEnumeratedSet_with_category
Set_object_enumerated_with_category
Set_object_enumerated_with_category

Vincent

comment:6 Changed 4 years ago by chapoton

  • Reviewers set to Frédéric Chapoton, Vincent Delecroix
  • Status changed from needs_review to positive_review

ok, I agree

comment:7 Changed 4 years ago by vbraun

  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.