nodes: 0, module; 1, function_definition; 2, function_name:split; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, expression_statement; 14, if_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, return_statement; 20, identifier:stash_splitter; 21, None; 22, identifier:stash_ranker; 23, None; 24, identifier:state_ranker; 25, None; 26, identifier:limit; 27, integer:8; 28, identifier:from_stash; 29, string; 30, identifier:to_stash; 31, string; 32, comment:"""
          Split a stash of states into two stashes depending on the specified options.
  
          The stash from_stash will be split into two stashes depending on the other options
          passed in. If to_stash is provided, the second stash will be written there.
  
          stash_splitter overrides stash_ranker, which in turn overrides state_ranker.
          If no functions are provided, the states are simply split according to the limit.
  
          The sort done with state_ranker is ascending.
  
          :param stash_splitter:  A function that should take a list of states and return a tuple
                                  of two lists (the two resulting stashes).
          :param stash_ranker:    A function that should take a list of states and return a sorted
                                  list of states. This list will then be split according to "limit".
          :param state_ranker:    An alternative to stash_splitter. States will be sorted with outputs
                                  of this function, which are to be used as a key. The first "limit"
                                  of them will be kept, the rest split off.
          :param limit:           For use with state_ranker. The number of states to keep. Default: 8
          :param from_stash:      The stash to split (default: 'active')
          :param to_stash:        The stash to write to (default: 'stashed')
  
          :returns:               The simulation manager, for chaining.
          :rtype:                 SimulationManager
          """; 33, assignment; 34, comparison_operator:stash_splitter is not None; 35, block; 36, elif_clause; 37, elif_clause; 38, else_clause; 39, assignment; 40, call; 41, call; 42, call; 43, identifier:self; 44, string_content:active; 45, string_content:stashed; 46, identifier:states; 47, call; 48, identifier:stash_splitter; 49, None; 50, expression_statement; 51, comparison_operator:stash_ranker is not None; 52, block; 53, comparison_operator:state_ranker is not None; 54, block; 55, block; 56, pattern_list; 57, call; 58, attribute; 59, argument_list; 60, attribute; 61, argument_list; 62, attribute; 63, argument_list; 64, attribute; 65, argument_list; 66, assignment; 67, identifier:stash_ranker; 68, None; 69, expression_statement; 70, expression_statement; 71, identifier:state_ranker; 72, None; 73, expression_statement; 74, expression_statement; 75, expression_statement; 76, identifier:keep; 77, identifier:split; 78, identifier:map; 79, argument_list; 80, identifier:self; 81, identifier:_clear_states; 82, identifier:from_stash; 83, identifier:self; 84, identifier:_store_states; 85, identifier:from_stash; 86, identifier:keep; 87, identifier:self; 88, identifier:_store_states; 89, identifier:to_stash; 90, identifier:split; 91, identifier:self; 92, identifier:_fetch_states; 93, keyword_argument; 94, pattern_list; 95, call; 96, assignment; 97, assignment; 98, assignment; 99, assignment; 100, assignment; 101, identifier:list; 102, tuple; 103, identifier:stash; 104, identifier:from_stash; 105, identifier:keep; 106, identifier:split; 107, identifier:stash_splitter; 108, argument_list; 109, identifier:ranked_paths; 110, call; 111, pattern_list; 112, expression_list; 113, identifier:ranked_paths; 114, call; 115, pattern_list; 116, expression_list; 117, pattern_list; 118, expression_list; 119, identifier:keep; 120, identifier:split; 121, identifier:states; 122, identifier:stash_ranker; 123, argument_list; 124, identifier:keep; 125, identifier:split; 126, subscript; 127, subscript; 128, identifier:sorted; 129, argument_list; 130, identifier:keep; 131, identifier:split; 132, subscript; 133, subscript; 134, identifier:keep; 135, identifier:split; 136, subscript; 137, subscript; 138, identifier:states; 139, identifier:ranked_paths; 140, slice; 141, identifier:ranked_paths; 142, slice; 143, identifier:states; 144, keyword_argument; 145, identifier:ranked_paths; 146, slice; 147, identifier:ranked_paths; 148, slice; 149, identifier:states; 150, slice; 151, identifier:states; 152, slice; 153, identifier:limit; 154, identifier:limit; 155, identifier:key; 156, identifier:state_ranker; 157, identifier:limit; 158, identifier:limit; 159, identifier:limit; 160, identifier:limit
code: def split(self, stash_splitter=None, stash_ranker=None, state_ranker=None,
                limit=8, from_stash='active', to_stash='stashed'):
          """
          Split a stash of states into two stashes depending on the specified options.
  
          The stash from_stash will be split into two stashes depending on the other options
          passed in. If to_stash is provided, the second stash will be written there.
  
          stash_splitter overrides stash_ranker, which in turn overrides state_ranker.
          If no functions are provided, the states are simply split according to the limit.
  
          The sort done with state_ranker is ascending.
  
          :param stash_splitter:  A function that should take a list of states and return a tuple
                                  of two lists (the two resulting stashes).
          :param stash_ranker:    A function that should take a list of states and return a sorted
                                  list of states. This list will then be split according to "limit".
          :param state_ranker:    An alternative to stash_splitter. States will be sorted with outputs
                                  of this function, which are to be used as a key. The first "limit"
                                  of them will be kept, the rest split off.
          :param limit:           For use with state_ranker. The number of states to keep. Default: 8
          :param from_stash:      The stash to split (default: 'active')
          :param to_stash:        The stash to write to (default: 'stashed')
  
          :returns:               The simulation manager, for chaining.
          :rtype:                 SimulationManager
          """
          states = self._fetch_states(stash=from_stash)
  
          if stash_splitter is not None:
              keep, split = stash_splitter(states)
          elif stash_ranker is not None:
              ranked_paths = stash_ranker(states)
              keep, split = ranked_paths[:limit], ranked_paths[limit:]
          elif state_ranker is not None:
              ranked_paths = sorted(states, key=state_ranker)
              keep, split = ranked_paths[:limit], ranked_paths[limit:]
          else:
              keep, split = states[:limit], states[limit:]
  
          keep, split = map(list, (keep, split))
  
          self._clear_states(from_stash)
          self._store_states(from_stash, keep)
          self._store_states(to_stash, split)
          return self