Class Java2NumpyCopy

java.lang.Object
com.illumon.integrations.numpy.Java2NumpyCopy

public class Java2NumpyCopy extends Object
Utilities for copying data into numpy arrays.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Type of table.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    copyImageRand(Table t, double[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
    Copies a random selection of image rows into a flattened array.
    static void
    copyImageRand(Table t, float[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
    Copies a random selection of image rows into a flattened array.
    static void
    copyImageRand(Table t, int[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
    Copies a random selection of image rows into a flattened array.
    static void
    copyImageRand(Table t, int nRow, int width, int height, boolean resize, boolean color, long[] rows, com.illumon.integrations.numpy.Java2NumpyCopy.IntValSetter setter)
    Copies a random selection of image rows into a flattened array.
    static void
    copyImageRand(Table t, long[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
    Copies a random selection of image rows into a flattened array.
    static void
    copyImageRand(Table t, short[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
    Copies a random selection of image rows into a flattened array.
    static void
    copyImageSlice(Table t, long rowStart, double[] data, int nRow, int width, int height, boolean resize, boolean color)
    Copies a slice of image rows into a flattened array.
    static void
    copyImageSlice(Table t, long rowStart, float[] data, int nRow, int width, int height, boolean resize, boolean color)
    Copies a slice of image rows into a flattened array.
    static void
    copyImageSlice(Table t, long rowStart, int[] data, int nRow, int width, int height, boolean resize, boolean color)
    Copies a slice of image rows into a flattened array.
    static void
    copyImageSlice(Table t, long rowStart, int nRow, int width, int height, boolean resize, boolean color, com.illumon.integrations.numpy.Java2NumpyCopy.IntValSetter setter)
    Copies a slice of image rows into a flattened array.
    static void
    copyImageSlice(Table t, long rowStart, long[] data, int nRow, int width, int height, boolean resize, boolean color)
    Copies a slice of image rows into a flattened array.
    static void
    copyImageSlice(Table t, long rowStart, short[] data, int nRow, int width, int height, boolean resize, boolean color)
    Copies a slice of image rows into a flattened array.
    static void
    copyRand(Table t, byte[] data, int nRow, int nCol, long[] rows)
    Casts data to the desired type and copies a random selection of rows into a flattened 2D array.
    static void
    copyRand(Table t, double[] data, int nRow, int nCol, long[] rows)
    Casts data to the desired type and copies a random selection of rows into a flattened 2D array.
    static void
    copyRand(Table t, float[] data, int nRow, int nCol, long[] rows)
    Casts data to the desired type and copies a random selection of rows into a flattened 2D array.
    static void
    copyRand(Table t, int[] data, int nRow, int nCol, long[] rows)
    Casts data to the desired type and copies a random selection of rows into a flattened 2D array.
    static void
    copyRand(Table t, int nRow, int nCol, long[] rows, Class type, String cast, com.illumon.integrations.numpy.Java2NumpyCopy.CopySetter setter)
    Casts data to the desired type and copies a random selection of rows into a flattened 2D array.
    static void
    copyRand(Table t, long[] data, int nRow, int nCol, long[] rows)
    Casts data to the desired type and copies a random selection of rows into a flattened 2D array.
    static void
    copyRand(Table t, short[] data, int nRow, int nCol, long[] rows)
    Casts data to the desired type and copies a random selection of rows into a flattened 2D array.
    static void
    copySlice(Table t, long rowStart, byte[] data, int nRow, int nCol)
    Casts data to the desired type and copies a slice of rows into a flattened 2D array.
    static void
    copySlice(Table t, long rowStart, double[] data, int nRow, int nCol)
    Casts data to the desired type and copies a slice of rows into a flattened 2D array.
    static void
    copySlice(Table t, long rowStart, float[] data, int nRow, int nCol)
    Casts data to the desired type and copies a slice of rows into a flattened 2D array.
    static void
    copySlice(Table t, long rowStart, int[] data, int nRow, int nCol)
    Casts data to the desired type and copies a slice of rows into a flattened 2D array.
    static void
    copySlice(Table t, long rowStart, long[] data, int nRow, int nCol)
    Casts data to the desired type and copies a slice of rows into a flattened 2D array.
    static void
    copySlice(Table t, long rowStart, short[] data, int nRow, int nCol)
    Casts data to the desired type and copies a slice of rows into a flattened 2D array.
    static long[]
    randRows(int nRow, long tSize)
    Generates a list of random table rows.
    Determines the type of table.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Java2NumpyCopy

      public Java2NumpyCopy()
  • Method Details

    • tableType

      public static Java2NumpyCopy.TableType tableType(Table t)
      Determines the type of table.
      Parameters:
      t - table.
      Returns:
      table type.
    • copySlice

      public static void copySlice(Table t, long rowStart, double[] data, int nRow, int nCol)
      Casts data to the desired type and copies a slice of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
    • copySlice

      public static void copySlice(Table t, long rowStart, float[] data, int nRow, int nCol)
      Casts data to the desired type and copies a slice of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
    • copySlice

      public static void copySlice(Table t, long rowStart, byte[] data, int nRow, int nCol)
      Casts data to the desired type and copies a slice of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
    • copySlice

      public static void copySlice(Table t, long rowStart, short[] data, int nRow, int nCol)
      Casts data to the desired type and copies a slice of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
    • copySlice

      public static void copySlice(Table t, long rowStart, int[] data, int nRow, int nCol)
      Casts data to the desired type and copies a slice of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
    • copySlice

      public static void copySlice(Table t, long rowStart, long[] data, int nRow, int nCol)
      Casts data to the desired type and copies a slice of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
    • randRows

      public static long[] randRows(int nRow, long tSize)
      Generates a list of random table rows.
      Parameters:
      nRow - number of random rows.
      tSize - table size.
      Returns:
      indices of random table rows.
    • copyRand

      public static void copyRand(Table t, int nRow, int nCol, long[] rows, Class type, String cast, com.illumon.integrations.numpy.Java2NumpyCopy.CopySetter setter)
      Casts data to the desired type and copies a random selection of rows into a flattened 2D array. This is useful for copying table data directly into arrays.
      Parameters:
      t - table to copy data from
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
      type - type of output data
      cast - string used to cast to the output type
      setter - setter used to assign data
    • copyRand

      public static void copyRand(Table t, double[] data, int nRow, int nCol, long[] rows)
      Casts data to the desired type and copies a random selection of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyRand

      public static void copyRand(Table t, float[] data, int nRow, int nCol, long[] rows)
      Casts data to the desired type and copies a random selection of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyRand

      public static void copyRand(Table t, byte[] data, int nRow, int nCol, long[] rows)
      Casts data to the desired type and copies a random selection of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyRand

      public static void copyRand(Table t, short[] data, int nRow, int nCol, long[] rows)
      Casts data to the desired type and copies a random selection of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyRand

      public static void copyRand(Table t, int[] data, int nRow, int nCol, long[] rows)
      Casts data to the desired type and copies a random selection of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyRand

      public static void copyRand(Table t, long[] data, int nRow, int nCol, long[] rows)
      Casts data to the desired type and copies a random selection of rows into a flattened 2D array. This is useful for copying table data directly into numpy arrays.
      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      nCol - number of table columns; also the number of columns in data.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyImageSlice

      public static void copyImageSlice(Table t, long rowStart, int nRow, int width, int height, boolean resize, boolean color, com.illumon.integrations.numpy.Java2NumpyCopy.IntValSetter setter)
      Copies a slice of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table images directly into arrays.

      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
      setter - setter used to assign data
    • copyImageSlice

      public static void copyImageSlice(Table t, long rowStart, short[] data, int nRow, int width, int height, boolean resize, boolean color)
      Copies a slice of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table images directly into numpy arrays.

      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
    • copyImageSlice

      public static void copyImageSlice(Table t, long rowStart, int[] data, int nRow, int width, int height, boolean resize, boolean color)
      Copies a slice of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table images directly into numpy arrays.

      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
    • copyImageSlice

      public static void copyImageSlice(Table t, long rowStart, long[] data, int nRow, int width, int height, boolean resize, boolean color)
      Copies a slice of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table images directly into numpy arrays.

      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
    • copyImageSlice

      public static void copyImageSlice(Table t, long rowStart, float[] data, int nRow, int width, int height, boolean resize, boolean color)
      Copies a slice of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table images directly into numpy arrays.

      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
    • copyImageSlice

      public static void copyImageSlice(Table t, long rowStart, double[] data, int nRow, int width, int height, boolean resize, boolean color)
      Copies a slice of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table images directly into numpy arrays.

      Parameters:
      t - table to copy data from
      rowStart - first row of data to copy
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
    • copyImageRand

      public static void copyImageRand(Table t, int nRow, int width, int height, boolean resize, boolean color, long[] rows, com.illumon.integrations.numpy.Java2NumpyCopy.IntValSetter setter)
      Copies a random selection of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table data directly into arrays.

      Parameters:
      t - table to copy data from
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
      setter - setter used to assign data
    • copyImageRand

      public static void copyImageRand(Table t, short[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
      Copies a random selection of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table data directly into numpy arrays.

      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyImageRand

      public static void copyImageRand(Table t, int[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
      Copies a random selection of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table data directly into numpy arrays.

      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyImageRand

      public static void copyImageRand(Table t, long[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
      Copies a random selection of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table data directly into numpy arrays.

      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyImageRand

      public static void copyImageRand(Table t, float[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
      Copies a random selection of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table data directly into numpy arrays.

      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
      rows - indices of rows to copy. Null causes rows to be randomly generated.
    • copyImageRand

      public static void copyImageRand(Table t, double[] data, int nRow, int width, int height, boolean resize, boolean color, long[] rows)
      Copies a random selection of image rows into a flattened array. For color, the array is indexed as [row, height, width, channel], where channel is red, green, blue. For grayscale, the array is indexed as [row, height, width].

      This is useful for copying table data directly into numpy arrays.

      Parameters:
      t - table to copy data from
      data - array to copy data into
      nRow - number of rows to copy; also the number of rows in data.
      width - width of the image
      height - height of the image
      resize - true to resize the image to the target size; false otherwise.
      color - true to return a color image; false to return a gray-scale image.
      rows - indices of rows to copy. Null causes rows to be randomly generated.