Skip to content
Python and C implementation of practicable Aligned Induction
Python C
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


The AlignmentRepaPy repository is a fast Python and C implementation of some of the practicable inducers described in the paper The Theory and Practice of Induction by Alignment at The AlignmentRepa repository depends on the AlignmentPy repository for the underlying model framework. The slower implementations of some of the practicable inducers in the Alignment repository can be used to verify the correctness of equivalent faster implementations in AlignmentRepa.

The AlignmentRepaPy repository uses NumPy high performance arrays. In addition, some compute-intensive array processing is implemented in C using the NumPy C-API.


The Python implementation of fast Practicable Inducers discusses the implementation of the inducers using this repository.


The Alignment module requires the Python 3 platform to be installed.

For example in Ubuntu,

sudo apt-get update
sudo apt-get install python3.5
sudo apt install python3-pip

Then use the Python installer tool pip to install Sorted Containers and NumPy and SciPy,

python3.5 -m pip install --user numpy
python3.5 -m pip install --user scipy
python3.5 -m pip install --user sortedcontainers

Then download the zip file or use git to get the repositories -

git clone
git clone

Then to build the AlignmentForeignPy module that contains the C interface,

cd AlignmentRepaPy
python3 build
sudo python3 install

In Windows the AlignmentForeignPy module must be built explicitly. For example,

cd /d AlignmentRepaPy
cl.exe -Dinline=__inline /LD /I "." /I "C:\Program Files (x86)\Python\Python37-32\include" /I "C:\Program Files (x86)\Python\Python37-32\Lib\site-packages\numpy\core\include" AlignmentForeignPy.c "C:\Program Files (x86)\Python\Python37-32\libs\python37.lib"
move /Y AlignmentForeignPy.dll  AlignmentForeignPy.pyd

Note that if the AlignmentForeignPy module fails to build, the AlignmentRepa module will still run in pure NumPy Python, albeit more slowly. The success of the AlignmentForeignPy module import can be checked at runtime,

# True


Load AlignmentDevRepa to import the modules and define various useful abbreviated functions. For example, in Ubuntu,

export PYTHONPATH=../AlignmentPy:../AlignmentRepaPy
cd ../AlignmentRepaPy
from AlignmentRepaPy import *

aarr = systemsHistogramsHistogramRepa
rraa = systemsHistogramRepasHistogram

aa = regdiag(2,2)

# {({(1, 1), (2, 1)}, 1 % 1), ({(1, 2), (2, 2)}, 1 % 1)}

ar = aarr(sys(aa),aa)

# ([1, 2], {(1, 0), (2, 1)}, array([[1., 0.],
#        [0., 1.]]))

# {({(1, 1), (2, 1)}, 1 % 1), ({(1, 1), (2, 2)}, 0 % 1), ({(1, 2), (2, 1)}, 0 % 1), ({(1, 2), (2, 2)}, 1 % 1)}
You can’t perform that action at this time.