ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 13 Apr 2012 18:04:35 +0200Can't make subposetshttps://ask.sagemath.org/question/7764/cant-make-subposets/I'm running into a problem trying to construct a subposet.
sage: L #poset of permutations
Finite poset containing 14 elements
sage: L.random_subposet(.5)
Finite poset containing 10 elements
sage: SPG=ShortestPathGraph(L) #constructs a graph that is the Hasse diagram
#of L with some edges deleted
sage: SPG
Digraph on 14 vertices
sage: S=Poset(SPG)
sage: S.random_subposet(.5)
results in an error message ending
AttributeError: 'Permutation_class' object has no attribute 'parent'
I get the same error when I try to construct a specific subposet (what I actually want to do), but I can't create duplicate the error in a small example. `random_subposet()` works just fine for a small poset created from a digraph whose vertices are permutations. Any ideas what could be going on? (I suspect whatever it is may have to be in ShortestPathGraph, given that I can't duplicate the error with a small digraph, but that doesn't really make sense, so I'd appreciate that sort of answer as well.)Sun, 14 Nov 2010 14:25:48 +0100https://ask.sagemath.org/question/7764/cant-make-subposets/Answer by sewowg for <p>I'm running into a problem trying to construct a subposet.</p>
<pre><code>sage: L #poset of permutations
Finite poset containing 14 elements
sage: L.random_subposet(.5)
Finite poset containing 10 elements
sage: SPG=ShortestPathGraph(L) #constructs a graph that is the Hasse diagram
#of L with some edges deleted
sage: SPG
Digraph on 14 vertices
sage: S=Poset(SPG)
sage: S.random_subposet(.5)
</code></pre>
<p>results in an error message ending</p>
<pre><code>AttributeError: 'Permutation_class' object has no attribute 'parent'
</code></pre>
<p>I get the same error when I try to construct a specific subposet (what I actually want to do), but I can't create duplicate the error in a small example. <code>random_subposet()</code> works just fine for a small poset created from a digraph whose vertices are permutations. Any ideas what could be going on? (I suspect whatever it is may have to be in ShortestPathGraph, given that I can't duplicate the error with a small digraph, but that doesn't really make sense, so I'd appreciate that sort of answer as well.)</p>
https://ask.sagemath.org/question/7764/cant-make-subposets/?answer=13454#post-id-13454spam deletedFri, 13 Apr 2012 04:34:11 +0200https://ask.sagemath.org/question/7764/cant-make-subposets/?answer=13454#post-id-13454Answer by niles for <p>I'm running into a problem trying to construct a subposet.</p>
<pre><code>sage: L #poset of permutations
Finite poset containing 14 elements
sage: L.random_subposet(.5)
Finite poset containing 10 elements
sage: SPG=ShortestPathGraph(L) #constructs a graph that is the Hasse diagram
#of L with some edges deleted
sage: SPG
Digraph on 14 vertices
sage: S=Poset(SPG)
sage: S.random_subposet(.5)
</code></pre>
<p>results in an error message ending</p>
<pre><code>AttributeError: 'Permutation_class' object has no attribute 'parent'
</code></pre>
<p>I get the same error when I try to construct a specific subposet (what I actually want to do), but I can't create duplicate the error in a small example. <code>random_subposet()</code> works just fine for a small poset created from a digraph whose vertices are permutations. Any ideas what could be going on? (I suspect whatever it is may have to be in ShortestPathGraph, given that I can't duplicate the error with a small digraph, but that doesn't really make sense, so I'd appreciate that sort of answer as well.)</p>
https://ask.sagemath.org/question/7764/cant-make-subposets/?answer=13455#post-id-13455You just need to add a `parent()` method to the appropriate object. Since I don't know how these objects are defined, I can't give you an example, but you should be able to work it out by searching the source code for where the `parent()` method is getting called, and adding such a method to the objects you're using. An easy way to do that would be to define a subclass, define the `parent()` method there, and then use instances of the subclass instead of the original class.Fri, 13 Apr 2012 18:04:35 +0200https://ask.sagemath.org/question/7764/cant-make-subposets/?answer=13455#post-id-13455