original_docstring: Filters the submodels available for the field in the time-series
      model according to the criteria provided in the prediction input data
      for the field.
  
      
docstring: Filters the submodels available for the field in the time-series
  model according to the criteria provided in the prediction input data
  for the field.
docstring_tokens: Filters the submodels available for the field in the time - series model according to the criteria provided in the prediction input data for the field .
code: def filter_submodels(submodels, filter_info):
      """Filters the submodels available for the field in the time-series
      model according to the criteria provided in the prediction input data
      for the field.
  
      """
      field_submodels = []
      submodel_names = []
      # filtering by indices and/or names
      indices = filter_info.get(SUBMODEL_KEYS[0], [])
      names = filter_info.get(SUBMODEL_KEYS[1], [])
  
      if indices:
          # adding all submodels by index if they are not also in the names
          # list
          field_submodels = [submodel for index, submodel in \
              enumerate(submodels) if index in indices]
  
      # union with filtered by names
      if names:
          pattern = r'|'.join(names)
          # only adding the submodels if they have not been included by using
          # indices
          submodel_names = [submodel["name"] for submodel in field_submodels]
          named_submodels = [submodel for submodel in submodels \
              if re.search(pattern, submodel["name"]) is not None and \
              submodel["name"] not in submodel_names]
          field_submodels.extend(named_submodels)
  
      if not indices and not names:
          field_submodels.extend(submodels)
  
      # filtering the resulting set by criterion and limit
      criterion = filter_info.get(SUBMODEL_KEYS[2])
      if criterion is not None:
          field_submodels = sorted(field_submodels,
                                   key=lambda x: x.get(criterion, float('inf')))
          limit = filter_info.get(SUBMODEL_KEYS[3])
          if limit is not None:
              field_submodels = field_submodels[0: limit]
      return field_submodels
code_tokens: def filter_submodels ( submodels , filter_info ) : field_submodels = [ ] submodel_names = [ ] indices = filter_info . get ( SUBMODEL_KEYS [ 0 ] , [ ] ) names = filter_info . get ( SUBMODEL_KEYS [ 1 ] , [ ] ) if indices : field_submodels = [ submodel for index , submodel in enumerate ( submodels ) if index in indices ] if names : pattern = r'|' . join ( names ) submodel_names = [ submodel [ "name" ] for submodel in field_submodels ] named_submodels = [ submodel for submodel in submodels if re . search ( pattern , submodel [ "name" ] ) is not None and submodel [ "name" ] not in submodel_names ] field_submodels . extend ( named_submodels ) if not indices and not names : field_submodels . extend ( submodels ) criterion = filter_info . get ( SUBMODEL_KEYS [ 2 ] ) if criterion is not None : field_submodels = sorted ( field_submodels , key = lambda x : x . get ( criterion , float ( 'inf' ) ) ) limit = filter_info . get ( SUBMODEL_KEYS [ 3 ] ) if limit is not None : field_submodels = field_submodels [ 0 : limit ] return field_submodels
short_docstring: Filters the submodels available for the field in the time-series
  model according to the criteria provided in the prediction input data
  for the field.
short_docstring_tokens: Filters the submodels available for the field in the time - series model according to the criteria provided in the prediction input data for the field .
comment: """Filters the submodels available for the field in the time-series
      model according to the criteria provided in the prediction input data
      for the field.
  
      """$SEP$# filtering by indices and/or names$SEP$# adding all submodels by index if they are not also in the names$SEP$# list$SEP$# union with filtered by names$SEP$# only adding the submodels if they have not been included by using$SEP$# indices$SEP$# filtering the resulting set by criterion and limit