Skip to content

Commit

Permalink
sort values and fix another script #503
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed Jul 30, 2024
1 parent c0e2dc7 commit 76fed0a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lphy-base/src/test/java/lphy/base/LPhyExamplesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void setUp() {
tutorialDir = Paths.get(wd, "..", "tutorials").toFile();
assertTrue(tutorialDir.exists(), "Cannot find tutorial folder : " + tutorialDir);

RandomUtils.setSeed(666L);
RandomUtils.setSeed(666L); // birth death could sample too many trees
}

@Test
Expand Down Expand Up @@ -142,6 +142,8 @@ protected void testLPhyExamplesInDir(File exampleDir) {
@Test
public void testCodeBuilder() {

// testCodeBuilder(Paths.get(String.valueOf(exampleDir), "io").toFile());

// lphy scripts under this dir
testCodeBuilder(exampleDir);

Expand All @@ -161,10 +163,9 @@ protected void testCodeBuilder(File exampleDir) {
System.out.println("\nTest that examples are revisable using CodeBuilder in " + exampleDir.getAbsolutePath());
String[] exampleFiles = exampleDir.list((dir1, name) -> name.endsWith(".lphy"));
List<String> ignoreFiles = Arrays.asList(
"cpacific.lphy", // tutorials/cpacific.lphy ==> array lengths differ,
"vars-in-array.lphy", //TODO
"jcc2Fasta.lphy" //TODO
"cpacific.lphy" //TODO string var is replaced by value, D.charset([bird, and, belly]);
);
// exampleFiles = new String[]{"cpacific.lphy"};

CanonicalCodeBuilder codeBuilder = new CanonicalCodeBuilder();
List<String> failed = new ArrayList<>();
Expand Down Expand Up @@ -215,7 +216,8 @@ protected void testCodeBuilder(File exampleDir) {
filter(v -> !(v instanceof RandomVariable)).map(Value::codeString).toList().toArray(new String[0]);
String[] vals2 = GraphicalModelUtils.getAllValuesFromSinks(newDict).stream().
filter(v -> ! (v instanceof RandomVariable)).map(Value::codeString).toList().toArray(new String[0]);

Arrays.sort(vals1);
Arrays.sort(vals2);
assertArrayEquals(vals1, vals2, "Original data value set : " + Arrays.toString(vals1) +
"\nBut data value set after code builder : " + Arrays.toString(vals2) + "\nFile = " + lphyPath);
}
Expand Down

0 comments on commit 76fed0a

Please sign in to comment.