code: def to_scales(val):
      
      res = []
      for i in val:
          if len(i) == 3:
              res.append((i[0], type(i[2])))
          else:
              try:
                  res.append((i[0], i[3].dtype, i[2]))
              except AttributeError:
                  res.append((i[0], type(i[3]), i[2]))
  
      dtype = np.dtype(res)
  
      scales = np.zeros((1, ), dtype=dtype)
  
      for i in val:
          try:
              scales[i[0]] = i[-1]
          except ValueError:
              scales[i[0]] = np.repeat(np.array(i[-1]), i[2][1]).reshape(i[2])
  
      return scales
docs: Parse *val* to return an array of scale factors.