Skip to content

Commit 298942b

Browse files
committed
-
1 parent df89cb6 commit 298942b

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

source_py3/python_toolbox/combi/perming/comb_space.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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]))

source_py3/python_toolbox/combi/perming/perm_space.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def __call__(cls, *args, **kwargs):
5858
return super().__call__(*args, **kwargs)
5959

6060

61-
@functools.total_ordering
6261
class PermSpace(_VariationRemovingMixin, _VariationAddingMixin,
6362
_FixedMapManagingMixin, sequence_tools.CuteSequenceMixin,
6463
collections.Sequence, metaclass=PermSpaceType):

0 commit comments

Comments
 (0)