/**
   * Create a dataset from an object which could be a Java list, array (of arrays...) or Number.
   * Ragged sequences or arrays are padded with zeros.
   *
   * @param obj
   * @return dataset with contents given by input
   */
  public static StringDatasetBase createFromObject(final Object obj) {
    StringDatasetBase result = new StringDatasetBase();

    result.shape = getShapeFromObject(obj);
    result.size = calcSize(result.shape);

    try {
      result.odata = result.data = createArray(result.size);
    } catch (Throwable t) {
      logger.error("Could not create a dataset of shape {}", Arrays.toString(result.shape), t);
      throw t;
    }

    int[] pos = new int[result.shape.length];
    result.fillData(obj, 0, pos);
    return result;
  }