<s> import pickle <EOL> import itertools <EOL> import math <EOL> from combi . _python_toolbox . third_party import functools <EOL> from combi . _python_toolbox import cute_testing <EOL> from combi . _python_toolbox import math_tools <EOL> from combi . _python_toolbox import cute_iter_tools <EOL> from combi . _python_toolbox import nifty_collections <EOL> from combi . _python_toolbox import caching <EOL> from combi . _python_toolbox import sequence_tools <EOL> import combi <EOL> from combi import * <EOL> infinity = float ( '<STR_LIT>' ) <EOL> infinities = ( infinity , - infinity ) <EOL> def test_perm_spaces ( ) : <EOL> pure_0a = PermSpace ( <NUM_LIT:4> ) <EOL> pure_0b = PermSpace ( range ( <NUM_LIT:4> ) ) <EOL> pure_0c = PermSpace ( list ( range ( <NUM_LIT:4> ) ) ) <EOL> pure_0d = PermSpace ( iter ( range ( <NUM_LIT:4> ) ) ) <EOL> assert pure_0a == pure_0b == pure_0c == pure_0d <EOL> assert len ( pure_0a ) == len ( pure_0b ) == len ( pure_0c ) == len ( pure_0d ) <EOL> assert repr ( pure_0a ) == repr ( pure_0b ) == repr ( pure_0c ) == repr ( pure_0d ) == '<STR_LIT>' <EOL> assert repr ( PermSpace ( sequence_tools . CuteRange ( <NUM_LIT:3> , <NUM_LIT:7> ) ) ) == '<STR_LIT>' <EOL> assert repr ( PermSpace ( sequence_tools . CuteRange ( <NUM_LIT:3> , <NUM_LIT:7> , <NUM_LIT:2> ) ) ) == '<STR_LIT>' <EOL> assert repr ( PermSpace ( tuple ( sequence_tools . CuteRange ( <NUM_LIT:3> , <NUM_LIT:7> , <NUM_LIT:2> ) ) ) ) == '<STR_LIT>' <EOL> assert cute_iter_tools . are_equal ( pure_0a , pure_0b , pure_0c , pure_0d ) <EOL> assert set ( map ( bool , ( pure_0a , pure_0b , pure_0c , pure_0d ) ) ) == set ( ( True , ) ) <EOL> pure_perm_space = pure_0a <EOL> assert pure_0a . is_pure <EOL> assert not pure_0a . is_rapplied <EOL> assert not pure_0a . is_dapplied <EOL> assert not pure_0a . is_fixed <EOL> assert not pure_0a . is_sliced <EOL> first_perm = pure_0a [ <NUM_LIT:0> ] <EOL> some_perm = pure_0a [ <NUM_LIT:7> ] <EOL> last_perm = pure_0a [ - <NUM_LIT:1> ] <EOL> assert first_perm . index ( <NUM_LIT:2> ) == <NUM_LIT:2> <EOL> assert first_perm . index ( <NUM_LIT:0> ) == <NUM_LIT:0> <EOL> with cute_testing . RaiseAssertor ( ValueError ) : first_perm . index ( <NUM_LIT:5> ) <EOL> assert last_perm . apply ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> assert last_perm . apply ( '<STR_LIT>' , str ) == '<STR_LIT>' <EOL> assert last_perm . apply ( '<STR_LIT>' , tuple ) == tuple ( '<STR_LIT>' ) <EOL> with cute_testing . RaiseAssertor ( IndexError ) : pure_0a [ - pure_0a . length - <NUM_LIT:1> ] <EOL> with cute_testing . RaiseAssertor ( IndexError ) : pure_0a [ - pure_0a . length - <NUM_LIT:2> ] <EOL> with cute_testing . RaiseAssertor ( IndexError ) : pure_0a [ - pure_0a . length - <NUM_LIT:30> ] <EOL> with cute_testing . RaiseAssertor ( IndexError ) : pure_0a [ pure_0a . length ] <EOL> with cute_testing . RaiseAssertor ( IndexError ) : pure_0a [ pure_0a . length + <NUM_LIT:1> ] <EOL> with cute_testing . RaiseAssertor ( IndexError ) : pure_0a [ pure_0a . length + <NUM_LIT:2> ] <EOL> with cute_testing . RaiseAssertor ( IndexError ) : pure_0a [ pure_0a . length + <NUM_LIT> ] <EOL> with cute_testing . RaiseAssertor ( ) : pure_0a [ <NUM_LIT> ] <EOL> assert pure_0a . take_random ( ) in pure_0c <EOL> pure_perm_space_dict = { pure_0a : '<STR_LIT:a>' , pure_0b : '<STR_LIT:b>' , <EOL> pure_0c : '<STR_LIT:c>' , pure_0d : '<STR_LIT:d>' , } <EOL> ( single_value , ) = pure_perm_space_dict . values ( ) <EOL> assert len ( pure_perm_space_dict ) == <NUM_LIT:1> <EOL> assert pure_perm_space_dict [ pure_0a ] == pure_perm_space_dict [ pure_0b ] == pure_perm_space_dict [ pure_0c ] == pure_perm_space_dict [ pure_0d ] == single_value <EOL> assert None not in pure_0a <EOL> assert PermSpace ( '<STR_LIT>' ) [ <NUM_LIT:0> ] not in pure_0a <EOL> assert type ( first_perm ) == type ( some_perm ) == type ( last_perm ) == Perm <EOL> assert set ( some_perm ) == set ( range ( <NUM_LIT:4> ) ) <EOL> assert tuple ( first_perm ) == ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert tuple ( last_perm ) == ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> assert Perm . coerce ( first_perm ) == first_perm <EOL> assert Perm . coerce ( first_perm , pure_0b ) == first_perm <EOL> assert Perm . coerce ( tuple ( first_perm ) ) == first_perm <EOL> assert Perm . coerce ( list ( first_perm ) ) == first_perm <EOL> assert Perm . coerce ( tuple ( first_perm ) , pure_0a ) == first_perm <EOL> assert Perm . coerce ( list ( first_perm ) , pure_0b ) == first_perm <EOL> assert Perm . coerce ( tuple ( first_perm ) , PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:4> ) ) != first_perm <EOL> assert isinstance ( first_perm . items , combi . perming . perm . PermItems ) <EOL> assert first_perm . items [ <NUM_LIT:2> ] == ( <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> assert repr ( first_perm . items ) == '<STR_LIT>' % repr ( first_perm ) <EOL> assert isinstance ( first_perm . as_dictoid , combi . perming . perm . PermAsDictoid ) <EOL> assert first_perm . as_dictoid [ <NUM_LIT:2> ] == <NUM_LIT:2> <EOL> assert dict ( first_perm . as_dictoid ) == { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : <NUM_LIT:1> , <NUM_LIT:2> : <NUM_LIT:2> , <NUM_LIT:3> : <NUM_LIT:3> } <EOL> assert not ( first_perm != first_perm ) <EOL> assert first_perm == first_perm <EOL> assert first_perm <EOL> assert tuple ( { pure_0a [ <NUM_LIT:4> ] : <NUM_LIT:1> , pure_0b [ <NUM_LIT:4> ] : <NUM_LIT:2> , pure_0c [ <NUM_LIT:4> ] : <NUM_LIT:3> , } . keys ( ) ) == ( pure_0d [ <NUM_LIT:4> ] , ) <EOL> assert some_perm . inverse == ~ some_perm <EOL> assert ~ ~ some_perm == some_perm <EOL> assert first_perm in pure_perm_space <EOL> assert set ( first_perm ) not in pure_perm_space <EOL> assert some_perm in pure_perm_space <EOL> assert last_perm in pure_perm_space <EOL> assert tuple ( first_perm ) in pure_perm_space <EOL> assert list ( some_perm ) in pure_perm_space <EOL> assert iter ( last_perm ) in pure_perm_space <EOL> assert '<STR_LIT>' not in pure_perm_space <EOL> assert ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> ) not in pure_perm_space <EOL> assert pure_perm_space . index ( first_perm ) == <NUM_LIT:0> <EOL> assert pure_perm_space . index ( last_perm ) == len ( pure_perm_space ) - <NUM_LIT:1> <EOL> assert pure_perm_space . index ( some_perm ) == <NUM_LIT:7> <EOL> assert '<STR_LIT>' * Perm ( ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:0> ) ) == '<STR_LIT>' <EOL> assert Perm ( '<STR_LIT>' , '<STR_LIT>' ) * Perm ( ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:0> ) ) == Perm ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] * Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) == ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) * Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) == Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> assert Perm ( ( <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:3> ) ) * Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> ) ) == Perm ( ( <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:1> ) ) <EOL> assert ( Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) ** ( - <NUM_LIT:2> ) ) == ( Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) ** ( - <NUM_LIT:1> ) ) == ( Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) ** ( <NUM_LIT:0> ) ) == ( Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) ** ( <NUM_LIT:1> ) ) == ( Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) ** <NUM_LIT:2> ) == ( Perm ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) ** <NUM_LIT:3> ) <EOL> assert set ( map ( bool , ( pure_0a [ <NUM_LIT:4> : <NUM_LIT:4> ] , pure_0a [ <NUM_LIT:3> : <NUM_LIT:2> ] ) ) ) == set ( ( False , ) ) <EOL> assert pure_0a [ <NUM_LIT:2> : <NUM_LIT:6> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] == pure_0a [ <NUM_LIT:3> : <NUM_LIT:5> ] <EOL> assert tuple ( pure_0a [ <NUM_LIT:2> : <NUM_LIT:6> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) == tuple ( pure_0a [ <NUM_LIT:3> : <NUM_LIT:5> ] ) <EOL> assert pure_0a [ <NUM_LIT:2> : <NUM_LIT:6> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] [ <NUM_LIT:1> ] == pure_0a [ <NUM_LIT:3> : <NUM_LIT:5> ] [ <NUM_LIT:1> ] <EOL> assert pure_0a [ <NUM_LIT:2> : <NUM_LIT:5> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] != pure_0a [ <NUM_LIT:3> : <NUM_LIT:5> ] <EOL> big_perm_space = PermSpace ( range ( <NUM_LIT> ) , fixed_map = { <NUM_LIT:1> : <NUM_LIT:5> , <NUM_LIT> : <NUM_LIT:3> , } , <EOL> degrees = ( <NUM_LIT:3> , <NUM_LIT:5> ) ) <EOL> assert big_perm_space == PermSpace ( range ( <NUM_LIT> ) , <EOL> fixed_map = { <NUM_LIT:1> : <NUM_LIT:5> , <NUM_LIT> : <NUM_LIT:3> , } . items ( ) , <EOL> degrees = ( <NUM_LIT:3> , <NUM_LIT:5> ) ) <EOL> for i in [ <NUM_LIT:10> ** <NUM_LIT:10> , <NUM_LIT:3> * <NUM_LIT:11> ** <NUM_LIT:9> - <NUM_LIT> , <NUM_LIT:4> * <NUM_LIT:12> ** <NUM_LIT:8> - <NUM_LIT:5> , <NUM_LIT:5> * <NUM_LIT:3> ** <NUM_LIT:20> + <NUM_LIT:4> ] : <EOL> perm = big_perm_space [ i ] <EOL> assert big_perm_space . index ( perm ) == i <EOL> repr_of_big_perm_space = repr ( PermSpace ( tuple ( range ( <NUM_LIT:100> , <NUM_LIT:0> , - <NUM_LIT:1> ) ) ) ) <EOL> assert '<STR_LIT>' in repr_of_big_perm_space <EOL> assert len ( repr_of_big_perm_space ) <= <NUM_LIT:100> <EOL> fixed_perm_space = pure_perm_space . get_fixed ( { <NUM_LIT:0> : <NUM_LIT:3> , } ) <EOL> assert fixed_perm_space . length == <NUM_LIT:6> <EOL> assert fixed_perm_space . is_fixed <EOL> assert not fixed_perm_space . is_pure <EOL> assert fixed_perm_space . unfixed . is_pure <EOL> assert fixed_perm_space . unfixed == pure_perm_space <EOL> assert pickle . loads ( pickle . dumps ( pure_perm_space ) ) == pure_perm_space <EOL> assert pickle . loads ( pickle . dumps ( pure_0b [ <NUM_LIT:2> ] ) ) == pure_0c [ <NUM_LIT:2> ] <EOL> assert pickle . loads ( pickle . dumps ( pure_0b [ <NUM_LIT:3> ] ) ) != pure_0b [ <NUM_LIT:4> ] <EOL> def test_fixed_perm_space ( ) : <EOL> pure_perm_space = PermSpace ( <NUM_LIT:5> ) <EOL> small_fixed_perm_space = PermSpace ( <NUM_LIT:5> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:2> : <NUM_LIT:2> , <NUM_LIT:4> : <NUM_LIT:4> , } ) <EOL> big_fixed_perm_space = PermSpace ( <NUM_LIT:5> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:2> : <NUM_LIT:2> , } ) <EOL> assert pure_perm_space != big_fixed_perm_space != small_fixed_perm_space <EOL> assert small_fixed_perm_space . length == len ( tuple ( small_fixed_perm_space ) ) == <NUM_LIT:2> <EOL> assert big_fixed_perm_space . length == len ( tuple ( big_fixed_perm_space ) ) == <NUM_LIT:6> <EOL> for perm in small_fixed_perm_space : <EOL> assert perm in big_fixed_perm_space <EOL> assert perm in pure_perm_space <EOL> for perm in big_fixed_perm_space : <EOL> assert perm in pure_perm_space <EOL> assert len ( [ perm for perm in big_fixed_perm_space if perm <EOL> not in small_fixed_perm_space ] ) == <NUM_LIT:4> <EOL> assert small_fixed_perm_space [ : ] == small_fixed_perm_space <EOL> assert small_fixed_perm_space [ <NUM_LIT:1> : ] [ <NUM_LIT:0> ] == small_fixed_perm_space [ <NUM_LIT:1> ] <EOL> assert small_fixed_perm_space . index ( small_fixed_perm_space [ <NUM_LIT:0> ] ) == <NUM_LIT:0> <EOL> assert small_fixed_perm_space . index ( small_fixed_perm_space [ <NUM_LIT:1> ] ) == <NUM_LIT:1> <EOL> assert big_fixed_perm_space . index ( big_fixed_perm_space [ <NUM_LIT:0> ] ) == <NUM_LIT:0> <EOL> assert big_fixed_perm_space . index ( big_fixed_perm_space [ <NUM_LIT:1> ] ) == <NUM_LIT:1> <EOL> assert big_fixed_perm_space . index ( big_fixed_perm_space [ <NUM_LIT:2> ] ) == <NUM_LIT:2> <EOL> assert big_fixed_perm_space . index ( big_fixed_perm_space [ <NUM_LIT:3> ] ) == <NUM_LIT:3> <EOL> assert big_fixed_perm_space . index ( big_fixed_perm_space [ <NUM_LIT:4> ] ) == <NUM_LIT:4> <EOL> assert big_fixed_perm_space . index ( big_fixed_perm_space [ <NUM_LIT:5> ] ) == <NUM_LIT:5> <EOL> for perm in small_fixed_perm_space : <EOL> assert ( perm [ <NUM_LIT:0> ] , perm [ <NUM_LIT:2> ] , perm [ <NUM_LIT:4> ] ) == ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:4> ) <EOL> for perm in big_fixed_perm_space : <EOL> assert ( perm [ <NUM_LIT:0> ] , perm [ <NUM_LIT:2> ] ) == ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> assert big_fixed_perm_space . index ( small_fixed_perm_space [ <NUM_LIT:1> ] ) != <NUM_LIT:1> <EOL> weird_fixed_perm_space = PermSpace ( range ( <NUM_LIT:100> ) , <EOL> fixed_map = zip ( range ( <NUM_LIT> ) , range ( <NUM_LIT> ) ) ) <EOL> assert weird_fixed_perm_space . length == math_tools . factorial ( <NUM_LIT:10> ) <EOL> assert weird_fixed_perm_space [ - <NUM_LIT> ] [ <NUM_LIT> ] == <NUM_LIT> <EOL> assert len ( repr ( weird_fixed_perm_space ) ) <= <NUM_LIT:100> <EOL> def test_rapplied_perm_space ( ) : <EOL> rapplied_perm_space = PermSpace ( '<STR_LIT>' ) <EOL> assert rapplied_perm_space . is_rapplied <EOL> assert not rapplied_perm_space . is_fixed <EOL> assert not rapplied_perm_space . is_sliced <EOL> assert '<STR_LIT>' in rapplied_perm_space <EOL> assert '<STR_LIT>' not in rapplied_perm_space <EOL> assert rapplied_perm_space . unrapplied [ <NUM_LIT:0> ] not in rapplied_perm_space <EOL> assert rapplied_perm_space [ rapplied_perm_space . index ( '<STR_LIT>' ) ] == Perm ( '<STR_LIT>' , rapplied_perm_space ) <EOL> rapplied_perm = rapplied_perm_space [ <NUM_LIT:3> ] <EOL> assert isinstance ( reversed ( rapplied_perm ) , Perm ) <EOL> assert tuple ( reversed ( rapplied_perm ) ) == tuple ( reversed ( tuple ( rapplied_perm ) ) ) <EOL> assert reversed ( reversed ( rapplied_perm ) ) == rapplied_perm <EOL> def test_dapplied_perm_space ( ) : <EOL> dapplied_perm_space = PermSpace ( <NUM_LIT:5> , domain = '<STR_LIT>' ) <EOL> assert dapplied_perm_space . is_dapplied <EOL> assert not dapplied_perm_space . is_rapplied <EOL> assert not dapplied_perm_space . is_fixed <EOL> assert not dapplied_perm_space . is_sliced <EOL> assert ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) in dapplied_perm_space <EOL> assert ( <NUM_LIT:0> , <NUM_LIT:4> , '<STR_LIT>' , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) not in dapplied_perm_space <EOL> assert dapplied_perm_space . get_partialled ( <NUM_LIT:3> ) [ <NUM_LIT:2> ] not in dapplied_perm_space <EOL> assert dapplied_perm_space . undapplied [ <NUM_LIT:7> ] not in dapplied_perm_space <EOL> dapplied_perm = dapplied_perm_space [ - <NUM_LIT:1> ] <EOL> assert dapplied_perm in dapplied_perm_space <EOL> assert isinstance ( reversed ( dapplied_perm ) , Perm ) <EOL> assert reversed ( dapplied_perm ) in dapplied_perm_space <EOL> assert tuple ( reversed ( dapplied_perm ) ) == tuple ( reversed ( tuple ( dapplied_perm ) ) ) <EOL> assert reversed ( reversed ( dapplied_perm ) ) == dapplied_perm <EOL> assert dapplied_perm [ '<STR_LIT:l>' ] == <NUM_LIT:0> <EOL> assert dapplied_perm [ '<STR_LIT:w>' ] == <NUM_LIT:1> <EOL> assert dapplied_perm [ '<STR_LIT:o>' ] == <NUM_LIT:2> <EOL> assert dapplied_perm [ '<STR_LIT:r>' ] == <NUM_LIT:3> <EOL> assert dapplied_perm [ '<STR_LIT:g>' ] == <NUM_LIT:4> <EOL> assert repr ( dapplied_perm ) == '''<STR_LIT>''' <EOL> assert dapplied_perm . index ( <NUM_LIT:4> ) == '<STR_LIT:g>' <EOL> assert dapplied_perm . as_dictoid [ '<STR_LIT:g>' ] == <NUM_LIT:4> <EOL> assert dapplied_perm . items [ <NUM_LIT:0> ] == ( '<STR_LIT:g>' , <NUM_LIT:4> ) <EOL> with cute_testing . RaiseAssertor ( IndexError ) : <EOL> dapplied_perm [ <NUM_LIT:2> ] <EOL> with cute_testing . RaiseAssertor ( IndexError ) : <EOL> dapplied_perm . as_dictoid [ <NUM_LIT:2> ] <EOL> with cute_testing . RaiseAssertor ( ValueError ) : <EOL> dapplied_perm . index ( '<STR_LIT:x>' ) <EOL> for char in '<STR_LIT>' : <EOL> assert char not in dapplied_perm <EOL> for number in range ( <NUM_LIT:5> ) : <EOL> assert number in dapplied_perm <EOL> assert not dapplied_perm_space . _just_fixed . is_fixed <EOL> assert not dapplied_perm_space . _just_fixed . is_dapplied <EOL> assert not dapplied_perm_space . _just_fixed . is_rapplied <EOL> assert not dapplied_perm_space . _just_fixed . is_partial <EOL> assert not dapplied_perm_space . _just_fixed . is_combination <EOL> assert not dapplied_perm_space . _just_fixed . is_degreed <EOL> assert repr ( dapplied_perm_space ) == "<STR_LIT>" <EOL> assert repr ( PermSpace ( <NUM_LIT:20> , domain = tuple ( range ( <NUM_LIT> , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ) ) == ( <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_degreed_perm_space ( ) : <EOL> assert PermSpace ( <NUM_LIT:3> , degrees = <NUM_LIT:0> ) . length == <NUM_LIT:1> <EOL> assert PermSpace ( <NUM_LIT:3> , degrees = <NUM_LIT:1> ) . length == <NUM_LIT:3> <EOL> assert PermSpace ( <NUM_LIT:3> , degrees = <NUM_LIT:2> ) . length == <NUM_LIT:2> <EOL> for perm in PermSpace ( <NUM_LIT:3> , degrees = <NUM_LIT:1> ) : <EOL> assert perm . degree == <NUM_LIT:1> <EOL> perm_space = PermSpace ( <NUM_LIT:5> , degrees = ( <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> for perm in perm_space : <EOL> assert perm . degree in ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> assert cute_iter_tools . is_sorted ( <EOL> [ perm_space . index ( perm ) for perm in perm_space ] <EOL> ) <EOL> assert PermSpace ( <EOL> <NUM_LIT:7> , domain = '<STR_LIT>' , <EOL> fixed_map = { '<STR_LIT:l>' : <NUM_LIT:5> , '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT:t>' : <NUM_LIT:0> , '<STR_LIT:v>' : <NUM_LIT:3> , '<STR_LIT:r>' : <NUM_LIT:1> , '<STR_LIT:e>' : <NUM_LIT:6> } , <EOL> degrees = ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> ) . length == <NUM_LIT:1> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:1> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : <NUM_LIT:1> , <NUM_LIT:2> : <NUM_LIT:2> , } ) . length == <NUM_LIT:0> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:1> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : <NUM_LIT:1> } ) . length == <NUM_LIT:1> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:1> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:0> , } ) . length == <NUM_LIT:3> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:1> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:1> , <NUM_LIT:1> : <NUM_LIT:0> , } ) . length == <NUM_LIT:1> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:1> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:1> , <NUM_LIT:1> : <NUM_LIT:2> , } ) . length == <NUM_LIT:0> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:2> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:1> , <NUM_LIT:1> : <NUM_LIT:2> , } ) . length == <NUM_LIT:1> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:3> , fixed_map = { <NUM_LIT:0> : <NUM_LIT:1> , <NUM_LIT:1> : <NUM_LIT:2> , } ) . length == <NUM_LIT:1> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:3> , fixed_map = { <NUM_LIT:2> : <NUM_LIT:3> , } ) . length == <NUM_LIT:2> <EOL> assert PermSpace ( <NUM_LIT:4> , degrees = <NUM_LIT:1> , fixed_map = { <NUM_LIT:2> : <NUM_LIT:3> , } ) . length == <NUM_LIT:1> <EOL> funky_perm_space = PermSpace ( '<STR_LIT>' , domain = '<STR_LIT>' , <EOL> degrees = ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:9> ) , <EOL> fixed_map = { '<STR_LIT:t>' : '<STR_LIT:i>' , '<STR_LIT:v>' : '<STR_LIT:g>' , } ) [ <NUM_LIT:2> : - <NUM_LIT:2> ] <EOL> assert funky_perm_space . purified == PermSpace ( <NUM_LIT:7> ) <EOL> assert funky_perm_space . is_rapplied <EOL> assert funky_perm_space . is_dapplied <EOL> assert funky_perm_space . is_degreed <EOL> assert funky_perm_space . is_fixed <EOL> assert funky_perm_space . is_sliced <EOL> assert not funky_perm_space . is_pure <EOL> assert funky_perm_space . degrees == ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> assert funky_perm_space . sequence == '<STR_LIT>' <EOL> assert funky_perm_space . domain == '<STR_LIT>' <EOL> assert funky_perm_space . canonical_slice . start == <NUM_LIT:2> <EOL> assert funky_perm_space . unsliced . undegreed . get_degreed ( <NUM_LIT:2> ) [ <NUM_LIT:0> ] not in funky_perm_space <EOL> assert funky_perm_space . unsliced . get_fixed ( { '<STR_LIT:t>' : '<STR_LIT:i>' , '<STR_LIT:v>' : '<STR_LIT:g>' , } ) [ funky_perm_space . slice_ ] == funky_perm_space <EOL> for i , perm in enumerate ( funky_perm_space ) : <EOL> assert perm . is_dapplied <EOL> assert perm . is_rapplied <EOL> assert perm [ '<STR_LIT:t>' ] == '<STR_LIT:i>' <EOL> assert perm [ '<STR_LIT:v>' ] == '<STR_LIT:g>' <EOL> assert perm [ '<STR_LIT:s>' ] in '<STR_LIT>' <EOL> assert <NUM_LIT:1> not in perm <EOL> assert perm . degree in ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:9> ) <EOL> assert funky_perm_space . index ( perm ) == i <EOL> assert perm . undapplied [ <NUM_LIT:0> ] == '<STR_LIT:i>' <EOL> assert perm . unrapplied [ '<STR_LIT:t>' ] == <NUM_LIT:0> <EOL> assert perm . unrapplied . undapplied [ <NUM_LIT:0> ] == <NUM_LIT:0> <EOL> assert perm . undapplied . is_rapplied <EOL> assert perm . unrapplied . is_dapplied <EOL> assert cute_iter_tools . is_sorted ( <EOL> [ funky_perm_space . index ( perm ) for perm in funky_perm_space ] <EOL> ) <EOL> other_perms_chain_space = ChainSpace ( ( funky_perm_space . unsliced [ : <NUM_LIT:2> ] , <EOL> funky_perm_space . unsliced [ - <NUM_LIT:2> : ] ) ) <EOL> for perm in other_perms_chain_space : <EOL> assert perm . is_dapplied <EOL> assert perm . is_rapplied <EOL> assert perm [ '<STR_LIT:t>' ] == '<STR_LIT:i>' <EOL> assert perm [ '<STR_LIT:v>' ] == '<STR_LIT:g>' <EOL> assert perm [ '<STR_LIT:s>' ] in '<STR_LIT>' <EOL> assert <NUM_LIT:1> not in perm <EOL> assert perm . degree in ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:9> ) <EOL> assert perm not in funky_perm_space <EOL> assert perm . unrapplied [ '<STR_LIT:t>' ] == <NUM_LIT:0> <EOL> assert perm . unrapplied . undapplied [ <NUM_LIT:0> ] == <NUM_LIT:0> <EOL> assert perm . undapplied . is_rapplied <EOL> assert perm . unrapplied . is_dapplied <EOL> assert other_perms_chain_space . length + funky_perm_space . length == funky_perm_space . unsliced . length <EOL> assert funky_perm_space . unsliced . length + funky_perm_space . unsliced . undegreed . get_degreed ( <EOL> i for i in range ( funky_perm_space . sequence_length ) <EOL> if i not in funky_perm_space . degrees <EOL> ) . length == funky_perm_space . unsliced . undegreed . length <EOL> assert funky_perm_space . _just_fixed . is_fixed <EOL> assert not funky_perm_space . _just_fixed . is_rapplied <EOL> assert not funky_perm_space . _just_fixed . is_dapplied <EOL> assert not funky_perm_space . _just_fixed . is_sliced <EOL> assert not funky_perm_space . _just_fixed . is_degreed <EOL> assert pickle . loads ( pickle . dumps ( funky_perm_space ) ) == funky_perm_space <EOL> assert funky_perm_space != pickle . loads ( pickle . dumps ( funky_perm_space . unsliced . unfixed ) ) == funky_perm_space . unsliced . unfixed <EOL> def test_partial_perm_space ( ) : <EOL> empty_partial_perm_space = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:6> ) <EOL> assert empty_partial_perm_space . length == <NUM_LIT:0> <EOL> assert empty_partial_perm_space . variation_selection == perming . variations . VariationSelection ( <EOL> set ( ( perming . variations . Variation . PARTIAL , ) ) ) <EOL> assert empty_partial_perm_space != PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:7> ) <EOL> with cute_testing . RaiseAssertor ( IndexError ) : <EOL> empty_partial_perm_space [ <NUM_LIT:0> ] <EOL> assert range ( <NUM_LIT:4> ) not in empty_partial_perm_space <EOL> assert range ( <NUM_LIT:5> ) not in empty_partial_perm_space <EOL> assert range ( <NUM_LIT:6> ) not in empty_partial_perm_space <EOL> assert range ( <NUM_LIT:7> ) not in empty_partial_perm_space <EOL> perm_space_0 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:5> ) <EOL> perm_space_1 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:3> ) <EOL> perm_space_2 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:2> ) <EOL> perm_space_3 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:1> ) <EOL> perm_space_4 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:0> ) <EOL> perm_space_5 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:5> , is_combination = True ) <EOL> perm_space_6 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:3> , is_combination = True ) <EOL> perm_space_7 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:2> , is_combination = True ) <EOL> perm_space_8 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:1> , is_combination = True ) <EOL> perm_space_9 = PermSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:0> , is_combination = True ) <EOL> assert not perm_space_0 . is_partial and not perm_space_0 . is_combination <EOL> assert perm_space_1 . is_partial and not perm_space_1 . is_combination <EOL> assert perm_space_2 . is_partial and not perm_space_2 . is_combination <EOL> assert perm_space_3 . is_partial and not perm_space_3 . is_combination <EOL> assert perm_space_4 . is_partial and not perm_space_4 . is_combination <EOL> assert set ( map ( type , ( perm_space_0 , perm_space_1 , perm_space_2 , <EOL> perm_space_3 , perm_space_4 ) ) ) == set ( ( PermSpace , ) ) <EOL> assert not perm_space_5 . is_partial and perm_space_5 . is_combination <EOL> assert perm_space_6 . is_partial and perm_space_6 . is_combination <EOL> assert perm_space_7 . is_partial and perm_space_7 . is_combination <EOL> assert perm_space_8 . is_partial and perm_space_8 . is_combination <EOL> assert perm_space_9 . is_partial and perm_space_9 . is_combination <EOL> assert set ( map ( type , ( perm_space_5 , perm_space_6 , perm_space_7 , <EOL> perm_space_8 , perm_space_9 ) ) ) == set ( ( CombSpace , ) ) <EOL> assert CombSpace ( <NUM_LIT:5> , n_elements = <NUM_LIT:2> ) == perm_space_7 <EOL> assert perm_space_0 . length == math . factorial ( <NUM_LIT:5> ) <EOL> assert perm_space_1 . length == <NUM_LIT:5> * <NUM_LIT:4> * <NUM_LIT:3> <EOL> assert perm_space_2 . length == <NUM_LIT:5> * <NUM_LIT:4> <EOL> assert perm_space_3 . length == <NUM_LIT:5> <EOL> assert perm_space_4 . length == <NUM_LIT:1> <EOL> assert perm_space_5 . length == <NUM_LIT:1> <EOL> assert perm_space_6 . length == perm_space_7 . length == <NUM_LIT:5> * <NUM_LIT:4> / <NUM_LIT:2> <EOL> assert perm_space_8 . length == <NUM_LIT:5> <EOL> assert perm_space_9 . length == <NUM_LIT:1> <EOL> assert set ( map ( tuple , perm_space_1 ) ) > set ( map ( tuple , perm_space_6 ) ) <EOL> for i , perm in enumerate ( perm_space_2 ) : <EOL> assert len ( perm ) == <NUM_LIT:2> <EOL> assert not perm . is_dapplied <EOL> assert not perm . is_rapplied <EOL> assert not isinstance ( perm , Comb ) <EOL> assert perm_space_2 . index ( perm ) == i <EOL> reconstructed_perm = Perm ( tuple ( perm ) , perm_space = perm_space_2 ) <EOL> assert perm == reconstructed_perm <EOL> for i , perm in enumerate ( perm_space_7 ) : <EOL> assert len ( perm ) == <NUM_LIT:2> <EOL> assert not perm . is_dapplied <EOL> assert not perm . is_rapplied <EOL> assert isinstance ( perm , Comb ) <EOL> assert perm_space_7 . index ( perm ) == i <EOL> assert perm [ <NUM_LIT:0> ] < perm [ <NUM_LIT:1> ] <EOL> reconstructed_perm = Perm ( tuple ( perm ) , perm_space = perm_space_7 ) <EOL> assert perm == reconstructed_perm <EOL> assert cute_iter_tools . is_sorted ( <EOL> [ perm_space_2 . index ( perm ) for perm in perm_space_2 ] <EOL> ) <EOL> assert cute_iter_tools . is_sorted ( <EOL> [ tuple ( perm ) for perm in perm_space_2 ] <EOL> ) <EOL> assert cute_iter_tools . is_sorted ( <EOL> [ perm_space_7 . index ( perm ) for perm in perm_space_7 ] <EOL> ) <EOL> assert cute_iter_tools . is_sorted ( <EOL> [ tuple ( perm ) for perm in perm_space_7 ] <EOL> ) <EOL> assert empty_partial_perm_space . length == <NUM_LIT:0> <EOL> def test_neighbors ( ) : <EOL> perm = Perm ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> first_level_neighbors = perm . get_neighbors ( ) <EOL> assert Perm ( '<STR_LIT>' , '<STR_LIT>' ) in first_level_neighbors <EOL> assert Perm ( '<STR_LIT>' , '<STR_LIT>' ) not in first_level_neighbors <EOL> assert len ( first_level_neighbors ) == <NUM_LIT:6> <EOL> assert isinstance ( first_level_neighbors [ <NUM_LIT:0> ] , Perm ) <EOL> first_and_second_level_neighbors = perm . get_neighbors ( degrees = ( <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> assert Perm ( '<STR_LIT>' , '<STR_LIT>' ) in first_and_second_level_neighbors <EOL> assert Perm ( '<STR_LIT>' , '<STR_LIT>' ) not in first_and_second_level_neighbors <EOL> assert Perm ( '<STR_LIT>' , '<STR_LIT>' ) in first_and_second_level_neighbors <EOL> assert isinstance ( first_and_second_level_neighbors [ - <NUM_LIT:1> ] , Perm ) <EOL> assert set ( first_level_neighbors ) < set ( first_and_second_level_neighbors ) <EOL> assert perm in perm . get_neighbors ( degrees = ( <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> assert set ( first_level_neighbors ) < set ( perm . get_neighbors ( degrees = ( <NUM_LIT:0> , <NUM_LIT:1> ) ) ) <EOL> assert len ( first_level_neighbors ) + <NUM_LIT:1> == len ( perm . get_neighbors ( degrees = ( <NUM_LIT:0> , <NUM_LIT:1> ) ) ) <EOL> def test_recurrent ( ) : <EOL> recurrent_perm_space = PermSpace ( '<STR_LIT>' , n_elements = <NUM_LIT:3> ) <EOL> assert recurrent_perm_space . is_recurrent <EOL> assert recurrent_perm_space . is_partial <EOL> assert recurrent_perm_space . length == <NUM_LIT> <EOL> assert recurrent_perm_space . combinationed . length == <NUM_LIT> <EOL> assert recurrent_perm_space . get_fixed ( { <NUM_LIT:1> : '<STR_LIT:b>' , } ) . length == <NUM_LIT> <EOL> assert PermSpace ( '<STR_LIT>' , n_elements = <NUM_LIT:1> ) . length == <NUM_LIT:2> <EOL> recurrent_perm_space = PermSpace ( '<STR_LIT>' * <NUM_LIT:100> , n_elements = <NUM_LIT:2> ) <EOL> assert recurrent_perm_space . length == <NUM_LIT:4> <EOL> assert tuple ( map ( tuple , recurrent_perm_space ) ) == ( <EOL> ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:b>' ) , <EOL> ) <EOL> assert recurrent_perm_space . unrecurrented . length == <NUM_LIT:200> * <NUM_LIT> <EOL> assert tuple ( map ( tuple , recurrent_perm_space . unrecurrented [ <NUM_LIT:0> : <NUM_LIT:6> ] ) ) == ( <EOL> ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:a>' ) , <EOL> ) <EOL> assert tuple ( map ( tuple , recurrent_perm_space . unrecurrented [ - <NUM_LIT:6> : ] ) ) == ( <EOL> ( '<STR_LIT:b>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:a>' ) , <EOL> ) <EOL> recurrent_comb_space = CombSpace ( '<STR_LIT>' * <NUM_LIT:100> , n_elements = <NUM_LIT:2> ) <EOL> assert recurrent_comb_space . length == <NUM_LIT:3> <EOL> assert tuple ( map ( tuple , recurrent_comb_space ) ) == ( <EOL> ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:b>' ) , <EOL> ) <EOL> recurrent_perm_space = PermSpace ( '<STR_LIT>' * <NUM_LIT:100> + '<STR_LIT:c>' , n_elements = <NUM_LIT:2> ) <EOL> assert recurrent_perm_space . length == <NUM_LIT:8> <EOL> assert tuple ( map ( tuple , recurrent_perm_space ) ) == ( <EOL> ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:c>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:c>' ) , <EOL> ( '<STR_LIT:c>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:c>' , '<STR_LIT:b>' ) , <EOL> ) <EOL> recurrent_comb_space = CombSpace ( '<STR_LIT>' * <NUM_LIT:100> + '<STR_LIT:c>' , n_elements = <NUM_LIT:2> ) <EOL> assert recurrent_comb_space . length == <NUM_LIT:5> <EOL> assert tuple ( map ( tuple , recurrent_comb_space ) ) == ( <EOL> ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:a>' ) , <EOL> ( '<STR_LIT:a>' , '<STR_LIT:c>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:b>' ) , <EOL> ( '<STR_LIT:b>' , '<STR_LIT:c>' ) , <EOL> ) <EOL> assert PermSpace ( <NUM_LIT:4> ) . unrecurrented == PermSpace ( <NUM_LIT:4> ) <EOL> def test_unrecurrented ( ) : <EOL> recurrent_perm_space = combi . PermSpace ( '<STR_LIT>' ) <EOL> unrecurrented_perm_space = recurrent_perm_space . unrecurrented <EOL> assert unrecurrented_perm_space . length == math_tools . factorial ( <NUM_LIT:6> ) <EOL> perm = unrecurrented_perm_space [ <NUM_LIT:100> ] <EOL> assert all ( i in '<STR_LIT:abc>' for i in perm ) <EOL> assert set ( map ( perm . index , '<STR_LIT:abc>' ) ) < set ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) ) <EOL> assert set ( '<STR_LIT>' . join ( perm ) ) == set ( '<STR_LIT:abc>' ) <EOL> def test_perm_type ( ) : <EOL> class Suit ( nifty_collections . CuteEnum ) : <EOL> club = '<STR_LIT>' <EOL> diamond = '<STR_LIT>' <EOL> heart = '<STR_LIT>' <EOL> spade = '<STR_LIT>' <EOL> __order__ = '<STR_LIT>' <EOL> @ functools . total_ordering <EOL> class Card ( ) : <EOL> def __init__ ( self , number_and_suit ) : <EOL> number , suit = number_and_suit <EOL> assert number in range ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> assert isinstance ( suit , Suit ) <EOL> self . number = number <EOL> self . suit = suit <EOL> _sequence = caching . CachedProperty ( lambda self : ( self . number , self . suit ) ) <EOL> _reduced = caching . CachedProperty ( lambda self : ( type ( self ) , self . _sequence ) ) <EOL> def __lt__ ( self , other ) : <EOL> if not isinstance ( other , Card ) : return NotImplemented <EOL> return self . _sequence < other . _sequence <EOL> def __eq__ ( self , other ) : <EOL> return type ( self ) == type ( other ) and self . _sequence == other . _sequence <EOL> __hash__ = lambda self : hash ( self . _reduced ) <EOL> __repr__ = lambda self : '<STR_LIT>' % ( <EOL> self . number if self . number <= <NUM_LIT:10> else '<STR_LIT>' [ self . number - <NUM_LIT:11> ] , <EOL> str ( self . suit . name ) [ <NUM_LIT:0> ] . capitalize ( ) <EOL> ) <EOL> card_space = combi . MapSpace ( Card , <EOL> combi . ProductSpace ( ( range ( <NUM_LIT:1> , <NUM_LIT> ) , Suit ) ) ) <EOL> class PokerHandSpace ( combi . CombSpace ) : <EOL> def __init__ ( self ) : <EOL> super ( PokerHandSpace , self ) . __init__ ( card_space , <NUM_LIT:5> , <EOL> perm_type = PokerHand ) <EOL> class PokerHand ( combi . Comb ) : <EOL> @ caching . CachedProperty <EOL> def stupid_score ( self ) : <EOL> return tuple ( <EOL> zip ( * nifty_collections . Bag ( card . number for card in self ) <EOL> . most_common ( ) ) ) [ <NUM_LIT:1> ] <EOL> poker_hand_space = PokerHandSpace ( ) <EOL> assert isinstance ( poker_hand_space [ <NUM_LIT:0> ] , PokerHand ) <EOL> some_poker_hands = MapSpace ( poker_hand_space . __getitem__ , <EOL> range ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> some_poker_hand_scores = set ( poker_hand . stupid_score for poker_hand <EOL> in some_poker_hands ) <EOL> assert ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) in some_poker_hand_scores <EOL> assert ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) in some_poker_hand_scores <EOL> assert ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> ) in some_poker_hand_scores <EOL> assert ( <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> ) in some_poker_hand_scores <EOL> card_comb_sequence = ( Card ( ( <NUM_LIT:1> , Suit . club ) ) , Card ( ( <NUM_LIT:2> , Suit . diamond ) ) , <EOL> Card ( ( <NUM_LIT:3> , Suit . heart ) ) , Card ( ( <NUM_LIT:4> , Suit . spade ) ) , <EOL> Card ( ( <NUM_LIT:5> , Suit . club ) ) ) <EOL> assert cute_iter_tools . is_sorted ( card_comb_sequence ) <EOL> assert card_comb_sequence in poker_hand_space <EOL> assert PokerHand ( card_comb_sequence , poker_hand_space ) in poker_hand_space <EOL> assert card_comb_sequence [ : : - <NUM_LIT:1> ] not in poker_hand_space <EOL> assert PokerHand ( card_comb_sequence [ : : - <NUM_LIT:1> ] , poker_hand_space ) not in poker_hand_space <EOL> assert PokerHand ( card_comb_sequence , poker_hand_space ) . stupid_score == ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> def test_variations_make_unequal ( ) : <EOL> class BluePerm ( Perm ) : pass <EOL> class RedPerm ( Perm ) : pass <EOL> perm_space = PermSpace ( <NUM_LIT:4> ) <EOL> assert perm_space == perm_space <EOL> assert perm_space != perm_space . get_rapplied ( '<STR_LIT>' ) != perm_space . get_rapplied ( '<STR_LIT>' ) <EOL> assert perm_space . get_rapplied ( '<STR_LIT>' ) == perm_space . get_rapplied ( '<STR_LIT>' ) <EOL> assert perm_space . get_rapplied ( '<STR_LIT>' ) == perm_space . get_rapplied ( '<STR_LIT>' ) <EOL> assert perm_space != perm_space . get_partialled ( <NUM_LIT:1> ) != perm_space . get_partialled ( <NUM_LIT:3> ) <EOL> assert perm_space . get_partialled ( <NUM_LIT:1> ) == perm_space . get_partialled ( <NUM_LIT:1> ) <EOL> assert perm_space . get_partialled ( <NUM_LIT:3> ) == perm_space . get_partialled ( <NUM_LIT:3> ) <EOL> assert perm_space != perm_space . combinationed <EOL> assert perm_space != perm_space . get_dapplied ( '<STR_LIT>' ) != perm_space . get_dapplied ( '<STR_LIT>' ) <EOL> assert perm_space . get_dapplied ( '<STR_LIT>' ) == perm_space . get_dapplied ( '<STR_LIT>' ) <EOL> assert perm_space . get_dapplied ( '<STR_LIT>' ) == perm_space . get_dapplied ( '<STR_LIT>' ) <EOL> assert perm_space != perm_space . get_fixed ( { <NUM_LIT:1> : <NUM_LIT:2> , } ) != perm_space . get_fixed ( { <NUM_LIT:3> : <NUM_LIT:2> , } ) <EOL> assert perm_space . get_fixed ( { <NUM_LIT:1> : <NUM_LIT:2> , } ) == perm_space . get_fixed ( { <NUM_LIT:1> : <NUM_LIT:2> , } ) <EOL> assert perm_space . get_fixed ( { <NUM_LIT:3> : <NUM_LIT:2> , } ) == perm_space . get_fixed ( { <NUM_LIT:3> : <NUM_LIT:2> , } ) <EOL> assert perm_space != perm_space . get_degreed ( <NUM_LIT:1> ) != perm_space . get_degreed ( <NUM_LIT:3> ) != perm_space . get_degreed ( ( <NUM_LIT:1> , <NUM_LIT:3> ) ) != perm_space <EOL> assert perm_space . get_degreed ( <NUM_LIT:2> ) == perm_space . get_degreed ( <NUM_LIT:2> ) <EOL> assert perm_space . get_degreed ( <NUM_LIT:3> ) == perm_space . get_degreed ( <NUM_LIT:3> ) <EOL> assert perm_space . get_degreed ( ( <NUM_LIT:1> , <NUM_LIT:3> ) ) == perm_space . get_degreed ( ( <NUM_LIT:3> , <NUM_LIT:1> ) ) == perm_space . get_degreed ( ( <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> assert perm_space != perm_space [ : - <NUM_LIT:1> ] != perm_space [ <NUM_LIT:1> : ] <EOL> assert perm_space [ : - <NUM_LIT:1> ] == perm_space [ : - <NUM_LIT:1> ] <EOL> assert perm_space [ <NUM_LIT:1> : ] == perm_space [ <NUM_LIT:1> : ] <EOL> assert perm_space != perm_space . get_typed ( BluePerm ) != perm_space . get_typed ( RedPerm ) <EOL> assert perm_space . get_typed ( BluePerm ) == perm_space . get_typed ( BluePerm ) <EOL> assert perm_space . get_typed ( RedPerm ) == perm_space . get_typed ( RedPerm ) </s>
