Opened 13 years ago

Closed 13 years ago

#5283 closed defect (fixed)

[with patch; positive review] problem with posets: iterating the subposet construction

Reported by: jhpalmieri Owned by: somebody
Priority: major Milestone: sage-4.0
Component: combinatorics Keywords:
Cc: sage-combinat Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

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...

Attachments (1)

trac_5283.patch (1.5 KB) - added by saliola 13 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 13 years ago by nthiery

  • Cc sage-combinat added

Changed 13 years ago by saliola

comment:2 Changed 13 years ago by saliola

  • Summary changed from problem with posets: iterating the subposet construction to [with patch; needs review] problem with posets: iterating the subposet construction

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.

comment:3 Changed 13 years ago by jhpalmieri

  • Summary changed from [with patch; needs review] problem with posets: iterating the subposet construction to [with patch; positive review] problem with posets: iterating the subposet construction

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

comment:4 Changed 13 years ago by mabshoff

  • Milestone changed from sage-combinat to sage-4.0
  • Resolution set to fixed
  • Status changed from new to closed

Merged in Sage 4.0.alpha0.

Cheers,

Michael

Note: See TracTickets for help on using tickets.