1111import dev .zarr .zarrjava .utils .MultiArrayUtils ;
1212import dev .zarr .zarrjava .v3 .*;
1313import dev .zarr .zarrjava .v3 .codec .core .TransposeCodec ;
14- import org .junit .jupiter .api .*;
14+ import org .junit .jupiter .api .Assertions ;
15+ import org .junit .jupiter .api .BeforeAll ;
16+ import org .junit .jupiter .api .Disabled ;
17+ import org .junit .jupiter .api .Test ;
1518import org .junit .jupiter .params .ParameterizedTest ;
1619import org .junit .jupiter .params .provider .ValueSource ;
1720
2730import java .util .Map ;
2831import java .util .stream .Stream ;
2932
30- import static org .junit .Assert .assertArrayEquals ;
31- import static org .junit .Assert .assertEquals ;
33+ import static org .junit .Assert .*;
3234
3335public class ZarrTest {
3436
@@ -38,8 +40,6 @@ public class ZarrTest {
3840 final static Path ZARRITA_WRITE_PATH = Paths .get ("src/test/java/dev/zarr/zarrjava/zarrita_write.py" );
3941 final static Path ZARRITA_READ_PATH = Paths .get ("src/test/java/dev/zarr/zarrjava/zarrita_read.py" );
4042 final static String CONDA_ENVIRONMENT = "zarrita_env" ;
41- static ucar .ma2 .Array testData ;
42- static ucar .ma2 .Array testDataTransposed ;
4343
4444 @ BeforeAll
4545 public static void clearTestoutputFolder () throws IOException {
@@ -94,52 +94,6 @@ public static void installZarritaInCondaEnv() throws IOException {
9494 }
9595 }
9696
97- @ BeforeEach
98- public void fillTestData () {
99- testData = ucar .ma2 .Array .factory (ucar .ma2 .DataType .UINT , new int []{4 , 4 , 4 }, new int []{
100- 0 , 1 , 2 , 3 ,
101- 4 , 5 , 6 , 7 ,
102- 8 , 9 , 10 , 11 ,
103- 12 , 13 , 14 , 15 ,
104-
105- 16 , 17 , 18 , 19 ,
106- 20 , 21 , 22 , 23 ,
107- 24 , 25 , 26 , 27 ,
108- 28 , 29 , 30 , 31 ,
109-
110- 32 , 33 , 34 , 35 ,
111- 36 , 37 , 38 , 39 ,
112- 40 , 41 , 42 , 43 ,
113- 44 , 45 , 46 , 47 ,
114-
115- 48 , 49 , 50 , 51 ,
116- 52 , 53 , 54 , 55 ,
117- 56 , 57 , 58 , 59 ,
118- 60 , 61 , 62 , 63
119- });
120- testDataTransposed = ucar .ma2 .Array .factory (ucar .ma2 .DataType .UINT , new int []{4 , 4 , 4 }, new int []{
121- 0 , 16 , 32 , 48 ,
122- 4 , 20 , 36 , 52 ,
123- 8 , 24 , 40 , 56 ,
124- 12 , 28 , 44 , 60 ,
125-
126- 1 , 17 , 33 , 49 ,
127- 5 , 21 , 37 , 53 ,
128- 9 , 25 , 41 , 57 ,
129- 13 , 29 , 45 , 61 ,
130-
131- 2 , 18 , 34 , 50 ,
132- 6 , 22 , 38 , 54 ,
133- 10 , 26 , 42 , 58 ,
134- 14 , 30 , 46 , 62 ,
135-
136- 3 , 19 , 35 , 51 ,
137- 7 , 23 , 39 , 55 ,
138- 11 , 27 , 43 , 59 ,
139- 15 , 31 , 47 , 63
140- });
141- }
142-
14397 @ ParameterizedTest
14498 @ ValueSource (strings = {"blosc" , "gzip" , "zstd" , "bytes" , "transpose" , "sharding" , "crc32c" })
14599 public void testReadFromZarrita (String codec ) throws IOException , ZarrException , InterruptedException {
@@ -295,19 +249,28 @@ public void testCodecsWriteRead(String codec) throws IOException, ZarrException,
295249 Assertions .assertArrayEquals (testData , (int []) result .get1DJavaArray (ucar .ma2 .DataType .INT ));
296250 }
297251
298- @ ParameterizedTest
299- @ ValueSource (strings = {"F" , "C" })
300- public void testCodecTranspose (String order ) throws IOException , ZarrException , InterruptedException {
252+ @ Test
253+ public void testCodecTranspose () throws IOException , ZarrException , InterruptedException {
254+ ucar .ma2 .Array testData = ucar .ma2 .Array .factory (ucar .ma2 .DataType .UINT , new int []{2 , 3 , 3 }, new int []{
255+ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 });
256+ ucar .ma2 .Array testDataTransposed120 = ucar .ma2 .Array .factory (ucar .ma2 .DataType .UINT , new int []{2 , 3 , 3 }, new int []{
257+ 0 , 9 , 1 , 10 , 2 , 11 , 3 , 12 , 4 , 13 , 5 , 14 , 6 , 15 , 7 , 16 , 8 , 17 });
258+
301259 ArrayMetadata .CoreArrayMetadata metadata = new ArrayMetadata .CoreArrayMetadata (
302- new long []{4 , 4 , 4 },
303- new int []{4 , 4 , 4 },
260+ new long []{2 , 3 , 3 },
261+ new int []{2 , 3 , 3 },
304262 DataType .UINT32 ,
305263 null );
306- TransposeCodec transposeCodec = new TransposeCodec (new TransposeCodec .Configuration (order ));
307-
308- //TODO is that what is expected?
309- assertEquals (testDataTransposed , transposeCodec .encode (testData , metadata ));
310- assertEquals (testData , transposeCodec .decode (testDataTransposed , metadata ));
264+ TransposeCodec transposeCodec = new TransposeCodec (new TransposeCodec .Configuration (new int []{1 , 2 , 0 }));
265+ TransposeCodec transposeCodecWrongOrder1 = new TransposeCodec (new TransposeCodec .Configuration (new int []{1 , 2 , 2 }));
266+ TransposeCodec transposeCodecWrongOrder2 = new TransposeCodec (new TransposeCodec .Configuration (new int []{1 , 2 , 3 }));
267+ TransposeCodec transposeCodecWrongOrder3 = new TransposeCodec (new TransposeCodec .Configuration (new int []{1 , 2 , 3 , 0 }));
268+
269+ assertEquals (testDataTransposed120 , transposeCodec .encode (testData , metadata ));
270+ assertEquals (testData , transposeCodec .decode (testDataTransposed120 , metadata ));
271+ assertThrows (ZarrException .class , () -> transposeCodecWrongOrder1 .encode (testData , metadata ));
272+ assertThrows (ZarrException .class , () -> transposeCodecWrongOrder2 .encode (testData , metadata ));
273+ assertThrows (ZarrException .class , () -> transposeCodecWrongOrder3 .encode (testData , metadata ));
311274 }
312275
313276 @ Test
0 commit comments