Libra: An open-source "Methodology Discovery" Library

General notes on Tutorials

Before we go into discussion of particular examples, let us first describe a few common points:
  1. Setup proper environment variables in all scripts. Well, since we are still working on polishing the cmake-based installer, one has to add the proper paths to Python path variable. This can be done in the script as:
    cwd = os.getcwd()

    Here, the "cwd" contains the path of the directory in which the current script has been called. For the purposes of these tutorials the present directory is one of the sub-folders of the "/libracode/tests" directory. Thus, the "_build" directory is two levels higher ("/../../"). In the "_build" folder there is a "src" folder created during the configuring and compilation. This "src" directory contains the sub-folders, similar to those present in the original "src" directory that contains only the source code. Each of the sub-directories will (after successful built process) contain the collersonding libraries. These libraries are essentially the Python modules, which can be loaded into Python scripts via the "import" command. So, in our present file system, we use the instructions in the snippet above to make the modules available. Of course, one is free to use absolute paths rather than relative as in the example above. Also, one can probably add the location of all libraries to the LD_LIBRARY_PATH or PYTHONPATH or both in the .bash_profile file, so not to use the above sys.path.insert() function. We reserve the latter option until later - when we are finished with a proper installer, but you can start using this option today, if you find it useful.
  2. Choose a proper prefix for the module names. The present tutorials will be run in my Cygwin terminal (Linux emulator on Windows), so in the compillation step, we have chosen the option to build binaries for Cygwin. The generated libraries carry the name prefix "cyg" instead of expected "lib". This is why, in our test scripts we load modules using:
    from cygmmath import *
    from cygmeigen import *
    from cyglinalg import *
    If you are working on Unix-based machines (Linux or MacOS), in the configuration/compillation step you would need to comment denining the flag to build Cygwin binaries. Hence, you will get libraries with the names starting with expected "lib" prefix. Hence, to load the modules, you would need to use:
    from libmmath import *
    from libmeigen import *
    from liblinalg import *

    (7/17/2016): I have figured out how the above two steps can be avoided, so that both environment variable and module name could be chosen automatically, depending on which OS you are using. In fact, we no longer need the paths to specific sub-modules (unless this is really what you need) and just loading core Libra modules and associated Libra Python scripts (libra_py) is sufficient. I'm updating test-tutorials, so that this convenient functionality appears everywhere, but the process is slow, so you might want to use the older (above 2) recipes or to adjust the scripts according to the new procedure (look in the updated examples). When this is done for all test-tutorials, I'll remove the above 2 steps (and this one), so you could just go straight to the tutorials.

With that, my friend, we are ready to use the library and try the tutorials out.

Tutorials for specific libraries