Skip to content

Commit aca5afc

Browse files
committed
-
1 parent a56e028 commit aca5afc

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

source_py3/python_toolbox/combi/perm_space.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ def get_rapplied(self, sequence):
763763
def get_dapplied(self, domain):
764764
'''Get a version of this `PermSpace` that has a domain of `domain`.'''
765765
assert not self.is_dapplied
766+
if self.is_combination:
767+
raise Exception("Can't use a domain with combination spaces.")
766768
domain = \
767769
sequence_tools.ensure_iterable_is_immutable_sequence(domain)
768770
if len(domain) != self.n_elements:
@@ -779,6 +781,8 @@ def get_degreed(self, degrees):
779781
if self.is_sliced:
780782
raise Exception("Can't be used on sliced perm spaces. Try "
781783
"`perm_space.unsliced.get_degreed(...)`.")
784+
if self.is_combination:
785+
raise Exception("Can't use degrees with combination spaces.")
782786
if not degrees:
783787
return self
784788
degrees_to_use = \

source_py3/test_python_toolbox/test_combi/test_comb_space.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright 2009-2014 Ram Rachum.
22
# This program is distributed under the MIT license.
33

4+
from python_toolbox import cute_testing
5+
46
from python_toolbox.combi import *
57

68

@@ -22,9 +24,25 @@ def test():
2224
for thing in things_not_in_comb_space:
2325
assert thing not in comb_space
2426

25-
26-
27-
28-
29-
30-
27+
assert comb_space.n_unused_elements == 4
28+
assert comb_space.index('du') == 0
29+
assert comb_space.index('er') == comb_space.length - 1
30+
assert comb_space.undapplied == comb_space
31+
assert comb_space.unrapplied == CombSpace(6, 2)
32+
assert comb_space.unpartialled == CombSpace(6, 6)
33+
assert comb_space.uncombinationed == PermSpace('dumber', n_elements=6)
34+
assert comb_space.undegreed == comb_space
35+
assert comb_space.unrapplied.get_rapplied(range(10, 70, 10)) == \
36+
CombSpace(range(10, 70, 10), 2)
37+
with cute_testing.RaiseAssertor():
38+
comb_space.undapplied.get_dapplied(range(10, 70, 10))
39+
with cute_testing.RaiseAssertor():
40+
comb_space.get_degreed(3)
41+
assert comb_space.unfixed == comb_space
42+
assert not comb_space.fixed_indices
43+
assert comb_space.free_indices == comb_space.free_keys == (0, 1)
44+
assert comb_space.free_values == tuple('dumber')
45+
46+
47+
48+

0 commit comments

Comments
 (0)