Skip to content

Commit 0491e8f

Browse files
committed
-
1 parent 282f22a commit 0491e8f

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

source_py3/python_toolbox/combi/perming/calculating_length.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
import collections
33
import itertools
44

5+
from python_toolbox import nifty_collections
6+
from python_toolbox import cute_iter_tools
7+
58
infinity = float('inf')
69

10+
711
###############################################################################
812

913
_length_of_recurrent_perm_space_cache = {}
1014

1115
def calculate_length_of_recurrent_perm_space(k, ftt):
12-
from python_toolbox import nifty_collections
13-
from python_toolbox import cute_iter_tools
1416
cache = _length_of_recurrent_perm_space_cache
1517
if not isinstance(ftt, nifty_collections.FrozenTallyTally):
1618
ftt = nifty_collections.FrozenTallyTally(ftt)
@@ -59,11 +61,6 @@ def calculate_length_of_recurrent_perm_space(k, ftt):
5961
_length_of_recurrent_comb_space_cache = {}
6062

6163
def calculate_length_of_recurrent_comb_space(k, ftt):
62-
'''
63-
blocktodo gotta properly name these two sons of bitches
64-
'''
65-
from python_toolbox import nifty_collections
66-
from python_toolbox import cute_iter_tools
6764
cache = _length_of_recurrent_comb_space_cache
6865
if not isinstance(ftt, nifty_collections.FrozenTallyTally):
6966
ftt = nifty_collections.FrozenTallyTally(ftt)

source_py3/python_toolbox/combi/perming/perm_space.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from .. import misc
2727
from . import variations
28+
from .calculating_length import *
2829
from .variations import UnallowedVariationSelectionException
2930
from ._variation_removing_mixin import _VariationRemovingMixin
3031
from ._variation_adding_mixin import _VariationAddingMixin
@@ -377,7 +378,7 @@ def _unsliced_length(self):
377378
elif self.is_fixed:
378379
assert not self.is_degreed and not self.is_combination
379380
if self.is_recurrent:
380-
return math_tools.calculate_length_of_recurrent_perm_space(
381+
return calculate_length_of_recurrent_perm_space(
381382
self.n_elements - len(self.fixed_map),
382383
nifty_collections.FrozenTallyTally(
383384
collections.Counter(self.free_values).values()
@@ -394,12 +395,12 @@ def _unsliced_length(self):
394395
assert not self.is_degreed and not self.is_fixed
395396
if self.is_recurrent:
396397
if self.is_combination:
397-
return math_tools.calculate_length_of_recurrent_comb_space(
398+
return calculate_length_of_recurrent_comb_space(
398399
self.n_elements,
399400
self._frozen_tally_tally
400401
)
401402
else:
402-
return math_tools.calculate_length_of_recurrent_perm_space(
403+
return calculate_length_of_recurrent_perm_space(
403404
self.n_elements,
404405
self._frozen_tally_tally
405406
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from python_toolbox.combi.perming.calculating_length import *
2+
3+
def test_recurrent_perm_space_length():
4+
assert calculate_length_of_recurrent_perm_space(3, (3, 1, 1)) == 13
5+
assert calculate_length_of_recurrent_perm_space(2, (3, 2, 2, 1)) == 15
6+
assert calculate_length_of_recurrent_perm_space(3, (3, 2, 2, 1)) == 52
7+
8+
9+
def test_recurrent_comb_space_length():
10+
assert calculate_length_of_recurrent_comb_space(3, (3, 1, 1)) == 4
11+
assert calculate_length_of_recurrent_comb_space(2, (3, 2, 2, 1)) == 9
12+
assert calculate_length_of_recurrent_comb_space(3, (3, 2, 2, 1)) == 14
13+

source_py3/test_python_toolbox/test_math_tools/test_sequences.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,3 @@ def test_abs_stirling():
1919
# number was verified with Wolfram Mathematica.
2020

2121

22-
def test_recurrent_perm_space_length():
23-
assert calculate_length_of_recurrent_perm_space(3, (3, 1, 1)) == 13
24-
assert calculate_length_of_recurrent_perm_space(2, (3, 2, 2, 1)) == 15
25-
assert calculate_length_of_recurrent_perm_space(3, (3, 2, 2, 1)) == 52
26-
27-
28-
def test_recurrent_comb_space_length():
29-
assert calculate_length_of_recurrent_comb_space(3, (3, 1, 1)) == 4
30-
assert calculate_length_of_recurrent_comb_space(2, (3, 2, 2, 1)) == 9
31-
assert calculate_length_of_recurrent_comb_space(3, (3, 2, 2, 1)) == 14
32-

0 commit comments

Comments
 (0)