# Ticket #8735: trac_8735-poset_size_cardinality-fh.patch

File trac_8735-poset_size_cardinality-fh.patch, 4.3 KB (added by Florent Hivert, 13 years ago)
• ## sage/combinat/posets/hasse_diagram.py

```# HG changeset patch
# User Florent Hivert <Florent.Hivert@univ-rouen.fr>
# Date 1271883113 -7200
# Node ID 958a41a1854fe14362e1c68996e34ebcf7419b0b
# Parent  b0efff20b7011c94f859d89e8228516110222c67
8735: Renamed size to cardinality in posets.

diff --git a/sage/combinat/posets/hasse_diagram.py b/sage/combinat/posets/hasse_diagram.py```
 a class HasseDiagram(DiGraph): for x in self.neighbor_in_iterator(element): yield x def size(self): def cardinality(self): """ Returns the number of elements in the poset. EXAMPLES:: sage: Poset([[1,2,3],[4],[4],[4],[]]).size() sage: Poset([[1,2,3],[4],[4],[4],[]]).cardinality() 5 """ return self.order() from sage.misc.misc import deprecated_function_alias size = deprecated_function_alias(cardinality, 'Sage Version 4.4 (2010-05)') def mobius_function(self,i,j): # dumb algorithm r""" Returns the value of the M\"obius function of the poset class HasseDiagram(DiGraph): """ if hasattr(self,'_meet'): return self._meet n = self.size() n = self.cardinality() meet = [[0 for x in range(n)] for x in range(n)] le = self.lequal_matrix() for i in range(n): le[i,i] = 1 class HasseDiagram(DiGraph): ValueError: No join for x=... """ if hasattr(self,'_join'): return self._join n = self.size() n = self.cardinality() join = [[0 for x in range(n)] for x in range(n)] le = self.lequal_matrix() for i in range(n): le[i,i] = 1 class HasseDiagram(DiGraph): mt = self.meet_matrix() except ValueError: return False n = self.size() n = self.cardinality() c = [-1 for x in range(n)] for x in range(n): for y in range(x,n): class HasseDiagram(DiGraph): """ jn = self.join_matrix() mt = self.meet_matrix() n = self.size() n = self.cardinality() c = [None for x in range(n)] for x in range(n): for y in range(x,n): class HasseDiagram(DiGraph): [[], [0], [1], [2], [3], [4]] """ S = [[]] self._antichains_rec([],0,range(1,self.size()),S) self._antichains_rec([],0,range(1,self.cardinality()),S) return S def _antichains_rec(self,A,x,T,S):
• ## sage/combinat/posets/posets.py

`diff --git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py`
 a class FinitePoset(ParentWithBase): self._elements[element], element) else: return self._element_type(self, \ self._elements[element], self.size()+element) self._elements[element], self.cardinality()+element) else: raise ValueError, "__call__ accepts a poset element or an integer; you passed %s"%type(element) class FinitePoset(ParentWithBase): sage: B.linear_extension() [0, 1, 2, 3, 4, 5, 6, 7] """ return map(self._vertex_to_element,range(self.size())) return map(self._vertex_to_element,range(self.cardinality())) def linear_extensions(self): """ class FinitePoset(ParentWithBase): """ return [x for x in self.lower_covers_iterator(y)] def size(self): def cardinality(self): """ Returns the number of elements in the poset. EXAMPLES:: sage: Poset([[1,2,3],[4],[4],[4],[]]).size() sage: Poset([[1,2,3],[4],[4],[4],[]]).cardinality() 5 """ return self._hasse_diagram.order() from sage.misc.misc import deprecated_function_alias size = deprecated_function_alias(cardinality, 'Sage Version 4.4 (2010-05)') def mobius_function(self,x,y): r""" Returns the value of the Mobius function of the poset on the