<s> '''<STR_LIT>''' <EOL> from python_toolbox import cute_testing <EOL> from python_toolbox . sequence_tools import partitions <EOL> def test ( ) : <EOL> '''<STR_LIT>''' <EOL> r = list ( range ( <NUM_LIT:8> ) ) <EOL> assert partitions ( r , <NUM_LIT:1> ) == partitions ( r , n_partitions = <NUM_LIT:8> ) == [ [ <NUM_LIT:0> ] , [ <NUM_LIT:1> ] , [ <NUM_LIT:2> ] , [ <NUM_LIT:3> ] , [ <NUM_LIT:4> ] , [ <NUM_LIT:5> ] , [ <NUM_LIT:6> ] , [ <NUM_LIT:7> ] ] <EOL> assert partitions ( r , <NUM_LIT:2> ) == partitions ( r , n_partitions = <NUM_LIT:4> ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> ] , [ <NUM_LIT:2> , <NUM_LIT:3> ] , [ <NUM_LIT:4> , <NUM_LIT:5> ] , [ <NUM_LIT:6> , <NUM_LIT:7> ] ] <EOL> assert partitions ( r , <NUM_LIT:3> ) == partitions ( r , n_partitions = <NUM_LIT:3> ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] , [ <NUM_LIT:6> , <NUM_LIT:7> ] ] <EOL> assert partitions ( r , <NUM_LIT:4> ) == partitions ( r , n_partitions = <NUM_LIT:2> ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] ] <EOL> assert partitions ( r , <NUM_LIT:5> ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] , [ <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] ] <EOL> assert partitions ( r , <NUM_LIT:6> ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] , [ <NUM_LIT:6> , <NUM_LIT:7> ] ] <EOL> assert partitions ( r , <NUM_LIT:7> ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , [ <NUM_LIT:7> ] ] <EOL> assert partitions ( r , <NUM_LIT:8> ) == partitions ( r , <NUM_LIT:9> ) == partitions ( r , <NUM_LIT:100> ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] ] <EOL> def test_too_many_arguments ( ) : <EOL> '''<STR_LIT>''' <EOL> with cute_testing . RaiseAssertor ( text = '<STR_LIT>' ) : <EOL> partitions ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <NUM_LIT:2> , n_partitions = <NUM_LIT:2> ) <EOL> def test_allow_remainder ( ) : <EOL> '''<STR_LIT>''' <EOL> r = list ( range ( <NUM_LIT:9> ) ) <EOL> assert partitions ( r , <NUM_LIT:1> , allow_remainder = False ) == partitions ( r , n_partitions = <NUM_LIT:9> , allow_remainder = False ) == [ [ <NUM_LIT:0> ] , [ <NUM_LIT:1> ] , [ <NUM_LIT:2> ] , [ <NUM_LIT:3> ] , [ <NUM_LIT:4> ] , [ <NUM_LIT:5> ] , [ <NUM_LIT:6> ] , [ <NUM_LIT:7> ] , [ <NUM_LIT:8> ] ] <EOL> assert partitions ( r , <NUM_LIT:3> , allow_remainder = False ) == partitions ( r , n_partitions = <NUM_LIT:3> , allow_remainder = False ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] , [ <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ] ] <EOL> with cute_testing . RaiseAssertor ( text = '<STR_LIT>' ) : <EOL> partitions ( r , <NUM_LIT:2> , allow_remainder = False ) <EOL> with cute_testing . RaiseAssertor ( text = '<STR_LIT>' ) : <EOL> partitions ( r , <NUM_LIT:4> , allow_remainder = False ) <EOL> with cute_testing . RaiseAssertor ( text = '<STR_LIT>' ) : <EOL> partitions ( r , <NUM_LIT:5> , allow_remainder = False ) <EOL> with cute_testing . RaiseAssertor ( text = '<STR_LIT>' ) : <EOL> partitions ( r , n_partitions = <NUM_LIT:2> , allow_remainder = False ) <EOL> with cute_testing . RaiseAssertor ( text = '<STR_LIT>' ) : <EOL> partitions ( r , n_partitions = <NUM_LIT:4> , allow_remainder = False ) <EOL> with cute_testing . RaiseAssertor ( text = '<STR_LIT>' ) : <EOL> partitions ( r , n_partitions = <NUM_LIT:5> , allow_remainder = False ) <EOL> def test_larger_on_remainder ( ) : <EOL> r = list ( range ( <NUM_LIT:9> ) ) <EOL> assert partitions ( r , <NUM_LIT:1> , larger_on_remainder = True ) == partitions ( r , n_partitions = <NUM_LIT:9> , larger_on_remainder = True ) == [ [ <NUM_LIT:0> ] , [ <NUM_LIT:1> ] , [ <NUM_LIT:2> ] , [ <NUM_LIT:3> ] , [ <NUM_LIT:4> ] , [ <NUM_LIT:5> ] , [ <NUM_LIT:6> ] , [ <NUM_LIT:7> ] , [ <NUM_LIT:8> ] ] <EOL> assert partitions ( r , <NUM_LIT:2> , larger_on_remainder = True ) == partitions ( r , n_partitions = <NUM_LIT:4> , larger_on_remainder = True ) == partitions ( r , n_partitions = <NUM_LIT:4> , larger_on_remainder = True , <EOL> fill_value = '<STR_LIT>' ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> ] , [ <NUM_LIT:2> , <NUM_LIT:3> ] , [ <NUM_LIT:4> , <NUM_LIT:5> ] , [ <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ] ] <EOL> assert partitions ( r , <NUM_LIT:3> , larger_on_remainder = True ) == partitions ( r , n_partitions = <NUM_LIT:3> , larger_on_remainder = True , <EOL> fill_value = '<STR_LIT>' ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] , [ <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ] ] <EOL> assert partitions ( tuple ( r ) , <NUM_LIT:4> , larger_on_remainder = True ) == [ ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) , ( <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ) ] <EOL> assert partitions ( tuple ( r ) , n_partitions = <NUM_LIT:3> , larger_on_remainder = True ) == [ ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ) , ( <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ) ] <EOL> assert partitions ( [ <NUM_LIT:1> ] , <NUM_LIT:1> , larger_on_remainder = True ) == partitions ( [ <NUM_LIT:1> ] , <NUM_LIT:2> , larger_on_remainder = True ) == partitions ( [ <NUM_LIT:1> ] , n_partitions = <NUM_LIT:1> , larger_on_remainder = True ) == partitions ( [ <NUM_LIT:1> ] , <NUM_LIT:3> , larger_on_remainder = True ) == partitions ( [ <NUM_LIT:1> ] , <NUM_LIT:4> , larger_on_remainder = True ) == partitions ( [ <NUM_LIT:1> ] , <NUM_LIT:1000> , larger_on_remainder = True ) == partitions ( [ <NUM_LIT:1> ] , <NUM_LIT:1000> , larger_on_remainder = True , fill_value = '<STR_LIT>' ) == [ [ <NUM_LIT:1> ] ] <EOL> with cute_testing . RaiseAssertor ( text = '<STR_LIT>' ) : <EOL> partitions ( [ <NUM_LIT:1> ] , <NUM_LIT:1000> , larger_on_remainder = True , allow_remainder = False , <EOL> fill_value = '<STR_LIT>' ) <EOL> def test_fill_value ( ) : <EOL> '''<STR_LIT>''' <EOL> r = list ( range ( <NUM_LIT:5> ) ) <EOL> assert partitions ( r , <NUM_LIT:3> ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:3> , <NUM_LIT:4> ] ] <EOL> assert partitions ( r , <NUM_LIT:3> , fill_value = None ) == [ [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:3> , <NUM_LIT:4> , None ] ] <EOL> assert partitions ( [ ] , <NUM_LIT:3> , fill_value = None ) == [ ] </s>
