Skip to content

Commit

Permalink
Fix expanding dataset in file bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterC-DLS committed Oct 7, 2016
1 parent e398fdd commit 962a960
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 962a960

Please sign in to comment.