This repository is my personal library of python and cython code.
I use the code routinely, and I repair things immediately when they do not do what I want. This may include arbitrary design changes to the API, although most of it is pretty stable now. So if you see something you like, it is not likely to break tomorrow. If a significant user base evolves, I will, of course, have to move to a more formal release cycle.
On ubuntu derivatives, python2.7 add-on packages are installed in:
/usr/local/lib/python2.7/dist-packages
and the historical directory:
/usr/local/lib/python2.7/site-packages
is empty. I use the latter directory to make python and cython code I authored available for use on my system. That code is stored as .py and .pyc (python) or .so (cython) files, as appropriate. This repository contains the necessary source code and setup files for creating that arrangement, stored in a tree that mirrors the destination of the object code.
If you would like to use this code in a similar fashion, clone the repository to somewhere in your home directory. For the pure python code, issue these commands from your home directory:
python -m compileall ./site-packages # recursively compile the clone files
cd ./site-packages # change current directory for searches
To compile the cython files, you will, of course, have to install cython, if you don't already have it. Under ubuntu and derivatives, install the cython package with the commands:
sudo apt-get update # freshen local package lists
sudo apt-get install cython # will also install any dependencies
For the cython code, each <name>.pyx file has an associated setup_<name>.py file. First, get a list of the ./<path>/<name>.pyx files (currently four files):
find -name "*.pyx"
To generate each .so file issue the commands:
cd ./<path>
python ./setup_<name>.py build_ext --inplace
rm ./setup_<name>.py* # no need to copy these to site-packages
cd ~/site-packages # move back to your home directory clone root
This sequence compiles python byte code files and cython shareable objects.
Notice that the modules, gauss, space, and space_4D are doubly implemented: there is a python version which establishes correctly functioning algorithms, and then there is a cython translation, which provides performance. You will need to choose which one you prefer and delete the other from your site-packages clone directory. It is not clear what python will load if both are present - probably the first one that it finds.
Now you are ready to copy the files to:
/usr/local/lib/python2.7/site-packages/
Issue the commands:
# find .py,.pyc, and .pyx files with paths; omit .pyx; pipe them to cpio
find -name "*.py*" -regex ".*py[c]?$" | \
# pass-through (-p) to site packages; recreate directory tree (d);
# preserve creation/modification times (m); silently overwrite (u);
# observing unbuntu ownership conventions (-R)
sudo cpio -R root:staff -pdmu /usr/local/lib/python2.7/site-packages/
# do the same for .so files
find -name "*.so" | \
sudo cpio -R root:staff -pdmu /usr/local/lib/python2.7/site-packages/
The first time you install, put that directory in your PYTHONPATH by including the following line at the end of your your home directory ~/.bashrc file:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages
Then issue the command . .bashrc (notice the space:'._.') in your home directory to reread the .bashrc file without the need to reboot or start a new terminal session.
Finally, delete the clone directory from your home directory.
TODO: Create a make file that automates this.
All of these modules have some lacunae. All of them are usable. The more fundamental ones are quite complete and have been used for various purposes for years.
Facilitates computation of arbitrary
n-th derivatives of standard math functions and compositions of those functions. Provides tools for numerical integration and black body calculations. Contains a brief and correct recursive implementation of the Faà di Bruno formula and some useful statistical tools.
A set of convenience functions that are not implemented in the standard
mathmodule.
Provides a class for linearly interpolating a dataset and a class for numerically computing derivatives of an analytic base function, e.g. a linear interpolant of a dataset.
Provides a
metaclassfor a read-only singleton dictionary and various data dictionaries.
Provides a table of CIE-LMS data and its transformation matrix to CIE-XYZ. Provides rectification of that data and matrix for use with linear interpolation and trapezoidal integration such that identical CIE-XYZ data is produced.
Provides a class implementation of the functionality of the python standard library
heapq.pymodule.
Provides classes for rendering the essential elements of the
svgDOM in an approximately one to one direct manner.
Provides more abstract classes for creating
svgplots.
Provides classes for representing planar figures in three dimensions.
Re-implements the built-in
complexnumber data type functionality in a way that automatically coerces the built-in data type and augments it with geometric methods.
Provides tools for differential geometry calculations on paths in space.
Provides classes representing 3-dimensional Cartesian geometric points as homogeneous 4-tuples, 3-dimensional affine differentials of geometric points, and quaternions. Operator overrides adhere strictly to the semantic distinctions facilitating geometrically correct expressions of computations, and informative error messages when the expression is geometrically incorrect.
Provides classes for representing surfaces. Operations include containment testing and intersection.
Provides classes for representing solids. Operations include containment testing.
Provides linear algebra tools for general multi-dimensional geometric modelling.
Provides linear algebra tools optimized for geometric modelling specific to the 4-dimensional projective space used in computer graphics. This
cythonimplementation executes more quickly than the same semantics implemented withnumpy.
See:
See: