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

problem with posets: iterating the subposet construction #5283

Closed
jhpalmieri opened this issue Feb 16, 2009 · 3 comments
Closed

problem with posets: iterating the subposet construction #5283

jhpalmieri opened this issue Feb 16, 2009 · 3 comments

Comments

@jhpalmieri
Copy link
Member

If I try to create a subposet of a subposet of something, I have problems:

sage: P = BooleanLattice(2)
sage: above = P.principal_order_filter(0)
sage: Q = P.subposet(above)
sage: above_new = Q.principal_order_filter(Q.list()[0])
sage: Q.subposet(above_new)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/Users/palmieri/.sage/temp/Macintosh.local/16679/_Users_palmieri__sage_init_sage_0.py in <module>()

/Applications/sage/local/lib/python2.5/site-packages/sage/combinat/posets/posets.pyc in subposet(self, elements)
   1036             raise ValueError, "not a list."
   1037         for element in elements:
-> 1038             if element not in self:
   1039                 raise ValueError, "element not in self"
   1040         relations = []

/Applications/sage/local/lib/python2.5/site-packages/sage/combinat/posets/posets.pyc in __contains__(self, x)
    272         else:
    273             y = x
--> 274         return y in self._elements
    275 
    276     def __call__(self,element):

/Applications/sage/local/lib/python2.5/site-packages/sage/combinat/posets/elements.pyc in __eq__(self, other)
     50             False
     51         """
---> 52         return self.parent() == other.parent() \
     53                 and self.element == other.element \
     54                 and self.vertex == other.vertex

AttributeError: 'int' object has no attribute 'parent'

I think that the problem is in the __contains__ method for posets, where the argument x is converted to x.element, which might be an int. I'm not sure why I have to iterate the subposet construction twice to get this to happen...

CC: @sagetrac-sage-combinat

Component: combinatorics

Issue created by migration from https://trac.sagemath.org/ticket/5283

@saliola
Copy link

saliola commented Apr 30, 2009

comment:2

Attachment: trac_5283.patch.gz

The poset elements are just wrapping elements, so I modified the subposet constructor to unwrap before constructing the subposet (it was wrapping a wrapped element).

Note that you can still create a poset of poset elements, this is just for the subposet constructor.

@jhpalmieri
Copy link
Member Author

comment:3

This fixes the problem, and all tests pass. Simple change to the code, good addition to the doctests.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented May 11, 2009

comment:4

Merged in Sage 4.0.alpha0.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-4.0 milestone May 11, 2009
@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed May 11, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants