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 b class HasseDiagram(DiGraph): 
    648648        for x in self.neighbor_in_iterator(element):
    649649            yield x
    650650
    651     def size(self):
     651    def cardinality(self):
    652652        """
    653653        Returns the number of elements in the poset.
    654        
     654
    655655        EXAMPLES::
    656        
    657             sage: Poset([[1,2,3],[4],[4],[4],[]]).size()
     656
     657            sage: Poset([[1,2,3],[4],[4],[4],[]]).cardinality()
    658658            5
    659659        """
    660660        return self.order()
    661661
     662    from sage.misc.misc import deprecated_function_alias
     663    size = deprecated_function_alias(cardinality, 'Sage Version 4.4 (2010-05)')
     664
    662665    def mobius_function(self,i,j): # dumb algorithm
    663666        r"""
    664667        Returns the value of the M\"obius function of the poset
    class HasseDiagram(DiGraph): 
    938941        """
    939942        if hasattr(self,'_meet'):
    940943            return self._meet
    941         n = self.size()
     944        n = self.cardinality()
    942945        meet = [[0 for x in range(n)] for x in range(n)]
    943946        le = self.lequal_matrix()
    944947        for i in range(n): le[i,i] = 1
    class HasseDiagram(DiGraph): 
    10341037            ValueError: No join for x=...
    10351038        """
    10361039        if hasattr(self,'_join'): return self._join
    1037         n = self.size()
     1040        n = self.cardinality()
    10381041        join = [[0 for x in range(n)] for x in range(n)]
    10391042        le = self.lequal_matrix()
    10401043        for i in range(n): le[i,i] = 1
    class HasseDiagram(DiGraph): 
    11551158            mt = self.meet_matrix()
    11561159        except ValueError:
    11571160            return False
    1158         n = self.size()
     1161        n = self.cardinality()
    11591162        c = [-1 for x in range(n)]
    11601163        for x in range(n):
    11611164            for y in range(x,n):
    class HasseDiagram(DiGraph): 
    11851188        """
    11861189        jn = self.join_matrix()
    11871190        mt = self.meet_matrix()
    1188         n = self.size()
     1191        n = self.cardinality()
    11891192        c = [None for x in range(n)]
    11901193        for x in range(n):
    11911194            for y in range(x,n):
    class HasseDiagram(DiGraph): 
    12251228            [[], [0], [1], [2], [3], [4]]
    12261229        """
    12271230        S = [[]]
    1228         self._antichains_rec([],0,range(1,self.size()),S)
     1231        self._antichains_rec([],0,range(1,self.cardinality()),S)
    12291232        return S
    12301233
    12311234    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 b class FinitePoset(ParentWithBase): 
    469469                        self._elements[element], element)
    470470            else:
    471471                return self._element_type(self, \
    472                         self._elements[element], self.size()+element)
     472                        self._elements[element], self.cardinality()+element)
    473473        else:
    474474            raise ValueError, "__call__ accepts a poset element or an integer; you passed %s"%type(element)
    475475
    class FinitePoset(ParentWithBase): 
    535535            sage: B.linear_extension()
    536536            [0, 1, 2, 3, 4, 5, 6, 7]
    537537        """
    538         return map(self._vertex_to_element,range(self.size()))
     538        return map(self._vertex_to_element,range(self.cardinality()))
    539539
    540540    def linear_extensions(self):
    541541        """
    class FinitePoset(ParentWithBase): 
    11091109        """
    11101110        return [x for x in self.lower_covers_iterator(y)]
    11111111
    1112     def size(self):
     1112    def cardinality(self):
    11131113        """
    11141114        Returns the number of elements in the poset.
    1115        
     1115
    11161116        EXAMPLES::
    1117        
    1118             sage: Poset([[1,2,3],[4],[4],[4],[]]).size()
     1117
     1118            sage: Poset([[1,2,3],[4],[4],[4],[]]).cardinality()
    11191119            5
    11201120        """
    11211121        return self._hasse_diagram.order()
    11221122
     1123    from sage.misc.misc import deprecated_function_alias
     1124    size = deprecated_function_alias(cardinality, 'Sage Version 4.4 (2010-05)')
     1125
    11231126    def mobius_function(self,x,y):
    11241127        r"""
    11251128        Returns the value of the Mobius function of the poset on the