@@ -540,10 +540,48 @@ cdef class AbstractFamily(Parent):
540
540
541
541
542
542
543
- cdef class FiniteFamily_base ( AbstractFamily) :
543
+ cdef class FiniteFamily ( AbstractFamily) :
544
544
r"""
545
- Cython base class for :class:`FiniteFamily`.
545
+ A :class:`FiniteFamily` is an associative container which models a finite
546
+ family `( f_i) _{i \i n I}`. Its elements `f_i` are therefore its
547
+ values. Instances should be created via the :func:`Family` factory. See its
548
+ documentation for examples and tests.
549
+
550
+ EXAMPLES:
551
+
552
+ We define the family `( f_i) _{i \i n \{ 3,4,7\} }` with `f_3=a`,
553
+ `f_4=b`, and `f_7=d`::
554
+
555
+ sage: from sage. sets. family import FiniteFamily
556
+ sage: f = FiniteFamily( {3: 'a', 4: 'b', 7: 'd'})
557
+
558
+ Individual elements are accessible as in a usual dictionary::
559
+
560
+ sage: f[7 ]
561
+ 'd'
562
+
563
+ And the other usual dictionary operations are also available::
564
+
565
+ sage: len( f)
566
+ 3
567
+ sage: f. keys( )
568
+ [3, 4, 7 ]
569
+
570
+ However f behaves as a container for the `f_i`'s::
571
+
572
+ sage: list( f)
573
+ ['a', 'b', 'd' ]
574
+ sage: [ x for x in f ]
575
+ ['a', 'b', 'd' ]
576
+
577
+ The order of the elements can be specified using the ``keys`` optional argument::
578
+
579
+ sage: f = FiniteFamily( {"a": "aa", "b": "bb", "c" : "cc" }, keys = ["c", "a", "b" ])
580
+ sage: list( f)
581
+ ['cc', 'aa', 'bb' ]
582
+
546
583
"""
584
+
547
585
def __init__( self, dictionary, keys=None) :
548
586
"""
549
587
TESTS::
@@ -679,8 +717,8 @@ cdef class FiniteFamily_base(AbstractFamily):
679
717
False
680
718
"""
681
719
return ( isinstance( other, self. __class__) and
682
- self. _keys == ( <FiniteFamily_base > other) . _keys and
683
- self. _dictionary == ( <FiniteFamily_base > other) . _dictionary)
720
+ self. _keys == ( <FiniteFamily > other) . _keys and
721
+ self. _dictionary == ( <FiniteFamily > other) . _dictionary)
684
722
685
723
def _repr_( self) :
686
724
"""
@@ -796,49 +834,6 @@ cdef class FiniteFamily_base(AbstractFamily):
796
834
self. __init__( state['dictionary' ], keys=state. get( "keys"))
797
835
798
836
799
- class FiniteFamily( FiniteFamily_base) :
800
- r"""
801
- A :class:`FiniteFamily` is an associative container which models a finite
802
- family `( f_i) _{i \i n I}`. Its elements `f_i` are therefore its
803
- values. Instances should be created via the :func:`Family` factory. See its
804
- documentation for examples and tests.
805
-
806
- EXAMPLES:
807
-
808
- We define the family `( f_i) _{i \i n \{ 3,4,7\} }` with `f_3=a`,
809
- `f_4=b`, and `f_7=d`::
810
-
811
- sage: from sage. sets. family import FiniteFamily
812
- sage: f = FiniteFamily( {3: 'a', 4: 'b', 7: 'd'})
813
-
814
- Individual elements are accessible as in a usual dictionary::
815
-
816
- sage: f[7 ]
817
- 'd'
818
-
819
- And the other usual dictionary operations are also available::
820
-
821
- sage: len( f)
822
- 3
823
- sage: f. keys( )
824
- [3, 4, 7 ]
825
-
826
- However f behaves as a container for the `f_i`'s::
827
-
828
- sage: list( f)
829
- ['a', 'b', 'd' ]
830
- sage: [ x for x in f ]
831
- ['a', 'b', 'd' ]
832
-
833
- The order of the elements can be specified using the ``keys`` optional argument::
834
-
835
- sage: f = FiniteFamily( {"a": "aa", "b": "bb", "c" : "cc" }, keys = ["c", "a", "b" ])
836
- sage: list( f)
837
- ['cc', 'aa', 'bb' ]
838
-
839
- """
840
- pass
841
-
842
837
class FiniteFamilyWithHiddenKeys( FiniteFamily) :
843
838
r"""
844
839
A close variant of :class:`FiniteFamily` where the family contains some
0 commit comments