Skip to content

Commit

Permalink
Merge pull request #1837 from cmu-phil/development
Browse files Browse the repository at this point in the history
7.6.6 final commits.
  • Loading branch information
jdramsey authored Dec 11, 2024
2 parents 69fdb1c + 520dc64 commit 72ba5aa
Show file tree
Hide file tree
Showing 486 changed files with 17,572 additions and 7,855 deletions.
2 changes: 1 addition & 1 deletion INSTALL_APPLICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ See [Setting up Java for Tetrad](https://github.com/cmu-phil/tetrad/wiki/Setting

To download the Tetrad jar, please click the following link (which will always be updated to the latest version):

https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.6.4/tetrad-gui-7.6.4-launch.jar
https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.6.5/tetrad-gui-7.6.5-launch.jar

You may be able to launch this jar by double-clicking the jar file name. However, on a Mac, this presents some security
challenges. On all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you
Expand Down
6 changes: 3 additions & 3 deletions data-reader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.github.cmu-phil</groupId>
<artifactId>tetrad</artifactId>
<version>7.6.5</version>
<version>7.6.6</version>
</parent>
<!-- <groupId>io.github.cmu-phil</groupId>-->
<artifactId>data-reader</artifactId>
Expand All @@ -24,8 +24,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.cmu-phil</groupId>
<artifactId>tetrad</artifactId>
<version>7.6.5</version>
<version>7.6.6</version>
<packaging>pom</packaging>

<name>Tetrad Project</name>
Expand Down Expand Up @@ -64,8 +64,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
Expand Down
6 changes: 3 additions & 3 deletions tetrad-gui/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>tetrad</artifactId>
<groupId>io.github.cmu-phil</groupId>
<version>7.6.5</version>
<version>7.6.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>tetrad-gui</artifactId>
Expand Down Expand Up @@ -35,8 +35,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
Expand Down
6 changes: 3 additions & 3 deletions tetrad-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.cmu-phil</groupId>
<artifactId>tetrad</artifactId>
<version>7.6.5</version>
<version>7.6.6</version>
</parent>

<artifactId>tetrad-gui</artifactId>
Expand All @@ -33,8 +33,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void addToPanel(GeneralAlgorithmRunner algorithmRunner) {
Set<String> params = new LinkedHashSet<>();
// RFCI
params.add(Params.DEPTH);
params.add(Params.MAX_PATH_LENGTH);
params.add(Params.MAX_DISCRIMINATING_PATH_LENGTH);
params.add(Params.COMPLETE_RULE_SET_USED);
params.add(Params.VERBOSE);
this.mainPanel.add(createSubPanel(title, params, parameters));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public void actionPerformed(ActionEvent e) {
MeekRules meekRules = new MeekRules();
meekRules.setMeekPreventCycles(true);
meekRules.setRevertToUnshieldedColliders(false);
meekRules.setVerbose(false);
meekRules.orientImplied(graph);
workbench.setGraph(graph);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.HashSet;

/**
* CheckGraphForMpdagAction is an action class that checks if a given graph is a legal MPDAG (Mixed Ancestral Graph) and
Expand Down Expand Up @@ -80,7 +81,7 @@ class MyWatchedProcess extends WatchedProcess {
@Override
public void watch() {
Graph _graph = new EdgeListGraph(workbench.getGraph());
legalMag = GraphSearchUtils.isLegalMag(_graph);
legalMag = GraphSearchUtils.isLegalMag(_graph, new HashSet<>());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.HashSet;

/**
* CheckGraphForMpdagAction is an action class that checks if a given graph is a legal PAG (Mixed Ancesgral Graph) and
Expand Down Expand Up @@ -80,7 +81,7 @@ class MyWatchedProcess extends WatchedProcess {
@Override
public void watch() {
Graph _graph = new EdgeListGraph(workbench.getGraph());
legalPag = GraphSearchUtils.isLegalPag(_graph);
legalPag = GraphSearchUtils.isLegalPag(_graph, new HashSet<>());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public static String generateDescriptiveStats(DataSet dataSet, Node variable,
/**
* <p>median.</p>
*
* @param data an array of {@link double} objects
* @return an array of {@link double} objects
* @param data an array of objects
* @return an array of objects
*/
public static double[] median(double[] data) {
Arrays.sort(data);
Expand Down Expand Up @@ -183,7 +183,7 @@ public static double standardErrorMean(double stdDev, double sampleSize) {
/**
* Given some variable, returns the mean, standard deviation, and variance.
*
* @param data an array of {@link double} objects
* @param data an array of objects
* @return [0] -&gt; mean, [1] -&gt; standard deviation, [2] -&gt; variance
*/
public static double[] normalParams(double[] data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public void setup() {
"<br>provide below as pseudocount for every cell. This Dirichlet" +
"<br>Bayes IM will be used as the prior for the estimation. If" +
"<br>you would like to have more control over how this prior is" +
"<br>created, please remove the PM-->Estimator edge, add a new" +
"<br>IM box, connect it as PM-->IM-->Estimator, and create the" +
"<br>created, please remove the PM--&gt;Estimator edge, add a new" +
"<br>IM box, connect it as PM--&gt;IM--&gt;Estimator, and create the" +
"<br>prior you want as a Dirichlet Bayes IM in the IM box." +
"</html>"));

Expand Down
117 changes: 92 additions & 25 deletions tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/EdgeTypeTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,29 @@ public class EdgeTypeTable extends JPanel {
"Node 2"
};

private static final String[] EDGES_WITH_PROPERTIES = {
"",
"Node 1",
"Interaction",
"Node 2",
"Property"
};

private static final String[] EDGES_AND_EDGE_TYPES = {
"",
"Node 1",
"Interaction",
"Node 2",
"Ensemble",
"Edge",
"No edge",
"\u2192",
"\u2190",
"---",
"\u2192", // -G> pd nl
"\u2190", // <G- pd nl
"\u2192", // =G> dd nl
"\u2190", // <G= dd nl
"No edge", // 6
"--> dd pl", // 7
"<-- dd pl", // 8
"---", // 9
"--> pd nl", // -G> pd nl 10 nl pd
"<-- pd nl", // <G- pd nl 11
"--> dd nl", // =G> dd nl 12 nl dd
"<-- dd nl", // <G= dd nl 13
"o->",
"<-o",
"o-o",
Expand Down Expand Up @@ -118,19 +126,19 @@ public void update(Graph graph) {
tableModel.setColumnIdentifiers(EdgeTypeTable.EDGES_AND_EDGE_TYPES);

JTableHeader header = this.table.getTableHeader();
Font boldFont = new Font(header.getFont().getFontName(), Font.BOLD, 18);
TableCellRenderer headerRenderer = header.getDefaultRenderer();
header.setDefaultRenderer((tbl, value, isSelected, hasFocus, row, column) -> {
Component comp = headerRenderer.getTableCellRendererComponent(tbl, value, isSelected, hasFocus, row, column);
if (column >= 10 && column <= 13) {
comp.setForeground(Color.BLUE);
}
if (column >= 12 && column <= 13) {
comp.setFont(boldFont);
}

return comp;
});
// Font boldFont = new Font(header.getFont().getFontName(), Font.BOLD, 18);
// TableCellRenderer headerRenderer = header.getDefaultRenderer();
// header.setDefaultRenderer((tbl, value, isSelected, hasFocus, row, column) -> {
// Component comp = headerRenderer.getTableCellRendererComponent(tbl, value, isSelected, hasFocus, row, column);
// if (column >= 10 && column <= 13) {
// comp.setForeground(Color.BLUE);
// }
// if (column >= 12 && column <= 13) {
// comp.setFont(boldFont);
// }
//
// return comp;
// });

edges.forEach(edge -> {
String[] rowData = new String[EdgeTypeTable.EDGES_AND_EDGE_TYPES.length];
Expand All @@ -140,17 +148,20 @@ public void update(Graph graph) {
tableModel.addRow(rowData);
});
} else {
boolean addProperty = hasEdgeProperties(graph);
String[] edgeHeaders = addProperty ? EDGES_WITH_PROPERTIES : EDGES;

this.title.setText("Edges");
this.table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
tableModel.setColumnIdentifiers(EdgeTypeTable.EDGES);

tableModel.setColumnIdentifiers(edgeHeaders);

edges.forEach(edge -> {
String[] rowData = new String[EdgeTypeTable.EDGES.length];
addEdgeData(edge, rowData);
String[] rowData = new String[edgeHeaders.length];
addEdgeData(edge, rowData, addProperty);

tableModel.addRow(rowData);
});

}

tableModel.fireTableDataChanged();
Expand Down Expand Up @@ -241,6 +252,52 @@ private void addEdgeProbabilityData(Edge edge, String[] rowData) {
rowData[5] = String.format("%.4f", edge.getProbability());
}

private void addEdgeData(Edge edge, String[] rowData, boolean addProperty) {
String node1Name = edge.getNode1().getName();
String node2Name = edge.getNode2().getName();

Endpoint endpoint1 = edge.getEndpoint1();
Endpoint endpoint2 = edge.getEndpoint2();

// These should not be flipped.
String endpoint1Str = switch (endpoint1) {
case TAIL ->
"-";
case ARROW ->
"<";
case CIRCLE ->
"o";
default ->
"";
};
String endpoint2Str = switch (endpoint2) {
case TAIL ->
"-";
case ARROW ->
">";
case CIRCLE ->
"o";
default ->
"";
};
String edgeType = endpoint1Str + "-" + endpoint2Str;

rowData[1] = node1Name;
rowData[2] = edgeType;
rowData[3] = node2Name;

if (addProperty) {
List<Edge.Property> edgeProperties = edge.getProperties();
if (edgeProperties.isEmpty()) {
rowData[4] = "";
} else {
rowData[4] = edgeProperties.stream()
.map(e -> e.toString())
.collect(Collectors.joining(", "));
}
}
}

private void addEdgeData(Edge edge, String[] rowData) {
String node1Name = edge.getNode1().getName();
String node2Name = edge.getNode2().getName();
Expand Down Expand Up @@ -282,6 +339,16 @@ private boolean hasEdgeProbabilities(Graph graph) {
return false;
}

private boolean hasEdgeProperties(Graph graph) {
for (Edge edge : graph.getEdges()) {
if (!edge.getProperties().isEmpty()) {
return true;
}
}

return false;
}

/**
* <p>Getter for the field <code>graph</code>.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private void initUI(GraphWrapper graphWrapper) {
// Update the graphWrapper
graphWrapper.setGraph(targetGraph);
// Also need to update the UI
updateBootstrapTable(targetGraph);
// updateBootstrapTable(targetGraph);
}
} else if ("modelChanged".equals(propertyName)) {
firePropertyChange("modelChanged", null, null);
Expand Down Expand Up @@ -350,6 +350,9 @@ private void initUI(GraphWrapper graphWrapper) {
// JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new PaddingPanel(topBox), new PaddingPanel(edgeTypeTable));
// splitPane.setDividerLocation((int) (splitPane.getPreferredSize().getHeight() - 150));

this.edgeTypeTable.update(graph);
updateBootstrapTable(graph);

// Switching to tabbed pane because of resizing problems with the split pane... jdramsey 2021.08.25
JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.RIGHT);
tabbedPane.addTab("Graph", new PaddingPanel(topBox));
Expand All @@ -359,8 +362,6 @@ private void initUI(GraphWrapper graphWrapper) {
add(menuBar, BorderLayout.NORTH);
add(tabbedPane, BorderLayout.CENTER);

this.edgeTypeTable.update(graph);

// Performs relayout.
// It means invalid content is asked for all the sizes and
// all the subcomponents' sizes are set to proper values by LayoutManager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public GraphFileMenu(GraphEditable editable, JComponent comp, boolean saveOnly)
JMenu save = new JMenu("Save...");
add(save);

save.add(new SaveGraph(editable, "Text...", SaveGraph.Type.text));
save.add(new SaveGraph(editable, "XML...", SaveGraph.Type.xml));
save.add(new SaveGraph(editable, "Json...", SaveGraph.Type.json));
save.add(new SaveGraph(editable, "R...", SaveGraph.Type.r));
save.add(new SaveGraph(editable, "Dot...", SaveGraph.Type.dot));
save.add(new SaveGraph(editable, "amat.cpdag...", SaveGraph.Type.amatCpdag));
save.add(new SaveGraph(editable, "amat.pag...", SaveGraph.Type.amatPag));
save.add(new SaveGraph(editable.getWorkbench(), "Text...", SaveGraph.Type.text));
save.add(new SaveGraph(editable.getWorkbench(), "XML...", SaveGraph.Type.xml));
save.add(new SaveGraph(editable.getWorkbench(), "Json...", SaveGraph.Type.json));
save.add(new SaveGraph(editable.getWorkbench(), "R...", SaveGraph.Type.r));
save.add(new SaveGraph(editable.getWorkbench(), "Dot...", SaveGraph.Type.dot));
save.add(new SaveGraph(editable.getWorkbench(), "amat.cpdag...", SaveGraph.Type.amatCpdag));
save.add(new SaveGraph(editable.getWorkbench(), "amat.pag...", SaveGraph.Type.amatPag));
// save.add(new SaveGraph(editable, "PCALG...", SaveGraph.Type.pcalg));
save.add(new SaveGraph(editable, "lavaan...", SaveGraph.Type.lavaan));
save.add(new SaveGraph(editable.getWorkbench(), "lavaan...", SaveGraph.Type.lavaan));

addSeparator();
add(new SaveComponentImage(comp, "Save Graph Image..."));
Expand Down
Loading

0 comments on commit 72ba5aa

Please sign in to comment.