org.eclipse.january.dataset

## Class SliceND

- java.lang.Object
- - org.eclipse.january.dataset.SliceND

-     public class SliceND
      extends Object

  The `SliceND` class represents a slice through all dimensions of a multi-dimensional `Dataset`.
  A slice comprises a starting position array, a stopping position array (not included) and a stepping size array.
  If a maximum shape is specified, slicing past the original shape is supported for positive steps otherwise it is ignored. With unlimited dimensions, extending past the original shape is only allowed if the stopping value is given.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SliceND(int[] shape)` Construct a nD Slice for whole of shape.
    `SliceND(int[] shape, int[] start, int[] stop, int[] step)` Construct a nD Slice from parameters, if the maxShape is `null`, it will be set to the maximum shape of the nD Slice, the start will be set to 0, stop is by default equal to the entire size of the set, step is defaultly set to 1.
    `SliceND(int[] shape, int[] maxShape, int[] start, int[] stop, int[] step)` Construct a nD Slice from parameters, if the maxShape is `null`, it will be set to the maximum shape of the nD Slice, the start will be set to 0, stop is by default equal to the entire size of the set, step is defaultly set to 1.
    `SliceND(int[] shape, int[] maxShape, Slice... slice)` Construct a nD Slice from an array of 1D slices, if the maxShape is `null`, it will be set to the maximum shape of the nD Slice.
    `SliceND(int[] shape, Slice... slice)` Construct a nD Slice from an array of 1D slices.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkShapes(int[] dShape, int[] dMShape)` Check slice is compatible with given shapes
    `SliceND` | `clone()` Create a deep copy of the SliceND
    `Slice[]` | `convertToSlice()` Convert to a slice array all the Slices of the SliceND
    `static SliceND` | `createSlice(ILazyDataset data, int[] start, int[] stop)` Create SliceND from dataset
    `static SliceND` | `createSlice(ILazyDataset data, int[] start, int[] stop, int[] step)` Create SliceND from dataset
    `SliceND` | `flip()` Flip slices directions in all dimensions, this means that all slices are beginning at previous end point, steps are in the opposite direction, and finishes are at the previous start point.
    `SliceND` | `flip(int i)` Flip the slice direction in given dimension, this means that slice begins at previous end point, steps in the opposite direction, and finishes at the previous start point.
    `int[]` | `getMaxShape()` Return an array of maximum shape
    `int[]` | `getShape()` Return an array of resulting shapes (this can change if the start, stop, step arrays are changed).
    `int[]` | `getSourceShape()` Return an array of shapes of the source dataset (this can change for dynamic datasets).
    `int[]` | `getStart()` Return an array of the starts values.
    `int[]` | `getStep()` Return an array of the steps values.
    `int[]` | `getStop()` Return an array of stops values.
    `boolean` | `isAll()` Return `true` if all of originals shapes are covered by positive steps slices, else `false`.
    `boolean` | `isExpanded()` Return `true` if the slice makes shape larger, else `false`.
    `void` | `setSlice(int i, Integer start, Integer stop, int step)` Set slice for given dimension, if the start is `null` it will be set to 0, stop is by default equal to the entire size of the set.
    `void` | `setSlice(int i, int start, int stop, int step)` Set slice for given dimension, if the start is `null` it will be set to 0, stop is by default equal to the entire size of the set.
    `void` | `setSlice(int i, Slice slice)` Set slice for given dimension.
    `String` | `toString()` Returns a string construction of the sliceND with the python form.
    `void` | `updateSourceShape(int... shape)` Update source shape (for use with dynamic datasets)

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SliceND

          public SliceND(int[] shape)

      Construct a nD Slice for whole of shape.
      Parameters:
        `shape` - Shape of the dataset, see `ILazyDataset.getShape()`

    - #### SliceND

          public SliceND(int[] shape,
                         Slice... slice)

      Construct a nD Slice from an array of 1D slices.
      Parameters:
        `shape` - Shape of the dataset, see `ILazyDataset.getShape()`
        `slice` - Slice for each dimension of ND slice

    - #### SliceND

          public SliceND(int[] shape,
                         int[] maxShape,
                         Slice... slice)

      Construct a nD Slice from an array of 1D slices, if the maxShape is `null`, it will be set to the maximum shape of the nD Slice.
      Parameters:
        `shape` - Shape of the dataset, see `ILazyDataset.getShape()`
        `maxShape,` - may be `null`
        `slice` - Slice for each dimension of ND slice

    - #### SliceND

          public SliceND(int[] shape,
                         int[] start,
                         int[] stop,
                         int[] step)

      Construct a nD Slice from parameters, if the maxShape is `null`, it will be set to the maximum shape of the nD Slice, the start will be set to 0, stop is by default equal to the entire size of the set, step is defaultly set to 1.
      Parameters:
        `shape` - Shape of the dataset, see `ILazyDataset.getShape()`
        `start` - Array of starts points, may be `null`
        `stop` - Array of stops points, may be `null`
        `step` - Array of steps, may be `null`

    - #### SliceND

          public SliceND(int[] shape,
                         int[] maxShape,
                         int[] start,
                         int[] stop,
                         int[] step)

      Construct a nD Slice from parameters, if the maxShape is `null`, it will be set to the maximum shape of the nD Slice, the start will be set to 0, stop is by default equal to the entire size of the set, step is defaultly set to 1.
      Parameters:
        `shape` - Shape of the dataset, see `ILazyDataset.getShape()`
        `maxShape` - Array of maximals shapes, may be `null`
        `start` - Array of starts points, may be `null`
        `stop` - Array of stops points, may be `null`
        `step` - Array of steps, may be `null`

  - ### Method Detail

    - #### setSlice

          public void setSlice(int i,
                               Integer start,
                               Integer stop,
                               int step)

      Set slice for given dimension, if the start is `null` it will be set to 0, stop is by default equal to the entire size of the set.
      Parameters:
        `i` - dimension
        `start` - Start point, may be `null` to imply start of dimension
        `stop` - Stop point, may be `null` to imply end of dimension
        `step` - Slice step

    - #### setSlice

          public void setSlice(int i,
                               int start,
                               int stop,
                               int step)

      Set slice for given dimension, if the start is `null` it will be set to 0, stop is by default equal to the entire size of the set.
      Parameters:
        `i` - dimension
        `start` - Start point, may be `null` to imply start of dimension
        `stop` - Stop point, may be `null` to imply end of dimension
        `step` - Slice step

    - #### setSlice

          public void setSlice(int i,
                               Slice slice)

      Set slice for given dimension.
      Parameters:
        `i` - Dimension
        `slice` - Slice with wanted properties to set
      Since:
        2.0

    - #### getSourceShape

          public int[] getSourceShape()

      Return an array of shapes of the source dataset (this can change for dynamic datasets).
      Returns:
        shape of source Dataset

    - #### getMaxShape

          public int[] getMaxShape()

      Return an array of maximum shape
      Returns:
        maximum shape

    - #### isExpanded

          public boolean isExpanded()

      Return `true` if the slice makes shape larger, else `false`.
      Returns:
        `true` if slice makes shape larger, `false` in the other case

    - #### getShape

          public int[] getShape()

      Return an array of resulting shapes (this can change if the start, stop, step arrays are changed).
      Returns:
        resulting shape

    - #### getStart

          public int[] getStart()

      Return an array of the starts values.
      Returns:
        start values

    - #### getStop

          public int[] getStop()

      Return an array of stops values.

      Note : stop values are clamped to -1 for negative steps

      Returns:
        stop values

    - #### getStep

          public int[] getStep()

      Return an array of the steps values.
      Returns:
        step values

    - #### updateSourceShape

          public void updateSourceShape(int... shape)

      Update source shape (for use with dynamic datasets)
      Parameters:
        `shape` - source shape
      Since:
        2.3

    - #### isAll

          public boolean isAll()

      Return `true` if all of originals shapes are covered by positive steps slices, else `false`.
      Returns:
        `true` if all of originals shapes is covered by this slice with positive steps, `false` in the other case.

    - #### flip

          public SliceND flip(int i)

      Flip the slice direction in given dimension, this means that slice begins at previous end point, steps in the opposite direction, and finishes at the previous start point.
      Parameters:
        `i` - dimension to flip
      Returns:
        this

    - #### flip

          public SliceND flip()

      Flip slices directions in all dimensions, this means that all slices are beginning at previous end point, steps are in the opposite direction, and finishes are at the previous start point.
      Returns:
        this

    - #### convertToSlice

          public Slice[] convertToSlice()

      Convert to a slice array all the Slices of the SliceND
      Returns:
        a Slice array

    - #### clone

          public SliceND clone()

      Create a deep copy of the SliceND
      Overrides:
        `clone` in class `Object`
      Returns:
        New SliceND with the current SliceND properties

    - #### toString

          public String toString()

      Returns a string construction of the sliceND with the python form.
      Overrides:
        `toString` in class `Object`
      Returns:
        Constructed String of all Slices

    - #### createSlice

          public static SliceND createSlice(ILazyDataset data,
                                            int[] start,
                                            int[] stop)

      Create SliceND from dataset
      Parameters:
        `data` - ILazyDataset to treat
        `start` - Array of starts indexes
        `stop` - Array of stops indexes
      Returns:
        Constructed SliceND

    - #### createSlice

          public static SliceND createSlice(ILazyDataset data,
                                            int[] start,
                                            int[] stop,
                                            int[] step)

      Create SliceND from dataset
      Parameters:
        `data` - ILazyDataset to treat
        `start` - Array of starts indexes
        `stop` - Array of stops indexes
        `step` - Array of steps
      Returns:
        Constructed SliceND

    - #### checkShapes

          public void checkShapes(int[] dShape,
                                  int[] dMShape)

      Check slice is compatible with given shapes
      Parameters:
        `dShape` - dataset shape
        `dMShape` - dataset maximum shape (can be null)
      Since:
        2.3

Copyright © 2014–2022 Eclipse Foundation. All rights reserved.