Skip to content

Commit

Permalink
ZarrArray: add a getDimensionSeparator method
Browse files Browse the repository at this point in the history
This allows the array's `DimensionSeparator` to be easily checked.

The corresponding test is also updated to use the new getter instead of
reflective access.
  • Loading branch information
melissalinkert committed Apr 28, 2022
1 parent b4eed70 commit 3a4e7dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/bc/zarr/ZarrArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ public ByteOrder getByteOrder() {
return _byteOrder;
}

public DimensionSeparator getDimensionSeparator() {
return _separator;
}

public void write(Number value) throws IOException, InvalidRangeException {
final int[] shape = getShape();
final int[] offset = new int[shape.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ public void tearDown() throws Exception {
@Test
public void openOldStyleZarrArrayAndDetectDimensionSeparator() throws IOException, NoSuchFieldException, IllegalAccessException {
final ZarrArray array = ZarrArray.open(arrayPath);
final Object separator = TestUtils.getPrivateFieldObject(array, "_separator");
assertThat(separator)
.isNotNull()
.isInstanceOf(DimensionSeparator.class);
DimensionSeparator sep = (DimensionSeparator) separator;
DimensionSeparator sep = array.getDimensionSeparator();
assertThat(sep).isNotNull();
assertThat(sep.getSeparatorChar()).isEqualTo("/");
}

Expand All @@ -104,4 +101,4 @@ private void prepareOldStyleArrayHeaderFile(FileSystemStore store) throws IOExce
final OutputStream os = store.getOutputStream(".zarray");
TestUtils.deleteLineContaining("dimension_separator", is, os);
}
}
}

0 comments on commit 3a4e7dd

Please sign in to comment.