From 2f9b26e7a8cad0ff20428b7c3377b39a65d86dfa Mon Sep 17 00:00:00 2001 From: JesseMckinzie <72471813+JesseMckinzie@users.noreply.github.com> Date: Tue, 31 Oct 2023 08:19:55 -0600 Subject: [PATCH 1/2] Fix groupby in iterator --- src/filepattern/java/FilePattern.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filepattern/java/FilePattern.java b/src/filepattern/java/FilePattern.java index 87b378f6..d0e89cc0 100644 --- a/src/filepattern/java/FilePattern.java +++ b/src/filepattern/java/FilePattern.java @@ -244,7 +244,7 @@ public Iterator iterator() { */ public Iterator iterator(String ... groups) { - this.fp.setGroup(new FilePatternBindings.StringVector(groups)); + this.setGroup(groups); return new FilePatternGroupedIterator(this); From 338dd6c10472ecfa391560e8115d838390c883c6 Mon Sep 17 00:00:00 2001 From: JesseMckinzie <72471813+JesseMckinzie@users.noreply.github.com> Date: Tue, 31 Oct 2023 08:38:22 -0600 Subject: [PATCH 2/2] Add additional test for groupBy --- tests/java/TestFilePattern.java | 34 ++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/java/TestFilePattern.java b/tests/java/TestFilePattern.java index f97daa83..78ccae3d 100644 --- a/tests/java/TestFilePattern.java +++ b/tests/java/TestFilePattern.java @@ -87,7 +87,7 @@ public void testGetMatching() { } @Test - public void testGroupBy() { + public void testSetGroup() { FilePattern fp = null; try { @@ -119,4 +119,36 @@ public void testGroupBy() { } + @Test + public void testGroupBy() { + + FilePattern fp = null; + try { + fp = new FilePattern.FilePatternBuilder("test_fp_data") + .recursive(false) + .filePattern("img_r00{r:d}_c00{c:d}_{channel:c+}.tif") + .suppressWarnings(false) + .blockSize("") + .recursive(false).build(); + } catch (Exception e) { + fail("Error creating FilePattern object."); + } + + ArrayList>, ArrayList, ArrayList>>>> result = new ArrayList<>(); + + + for (Iterator i = fp.iterator("r"); i.hasNext(); ) { + result.add((Pair>, ArrayList, ArrayList>>>) i.next()); + } + + ArrayList>, ArrayList, ArrayList>>>> truth = TestData.getGroupedResults(); + + System.out.println(result.size()); + System.out.println(truth.size()); + + assertEquals(result.size(), truth.size()); + assertEquals(result, truth); + + } + }