original_docstring: 
      Convert the im array with shape shape to a PGM string
      writes it into the stream_out stream.
      
docstring: Convert the im array with shape shape to a PGM string
  writes it into the stream_out stream.
docstring_tokens: Convert the im array with shape shape to a PGM string writes it into the stream_out stream .
code: def nparray_to_pgm(stream_out, im, shape):
      """
      Convert the im array with shape shape to a PGM string
      writes it into the stream_out stream.
      """
      stream_out.write("P5\n")  # P5 is binary grayscale
      stream_out.write("%d %d\n" % (shape[0], shape[1]))  # dimensions
      stream_out.write("255\n")
      if use_numpy_arrays:
          stream_out.write(np.asarray(im, dtype=np.uint8))
      else:
          out = array.array('B')
          out.extend((int(min(255, max(0, x))) for x in im))
          stream_out.write(out)
code_tokens: def nparray_to_pgm ( stream_out , im , shape ) : stream_out . write ( "P5\n" ) stream_out . write ( "%d %d\n" % ( shape [ 0 ] , shape [ 1 ] ) ) stream_out . write ( "255\n" ) if use_numpy_arrays : stream_out . write ( np . asarray ( im , dtype = np . uint8 ) ) else : out = array . array ( 'B' ) out . extend ( ( int ( min ( 255 , max ( 0 , x ) ) ) for x in im ) ) stream_out . write ( out )
short_docstring: Convert the im array with shape shape to a PGM string
  writes it into the stream_out stream.
short_docstring_tokens: Convert the im array with shape shape to a PGM string writes it into the stream_out stream .
comment: """
      Convert the im array with shape shape to a PGM string
      writes it into the stream_out stream.
      """$SEP$# P5 is binary grayscale$SEP$# dimensions