On Sun, Aug 23, 2009 at 11:59 PM, John H Palmieri<jhpalmier...@gmail.com> wrote: > > On Aug 10, 8:41 pm, Rafael Villarroel <rvf0...@gmail.com> wrote:
> Some comments: first, in general, these functions would be better as > "methods", so that they would be called as > > S.is_free_face(s) > S.free_face_removed() > S.collapsed_complex() > > That is, they would be included in simplicial_complex.py, like > "remove_face", etc. > >> # a free face is one that is contained properly in exactly one maximal face >> def is_free_face (S,s): > > To turn into a method, change the previous line to "def is_free_face > (self, s):", and in general replace "S" with "self". > >> def f(x): return set(s)<=set(x) >> return not (Simplex(s) in S.facets()) and len(filter(f,S.facets()))==1 >> Thanks for your answer! I have added def is_free_face (self,s): """ A free face is one that is contained properly in exactly one maximal face. Removing a free face from a complex does not change the homotopy type of the complex. """ def f(x): return set(s)<=set(x) return not (Simplex(s) in self.facets()) and len(filter(f,self.facets()))==1 to the end of ~/sage-4.0/devel/sage-main/build/sage/homology/simplicial_complex.py (since it was the only one of the four simplicial_complex.py that I have under ~/sage-4.0 that seemed to make a difference). But now I get sage: S.is_free_face(l[1]) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/rafael/.sage/temp/rafael_desktop/1477/_home_rafael_sage_simplicial_sage_0.py in <module>() TypeError: 'set' object does not support indexing So, is there something else I have to do to make "is_free_face" work as a method? As soon as I get this working, I think I could work through your other suggestions. I think that it depends of the complex which method would be faster. For example, with a (complete) simplex, any vertex is a free face, and collapsing this simplex completely only takes as many steps as there are vertices. Best regards, Rafael --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---