(cmd_list, categorical=False)
return command + arguments
Converts the given command (given as a list) into a vector.
Converts the given command (given as a list) into a vector.
Converts the given command ( given as a list ) into a vector .
def cmd_to_vector(cmd_list, categorical=False):
  """Converts the given command (given as a list) into a vector."""
  # For description of how this conversion happens, see
  # path_to_vector docstring.
  cmd = cmd_list[0]
  args = cmd_list[1:]

  if not categorical:
    # integer, for MSE
    command = [float(CMD_MAPPING[cmd])]
  else:
    # one hot + 1 dim for EOS.
    command = [0.0] * (len(CMDS_LIST) + 1)
    command[CMD_MAPPING[cmd] + 1] = 1.0

  arguments = [0.0] * 10
  if cmd in 'hH':
    arguments[8] = float(args[0])  # x
  elif cmd in 'vV':
    arguments[9] = float(args[0])  # y
  elif cmd in 'mMlLtT':
    arguments[8] = float(args[0])  # x
    arguments[9] = float(args[1])  # y
  elif cmd in 'sSqQ':
    arguments[6] = float(args[0])  # x2
    arguments[7] = float(args[1])  # y2
    arguments[8] = float(args[2])  # x
    arguments[9] = float(args[3])  # y
  elif cmd in 'cC':
    arguments[4] = float(args[0])  # x1
    arguments[5] = float(args[1])  # y1
    arguments[6] = float(args[2])  # x2
    arguments[7] = float(args[3])  # y2
    arguments[8] = float(args[4])  # x
    arguments[9] = float(args[5])  # y
  elif cmd in 'aA':
    arguments[0] = float(args[0])  # rx
    arguments[1] = float(args[1])  # ry
    # we skip x-axis-rotation
    arguments[2] = float(args[3])  # large-arc-flag
    arguments[3] = float(args[4])  # sweep-flag
    # a does not have x1, y1, x2, y2 args
    arguments[8] = float(args[5])  # x
    arguments[9] = float(args[6])  # y

  return command + arguments
def cmd_to_vector ( cmd_list , categorical = False ) : # For description of how this conversion happens, see # path_to_vector docstring. cmd = cmd_list [ 0 ] args = cmd_list [ 1 : ] if not categorical : # integer, for MSE command = [ float ( CMD_MAPPING [ cmd ] ) ] else : # one hot + 1 dim for EOS. command = [ 0.0 ] * ( len ( CMDS_LIST ) + 1 ) command [ CMD_MAPPING [ cmd ] + 1 ] = 1.0 arguments = [ 0.0 ] * 10 if cmd in 'hH' : arguments [ 8 ] = float ( args [ 0 ] ) # x elif cmd in 'vV' : arguments [ 9 ] = float ( args [ 0 ] ) # y elif cmd in 'mMlLtT' : arguments [ 8 ] = float ( args [ 0 ] ) # x arguments [ 9 ] = float ( args [ 1 ] ) # y elif cmd in 'sSqQ' : arguments [ 6 ] = float ( args [ 0 ] ) # x2 arguments [ 7 ] = float ( args [ 1 ] ) # y2 arguments [ 8 ] = float ( args [ 2 ] ) # x arguments [ 9 ] = float ( args [ 3 ] ) # y elif cmd in 'cC' : arguments [ 4 ] = float ( args [ 0 ] ) # x1 arguments [ 5 ] = float ( args [ 1 ] ) # y1 arguments [ 6 ] = float ( args [ 2 ] ) # x2 arguments [ 7 ] = float ( args [ 3 ] ) # y2 arguments [ 8 ] = float ( args [ 4 ] ) # x arguments [ 9 ] = float ( args [ 5 ] ) # y elif cmd in 'aA' : arguments [ 0 ] = float ( args [ 0 ] ) # rx arguments [ 1 ] = float ( args [ 1 ] ) # ry # we skip x-axis-rotation arguments [ 2 ] = float ( args [ 3 ] ) # large-arc-flag arguments [ 3 ] = float ( args [ 4 ] ) # sweep-flag # a does not have x1, y1, x2, y2 args arguments [ 8 ] = float ( args [ 5 ] ) # x arguments [ 9 ] = float ( args [ 6 ] ) # y return command + arguments