File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
test_python_toolbox/test_combi Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff line change 44import pickle
55import itertools
66import collections
7+ import ast
78
89import 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
335348def test ():
336349 yield from ((_check_variation_selection , variation_selection ) for
You can’t perform that action at this time.
0 commit comments