Skip to content

Commit 011ed19

Browse files
author
haileyajohnson
authored
handle get coord bounds for an axis with size=1 (#1030)
* handle get coord bounds for an axis with size=1 * fix comment
1 parent 2046707 commit 011ed19

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

cdm/core/src/main/java/ucar/nc2/dataset/CoordinateAxis1D.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,18 @@ private boolean makeBoundsFromAux() {
972972
private void makeEdges() {
973973
int size = (int) getSize();
974974
edge = new double[size + 1];
975-
if (size < 1)
975+
if (size < 1) {
976976
return;
977-
for (int i = 1; i < size; i++)
977+
}
978+
if (size == 1) {
979+
// if the axis size is one, edges are the same as the coord
980+
edge[0] = coords[0];
981+
edge[1] = coords[0];
982+
return;
983+
}
984+
for (int i = 1; i < size; i++) {
978985
edge[i] = (coords[i - 1] + coords[i]) / 2;
986+
}
979987
edge[0] = coords[0] - (edge[1] - coords[0]);
980988
edge[size] = coords[size - 1] + (coords[size - 1] - edge[size - 1]);
981989
isContiguous = true;

0 commit comments

Comments
 (0)