Thanks Eric. It works! I figured out the FinitePoset part after reading the manual. But I know test that it works for X = FinitePoset(...) I didn't think of trying it with X = Poset(...).
On Monday, September 28, 2020 at 11:38:15 AM UTC-7 egourg...@gmail.com wrote: > Poset is a function, which constructs a finite poset, not the poset class, > as you can check: > sage: type(Poset) > <class 'function'> > You can also check it by having a look at the source code: > sage: Poset?? > > So when you write > Poset.upper_bounds = upper_bounds > you are attaching upper_bounds to the function, not to the class of > posets. The latter is FinitePoset (actually a subclass of it, name > FinitePoset_with_category, which is constructed dynamically via Sage > category mechanism). So you should do > > sage: from sage.combinat.posets.posets import FinitePoset > sage: FinitePoset.upper_bounds = upper_bounds > > Then > sage: X = Poset(...) > sage: X.upper_bounds(...) > shoud work. > > > Le lundi 28 septembre 2020 à 18:29:43 UTC+2, pong a écrit : > >> For convenient, I would like to add an attribute, upper_bounds, to Poset >> objects >> >> However, after writing the method and issue >> Poset.upper_bounds = upper_bounds >> >> X.upper_bounds(S) complains >> >> 'FinitePoset_with_category' object has no attribute 'upper_bounds' >> >> When I try >> FinitePoset_with_category.upper_bounds = upper_bounds >> >> I got >> name 'FinitePoset_with_category' is not defined >> >> So how can one add an attribute to FinitePoset_with_category? >> > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/3b134e30-a1a5-4e63-afd3-3a14380df654n%40googlegroups.com.