def _extend_mode_to_code(mode):
 if (mode == 'nearest'):
  return 0
 elif (mode == 'wrap'):
  return 1
 elif (mode == 'reflect'):
  return 2
 elif (mode == 'mirror'):
  return 3
 elif (mode == 'constant'):
  return 4
 else:
  raise RuntimeError('boundary mode not supported')

def _extend_mode_to_code ( mode ) : if ( mode == 'nearest' ) : return 0 elif ( mode == 'wrap' ) : return 1 elif ( mode == 'reflect' ) : return 2 elif ( mode == 'mirror' ) : return 3 elif ( mode == 'constant' ) : return 4 else : raise RuntimeError ( 'boundary mode not supported' )
convert an extension mode to the corresponding integer code .