@@ -7,9 +7,27 @@ class CombSpace(PermSpace):
77 '''
88 A space of combinations.
99
10+ This is a subclass of `PermSpace`; see its documentation for more details.
1011
12+ Each item in a `CombSpace` is a `Comb`, i.e. a combination. This is similar
13+ to `itertools.combinations`, except it offers far, far more functionality.
14+ The combinations may be accessed by index number, the combinations can be
15+ of a custom type, the space may be sliced, etc.
1116
12- Every item in a `CombSpace` is a `Comb`.
17+ Here is the simplest possible `CombSpace`:
18+
19+ >>> comb_space = CombSpace(4, 2)
20+ <CombSpace: 0..3, n_elements=2>
21+ >>> comb_space[2]
22+ <Comb, n_elements=2: (0, 3)>
23+ >>> tuple(comb_space)
24+ (<Comb, n_elements=2: (0, 1)>, <Comb, n_elements=2: (0, 2)>,
25+ <Comb, n_elements=2: (0, 3)>, <Comb, n_elements=2: (1, 2)>,
26+ <Comb, n_elements=2: (1, 3)>, <Comb, n_elements=2: (2, 3)>)
27+
28+ The members are `Comb` objects, which are sequence-like objects that have
29+ extra functionality. (See documentation of `Comb` and `Perm` for more
30+ info.)
1331 '''
1432 def __init__ (self , iterable_or_length , n_elements , * , slice_ = None ,
1533 perm_type = None , _domain_for_checking = None ,
@@ -22,7 +40,8 @@ def __init__(self, iterable_or_length, n_elements, *, slice_=None,
2240
2341
2442 def __repr__ (self ):
25- sequence_repr = repr (self .sequence )
43+ sequence_repr = self .sequence .short_repr if \
44+ hasattr (self .sequence , 'short_repr' ) else repr (self .sequence )
2645 if len (sequence_repr ) > 40 :
2746 sequence_repr = \
2847 '' .join ((sequence_repr [:35 ], ' ... ' , sequence_repr [- 1 ]))
0 commit comments