Skip to content

Commit b72e576

Browse files
committed
-
1 parent 4bca48d commit b72e576

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

source_py3/python_toolbox/combi/_variation_removing_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def unrapplied(self):
3030
fixed_map={key: self.sequence.index(value) for
3131
key, value in self.fixed_map.items()},
3232
degrees=self.degrees, n_elements=self.n_elements,
33-
is_combination=self.is_combination
33+
slice_=self.canonical_slice, is_combination=self.is_combination
3434
)
3535

3636
@caching.CachedProperty

source_py3/python_toolbox/combi/perm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,13 @@ def number(self):
187187
if self.is_dapplied:
188188
return self.undapplied.number
189189

190+
if self.is_recurrent:
191+
return self.nominal_perm_space.index(self)
192+
190193
factoradic_number = []
191194
unused_values = list(self.nominal_perm_space.sequence)
192195
for i, value in enumerate(self):
193-
index_of_current_number = \
194-
nifty_collections.OrderedSet(unused_values).index(value) if \
195-
self.is_recurrent else unused_values.index(value)
196+
index_of_current_number = unused_values.index(value)
196197
factoradic_number.append(index_of_current_number)
197198
unused_values.remove(value)
198199
return math_tools.from_factoradic(

source_py3/test_python_toolbox/test_combi/test_exhaustive.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pickle
55
import itertools
66
import collections
7+
import ast
78

89
import nose
910

@@ -256,7 +257,8 @@ def _check_variation_selection(variation_selection):
256257
# Give me your unsliced, your undegreed, your unfixed.
257258

258259
if not variation_selection.is_fixed and \
259-
not variation_selection.is_degreed:
260+
not variation_selection.is_degreed and \
261+
not variation_selection.is_recurrent:
260262
assert perm_space.index(perm) == i
261263
if not variation_selection.is_sliced:
262264
assert perm.number == i
@@ -331,6 +333,17 @@ def _check_variation_selection(variation_selection):
331333
# #
332334
### Finished testing neighbors. #######################################
333335

336+
perm_repr = repr(perm)
337+
perm_number_string, big_number_string = perm_repr.split(')', 1)[0] \
338+
.split('(', 1)[1].split(' / ')
339+
perm_number = ast.literal_eval(perm_number_string)
340+
big_number = (math.factorial(ast.literal_eval(big_number_string[:-1]))
341+
if big_number_string.endswith('!')
342+
else ast.literal_eval(big_number_string))
343+
344+
assert (0 <= perm_number == perm.number <= big_number ==
345+
perm.nominal_perm_space.length)
346+
334347

335348
def test():
336349
yield from ((_check_variation_selection, variation_selection) for

0 commit comments

Comments
 (0)