diff --git a/org.eclipse.dawnsci.hdf5/src/org/eclipse/dawnsci/hdf5/HDF5Utils.java b/org.eclipse.dawnsci.hdf5/src/org/eclipse/dawnsci/hdf5/HDF5Utils.java index b46db5f5..f35af977 100644 --- a/org.eclipse.dawnsci.hdf5/src/org/eclipse/dawnsci/hdf5/HDF5Utils.java +++ b/org.eclipse.dawnsci.hdf5/src/org/eclipse/dawnsci/hdf5/HDF5Utils.java @@ -1248,7 +1248,7 @@ public static void writeDatasetSlice(long fileID, String dataPath, SliceND slice newShape = toLongArray(slice.getSourceShape()); } else { long[] mShape = toLongArray(slice.getStop()); - if (isGreaterThan(mShape, dims)) { + if (expandToGreatestShape(mShape, dims)) { newShape = mShape; } } @@ -1341,14 +1341,18 @@ public static void writeDatasetSlice(long fileID, String dataPath, SliceND slice } } - private static boolean isGreaterThan(long[] a, long[] b) { + private static boolean expandToGreatestShape(long[] a, long[] b) { int rank = a.length; + boolean isExpanded = false; for (int i = 0; i < rank; i++) { if (a[i] > b[i]) { - return true; + isExpanded = true; + } else { // ensure shape is maximal + a[i] = b[i]; } } - return false; + + return isExpanded; } /**