Opened 8 years ago
Closed 8 years ago
#12351 closed defect (fixed)
AttributeError raised by method __eq__ of poset element
Reported by: | slabbe | Owned by: | slabbe |
---|---|---|---|
Priority: | major | Milestone: | sage-5.0 |
Component: | combinatorics | Keywords: | poset |
Cc: | sage-combinat | Merged in: | sage-5.0.beta9 |
Authors: | David Loeffler | Reviewers: | Nicolas M. Thiéry, Simon King |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
Using sage-4.7.2
sage: P = Poset([[1,2],[4],[3],[4],[]]) sage: P(0) == int(0) Traceback (most recent call last): ... AttributeError: 'int' object has no attribute 'parent'
This error is raised when ploting a poset :
sage: m = WordMorphism('a->abb,b->ba') sage: w = m.fixed_point('a') sage: prefix = Word(list(w[:100])) sage: pals = prefix.palindromes() sage: poset = Poset((pals, lambda x,y: x.is_factor(y))) sage: H = poset.hasse_diagram() sage: H.plot() Traceback (most recent call last): ... AttributeError: 'int' object has no attribute 'parent'
Attachments (1)
Change History (14)
comment:1 Changed 8 years ago by
- Status changed from new to needs_review
comment:2 follow-up: ↓ 3 Changed 8 years ago by
- Reviewers set to Sébastien Labbé
- Status changed from needs_review to positive_review
Great!
I tested it (on sage-4.7.2) and it solves the problem. All tests pass on sage/combinat
repository. Documentation builds fine. Positive review.
But now, I get another problem. When the package sage -i dot2tex
is installed the method layout_graphviz
gets called by plot
and it seems broken for another reason. But this should be another ticket :
sage: H.plot() Traceback (most recent call last): ... AttributeError: 'str' object has no attribute 'iteritems'
which is also obtained by doing
sage: H.layout_graphviz() # require dot2tex Traceback (most recent call last): ... AttributeError: 'str' object has no attribute 'iteritems'
comment:3 in reply to: ↑ 2 Changed 8 years ago by
But now, I get another problem.
This is now #12364.
comment:4 Changed 8 years ago by
Same lines are edited by #11559. One will have to adapt to the other one.
comment:5 follow-up: ↓ 6 Changed 8 years ago by
- Description modified (diff)
- Owner changed from sage-combinat to slabbe
- Summary changed from AttributeError when ploting a poset to AttributeError raised by method __eq__ of poset element
Changed the ticket title and its description since the original problem (hasse diagram ploting) might be (is?) solved indirectly by #10998.
comment:6 in reply to: ↑ 5 ; follow-up: ↓ 7 Changed 8 years ago by
- Status changed from positive_review to needs_work
comment:7 in reply to: ↑ 6 Changed 8 years ago by
Replying to nthiery:
Replying to slabbe:
Changed the ticket title and its description since the original problem (hasse diagram ploting) might be (is?) solved indirectly by #10998.
I removed the positive review, just in case we decide that this should be resolved as a duplicate of #10998.
Since #10998 does not touch the __eq__
method, I suggest that one first checks whether the bug triggered by comparing a poset element with a Python int is really fixed by #10998.
comment:8 Changed 8 years ago by
comment:9 follow-up: ↓ 10 Changed 8 years ago by
- Status changed from needs_work to needs_review
I just tested that the error vanishes with #10998. From that point of view, one could suggest that the ticket be resolved as duplicate.
On the other hand, having parent(bla)
instead of bla.parent()
is another layer of security and won't hurt.
I leave the decision to you.
comment:10 in reply to: ↑ 9 Changed 8 years ago by
Replying to SimonKing:
I just tested that the error vanishes with #10998. From that point of view, one could suggest that the ticket be resolved as duplicate.
On the other hand, having
parent(bla)
instead ofbla.parent()
is another layer of security and won't hurt.I leave the decision to you.
I don't mind. In case we go for it, we might as well use "sage.structure.sage_object.have_same_parent".
comment:11 Changed 8 years ago by
- Reviewers Sébastien Labbé deleted
The new code from #10998 already uses have_same_parent
. So all that's left to do here is to add a doctest to prevent the error happening again. I've uploaded a patch for that.
comment:12 Changed 8 years ago by
- Reviewers set to Nicolas M. Thiéry, Simon King
- Status changed from needs_review to positive_review
comment:13 Changed 8 years ago by
- Merged in set to sage-5.0.beta9
- Resolution set to fixed
- Status changed from positive_review to closed
The problem was in the comparison of poset elements. Comparing a poset element with any object that has no parent (for example, comparison with a Python int) resulted in an error.
I thought the straight forward way to fix it is: Use
sage.structure.element.parent(bla)
instead ofbla.parent()
.With the patch, plotting the Hasse diagram works, and the bug fix is doctested. Needs review, then!