Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I find the subsets of a Cartesian product?

I have code that looks like this:

def Z(m,n):
  return CartesianProduct(IntegerRange(m),IntegerRange(n))

print Subsets(Z(2,2))

However, when I try to run it, it gives me the following scary error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/math4tots/math/<ipython console> in <module>()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/combinat/combinat.pyc in __str__(self)
   1052             'Partitions of the integer 5'
   1053         """
-> 1054         return self.__repr__()
   1055     
   1056     def _repr_(self):

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/combinat/subset.pyc in __repr__(self)
    152             'Subsets of {1, 2, 3}'
    153         """
--> 154         return "Subsets of %s"%self.s
    155 
    156     def __contains__(self, value):

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1492)()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/sets/set.pyc in _repr_(self)
    673             {0, 1}
    674         """
--> 675         s = repr(self.set())
    676         return "{" + s[5:-2] + "}"
    677 

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/sets/set.pyc in set(self)
    717             <class 'sage.sets.set.Set_object_enumerated_with_category'>
    718         """
--> 719         return set(self.object())
    720 
    721     def frozenset(self):

TypeError: unhashable type: 'list'

What did I do wrong? What is the canonical way to handle this situation?

How do I find the subsets of a Cartesian product?given Set?

I have code that looks like this:

def Z(m,n):
  return CartesianProduct(IntegerRange(m),IntegerRange(n))

print Subsets(Z(2,2))

However, when I try to run it, it gives me the following scary error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/math4tots/math/<ipython console> in <module>()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/combinat/combinat.pyc in __str__(self)
   1052             'Partitions of the integer 5'
   1053         """
-> 1054         return self.__repr__()
   1055     
   1056     def _repr_(self):

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/combinat/subset.pyc in __repr__(self)
    152             'Subsets of {1, 2, 3}'
    153         """
--> 154         return "Subsets of %s"%self.s
    155 
    156     def __contains__(self, value):

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1492)()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/sets/set.pyc in _repr_(self)
    673             {0, 1}
    674         """
--> 675         s = repr(self.set())
    676         return "{" + s[5:-2] + "}"
    677 

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/sets/set.pyc in set(self)
    717             <class 'sage.sets.set.Set_object_enumerated_with_category'>
    718         """
--> 719         return set(self.object())
    720 
    721     def frozenset(self):

TypeError: unhashable type: 'list'

What did I do wrong? What is the canonical way to handle this situation?

How do I find the subsets of given Set?

I have code that looks like this:

def Z(m,n):
  return CartesianProduct(IntegerRange(m),IntegerRange(n))

print Subsets(Z(2,2))

However, when I try to run it, it gives me the following scary error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/math4tots/math/<ipython console> in <module>()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/combinat/combinat.pyc in __str__(self)
   1052             'Partitions of the integer 5'
   1053         """
-> 1054         return self.__repr__()
   1055     
   1056     def _repr_(self):

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/combinat/subset.pyc in __repr__(self)
    152             'Subsets of {1, 2, 3}'
    153         """
--> 154         return "Subsets of %s"%self.s
    155 
    156     def __contains__(self, value):

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1492)()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/sets/set.pyc in _repr_(self)
    673             {0, 1}
    674         """
--> 675         s = repr(self.set())
    676         return "{" + s[5:-2] + "}"
    677 

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/sets/set.pyc in set(self)
    717             <class 'sage.sets.set.Set_object_enumerated_with_category'>
    718         """
--> 719         return set(self.object())
    720 
    721     def frozenset(self):

TypeError: unhashable type: 'list'

What did I do wrong? What is the canonical way to handle this situation?

I was expecting an output something along the lines of "Subsets of Cartesian Product of {0..2} {0..2}"

click to hide/show revision 4
retagged

How do I find the subsets of given Set?

I have code that looks like this:

def Z(m,n):
  return CartesianProduct(IntegerRange(m),IntegerRange(n))

print Subsets(Z(2,2))

However, when I try to run it, it gives me the following scary error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/math4tots/math/<ipython console> in <module>()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/combinat/combinat.pyc in __str__(self)
   1052             'Partitions of the integer 5'
   1053         """
-> 1054         return self.__repr__()
   1055     
   1056     def _repr_(self):

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/combinat/subset.pyc in __repr__(self)
    152             'Subsets of {1, 2, 3}'
    153         """
--> 154         return "Subsets of %s"%self.s
    155 
    156     def __contains__(self, value):

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1492)()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/sets/set.pyc in _repr_(self)
    673             {0, 1}
    674         """
--> 675         s = repr(self.set())
    676         return "{" + s[5:-2] + "}"
    677 

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/sets/set.pyc in set(self)
    717             <class 'sage.sets.set.Set_object_enumerated_with_category'>
    718         """
--> 719         return set(self.object())
    720 
    721     def frozenset(self):

TypeError: unhashable type: 'list'

What did I do wrong? What is the canonical way to handle this situation?

I was expecting an output something along the lines of "Subsets of Cartesian Product of {0..2} {0..2}"