Please visit our Tetrad web page for current links for downloadables, a list of contributors, some history, documentation, descriptions, links for our various projects, Javadocs, and more!
This package shows how to make arbitrary code in Tetrad directly available in Python via JPype as part of a Python workflow. We do this by giving reusable examples of how it can be done, along with API Javadoc documentation to allow further exploration of the entire Tetrad codebase.
It also gives some simple tools that can be used in both Python and R to hide the JPype facilities for those who don't want to (or can't, in the case of R) deal directly with the Tetrad codebase.
You can also integrate Tetrad code into Python by making os.system (..) calls to Causal Command; here are some examples of how to do it.
Please bear with us as we add and refine example modules and keep our code current. Please submit any problems or suggestions to our Issue Tracker, so that we can resolve them. Sometimes it may not be obvious how to call a Tetrad class or method from Python. Please point out any difficulties you have, so we can make it more intuitive for the next version.
We maintain a current version of the Tetrad launch jar, which is either the [current published version](https://github.com/cmu-phil/tetrad/releases or else the current published version with some adjustments. The example code will work with this current jar. Feel free to use any version of Tetrad though. All artifacts for Tetrad for the last several releases are on Maven Central, with their corresponding API Javadocs, along wth signatures to verify authenticity.
We added a method to use Tetrad algorithms in R via py-tetrad. This is work in progress.
-
It is necessary to have a JDK installed for version 9+. See our Wiki article, Setting up Java for Tetrad.
-
type
echo $JAVA_HOME
in a terminal to see if this is already set to your JDK. On Windows, it should already be set if you've installed Java. On Mac, it should be set to the latest JDK installed. If it's not set, you'll need to set JAVA_HOME to the path of the Java installation you want to use for py-tetrad. -
It is also necessary (for JPype) to have Python 3.5+ installed. Here is how to update Python if you need to.
-
We use the JPype package to interface Python with Java. For installation instructions, see the Docs for the JPype box.
-
Finally, you will need to clone this GitHub repository, so if you don't have Git installed, google and install that for your machine type.
Then (for instance, on a Mac) in a terminal window, cd to a directory where you want the cloned project to appear and type the following--again, as above, make sure JAVA_HOME is set correctly to your java path:
git clone https://github.com/cmu-phil/py-tetrad/
cd py-tetrad/pytetrad
python run_continuous.py
If everything is set up right, the last command should cause this example module to run various algorithms in Tetrad and print out result graphs. Feel free to explore other example modules in that directory.
Feel free to use your favorite method for editing and running modules.
We realize these install instructions are a bit cumbersome and have ideas for how to simplify them, whicih we will do soon.
Please cite as:
Bryan Andrews and Joseph Ramsey. https://github.com/cmu-phil/py-tetrad, 2023.