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
    --- | ---
    `SliceND` | `clone()` Creates a deep copy of the SliceND.
    `Slice[]` | `convertToSlice()` Converts to a slice array all the Slices of the SliceND.
    `static SliceND` | `createSlice(ILazyDataset data, int[] start, int[] stop)` Creats SliceND from dataset.
    `static SliceND` | `createSlice(ILazyDataset data, int[] start, int[] stop, int[] step)` Creating SliceND from dataset.
    `SliceND` | `flip()` Flips 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)` Flips 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()` Returns an array of maximals shapes
    `int[]` | `getShape()` Returns an array of resulting shapes (this can change if the start, stop, step arrays are changed).
    `int[]` | `getSourceShape()` Returns an array of shapes of the source Dataset (this can change for dynamic Datasets).
    `int[]` | `getStart()` Returns an array of the starts values.
    `int[]` | `getStep()` Returns an array of the steps values.
    `int[]` | `getStop()` Returns an array of stops values.
    `boolean` | `isAll()` Returns `true` if all of originals shapes are covered by positive steps slices, else `false`.
    `boolean` | `isExpanded()` Returns `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()

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

    - #### getMaxShape

          public int[] getMaxShape()

      Returns an array of maximals shapes
      Returns:
        maximum shape

    - #### isExpanded

          public boolean isExpanded()

      Returns `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()

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

    - #### getStart

          public int[] getStart()

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

    - #### getStop

          public int[] getStop()

      Returns an array of stops values.

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

      Returns:
        stop values

    - #### getStep

          public int[] getStep()

      Returns 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()

      Returns `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)

      Flips 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()

      Flips 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()

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

    - #### clone

          public SliceND clone()

      Creates 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)

      Creats 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)

      Creating 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

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