### Question:
Arrays { public static <T> Array<T> section(Array<T> org, List<Range> ranges) throws InvalidRangeException { return org.createView(org.indexFn().section(ranges)); }  static Array<T> factory(DataType dataType, int[] shape, Storage<T> storage); static Array<T> factory(DataType dataType, int[] shape, Object dataArray); static Array<T> factory(DataType dataType, int[] shape); static Array<T> factoryCopy(DataType dataType, int[] shape, List<Array<T>> dataArrays); static Array<T> factoryArrays(DataType dataType, int[] shape, List<Array<?>> dataArrays); static Array<T> flip(Array<T> org, int dim); static Array<T> permute(Array<T> org, int[] dims); static Array<T> reshape(Array<T> org, int[] shape); static Array<T> reduce(Array<T> org); static Array<T> reduce(Array<T> org, int dim); static Array<T> section(Array<T> org, List<Range> ranges); static Array<T> slice(Array<T> org, int dim, int value); static Array<T> transpose(Array<T> org, int dim1, int dim2); static long computeSize(int[] shape); static boolean isVariableLength(int[] shape); static int[] removeVlen(int[] shape);  }### Answer:
@Test public void testSection() throws InvalidRangeException { ArrayList<Range> ranges = new ArrayList<>(); ranges.add(null); ranges.add(null); ranges.add(new Range(2)); Array<Double> pArray = Arrays.section(array, ranges); assertThat(pArray.getShape()).isEqualTo(new int[] {1, 2, 2}); assertThat(pArray.get(0, 0, 0)).isEqualTo(1); assertThat(pArray.get(0, 0, 1)).isEqualTo(2); assertThat(pArray.get(0, 1, 0)).isEqualTo(4); assertThat(pArray.get(0, 1, 1)).isEqualTo(5); try { assertThat(pArray.get(0, 0, 2)).isEqualTo(3); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalArgumentException.class); } double total = 0.0; for (double val : pArray) { total += val; } assertThat(total).isEqualTo(12.0); Array<Double> rArray = Arrays.reduce(pArray); assertThat(rArray.getShape()).isEqualTo(new int[] {2, 2}); assertThat(rArray.get(0, 0)).isEqualTo(1); assertThat(rArray.get(0, 1)).isEqualTo(2); assertThat(rArray.get(1, 0)).isEqualTo(4); assertThat(rArray.get(1, 1)).isEqualTo(5); try { assertThat(rArray.get(0, 2)).isEqualTo(3); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalArgumentException.class); } }