@Test public void testConvert() { ucar.ma2.Array ma2 = ArraysConvert.convertFromArray(array); assertThat(ma2.getDataType()).isEqualTo(array.getDataType()); assertThat(ma2.getShape()).isEqualTo(array.getShape()); assertThat(ma2.getSize()).isEqualTo(array.length()); Iterator<Double> iter = array.iterator(); IndexIterator indexIter = ma2.getIndexIterator(); while (indexIter.hasNext() && iter.hasNext()) { assertThat(indexIter.getDoubleNext()).isEqualTo(iter.next()); } }
public static ucar.ma2.Array convertFromArray(Array<?> from) { Preconditions.checkArgument(!(from instanceof ArrayVlen), "Cant convert Vlen"); Preconditions.checkArgument(from.dataType != DataType.OPAQUE, "Cant convert Opaque"); Preconditions.checkArgument(from.dataType != DataType.SEQUENCE, "Cant convert Sequence"); if (from.dataType == DataType.STRUCTURE) { return convertStructureDataArray(from); } ucar.ma2.Array values = ucar.ma2.Array.factory(from.getDataType(), from.getShape()); int count = 0; for (Object val : from) { values.setObject(count++, val); } return values; }
ArraysConvert { public static ucar.ma2.Array convertFromArray(Array<?> from) { Preconditions.checkArgument(!(from instanceof ArrayVlen), "Cant convert Vlen"); Preconditions.checkArgument(from.dataType != DataType.OPAQUE, "Cant convert Opaque"); Preconditions.checkArgument(from.dataType != DataType.SEQUENCE, "Cant convert Sequence"); if (from.dataType == DataType.STRUCTURE) { return convertStructureDataArray(from); } ucar.ma2.Array values = ucar.ma2.Array.factory(from.getDataType(), from.getShape()); int count = 0; for (Object val : from) { values.setObject(count++, val); } return values; } }
ArraysConvert { public static ucar.ma2.Array convertFromArray(Array<?> from) { Preconditions.checkArgument(!(from instanceof ArrayVlen), "Cant convert Vlen"); Preconditions.checkArgument(from.dataType != DataType.OPAQUE, "Cant convert Opaque"); Preconditions.checkArgument(from.dataType != DataType.SEQUENCE, "Cant convert Sequence"); if (from.dataType == DataType.STRUCTURE) { return convertStructureDataArray(from); } ucar.ma2.Array values = ucar.ma2.Array.factory(from.getDataType(), from.getShape()); int count = 0; for (Object val : from) { values.setObject(count++, val); } return values; }  }
ArraysConvert { public static ucar.ma2.Array convertFromArray(Array<?> from) { Preconditions.checkArgument(!(from instanceof ArrayVlen), "Cant convert Vlen"); Preconditions.checkArgument(from.dataType != DataType.OPAQUE, "Cant convert Opaque"); Preconditions.checkArgument(from.dataType != DataType.SEQUENCE, "Cant convert Sequence"); if (from.dataType == DataType.STRUCTURE) { return convertStructureDataArray(from); } ucar.ma2.Array values = ucar.ma2.Array.factory(from.getDataType(), from.getShape()); int count = 0; for (Object val : from) { values.setObject(count++, val); } return values; }  static Array<?> convertToArray(ucar.ma2.Array from); static ucar.ma2.Array convertFromArray(Array<?> from); }
ArraysConvert { public static ucar.ma2.Array convertFromArray(Array<?> from) { Preconditions.checkArgument(!(from instanceof ArrayVlen), "Cant convert Vlen"); Preconditions.checkArgument(from.dataType != DataType.OPAQUE, "Cant convert Opaque"); Preconditions.checkArgument(from.dataType != DataType.SEQUENCE, "Cant convert Sequence"); if (from.dataType == DataType.STRUCTURE) { return convertStructureDataArray(from); } ucar.ma2.Array values = ucar.ma2.Array.factory(from.getDataType(), from.getShape()); int count = 0; for (Object val : from) { values.setObject(count++, val); } return values; }  static Array<?> convertToArray(ucar.ma2.Array from); static ucar.ma2.Array convertFromArray(Array<?> from);  }