from query_result_document import QueryResultDocument


class QueryResultList:
  def __init__(self, query, result_documents = []):
    self.result_documents = result_documents # Guaranteed to be in rank order
    self.query = query

  def add( self, rank, document ):
    self.result_documents.insert( int(rank) - 1, QueryResultDocument( self, rank, document ) )

  def results_up_to_rank( self, rank ):
    return self.result_documents[:int(rank)]

from query_result_document import QueryResultDocument


class QueryResultList:
  def __init__(self, query):
    self.result_documents = [] # Guaranteed to be in rank order
    self.query = query

  def add( self, rank, document ):
    self.result_documents.insert( int(rank) - 1, QueryResultDocument( self, rank, document ) )

  def results_up_to_rank( self, rank ):
    return self.result_documents[:int(rank)]

  def length( self ):
    return len( self.result_documents )

Fix query result list having an empty list default parameter (default parameters get initialized only once!)
Fix query result list having an empty list default parameter (default parameters get initialized only once!)

  from query_result_document import QueryResultDocument
  
  
  class QueryResultList:
-   def __init__(self, query, result_documents = []):
+   def __init__(self, query):
-     self.result_documents = result_documents # Guaranteed to be in rank order
+     self.result_documents = [] # Guaranteed to be in rank order
      self.query = query
  
    def add( self, rank, document ):
      self.result_documents.insert( int(rank) - 1, QueryResultDocument( self, rank, document ) )
  
    def results_up_to_rank( self, rank ):
      return self.result_documents[:int(rank)]
  
+   def length( self ):
+     return len( self.result_documents )
+ 
Fix query result list having an empty list default parameter (default parameters get initialized only once!)
## Code Before:
from query_result_document import QueryResultDocument


class QueryResultList:
  def __init__(self, query, result_documents = []):
    self.result_documents = result_documents # Guaranteed to be in rank order
    self.query = query

  def add( self, rank, document ):
    self.result_documents.insert( int(rank) - 1, QueryResultDocument( self, rank, document ) )

  def results_up_to_rank( self, rank ):
    return self.result_documents[:int(rank)]

## Instruction:
Fix query result list having an empty list default parameter (default parameters get initialized only once!)
## Code After:
from query_result_document import QueryResultDocument


class QueryResultList:
  def __init__(self, query):
    self.result_documents = [] # Guaranteed to be in rank order
    self.query = query

  def add( self, rank, document ):
    self.result_documents.insert( int(rank) - 1, QueryResultDocument( self, rank, document ) )

  def results_up_to_rank( self, rank ):
    return self.result_documents[:int(rank)]

  def length( self ):
    return len( self.result_documents )
