Package: la
The main class of the la package is a labeled array, larry. A larry consists
of data and labels. The data is stored as a NumPy array and the labels as a
list of lists (one list per dimension).Here’s larry in schematic form:date1    date2    date3
    'AAPL'   209.19   207.87   210.11
y = 'IBM'    129.03   130.39   130.55
    'DELL'    14.82    15.11    14.94The larry above is stored internally as aNumpyarray and a list of lists:y.label = [['AAPL', 'IBM', 'DELL'], [date1, date2, date3]]
y.x = np.array([[209.19, 207.87, 210.11],
                [129.03, 130.39, 130.55],
                [ 14.82,  15.11,  14.94]])A larry can have any number of dimensions except zero. Here, for example, is
one way to create a one-dimensional larry:>>> import la
>>> y = la.larry([1, 2, 3])In the statement above the list is converted to a Numpy array and the labels
default torange(n), wherenin this case is 3.larry has built-in methods such asranking, merge, shuffle, move_sum,
zscore, demean, lagas well as typical Numpy methods likesum, max, std,
sign, clip. NaNs are treated as missing data.Alignment by label is automatic when you add (or subtract, multiply, divide)
two larrys. You can also specify the join method (inner, outer, left, right)
for binary operations on two larrys with unaligned labels.You can archive larrys in HDF5 format usingsaveandloador using a
dictionary-like interface:>>> io = la.IO('/tmp/dataset.hdf5')
>>> io['y'] = y   # <--- save
>>> z = io['y']   # <--- load
>>> del io['y']   # <--- delete from archiveFor the most part larry acts like a Numpy array. And, whenever you want,
you have direct access to the Numpy array that holds your data. For
example if you have a function,myfunc, that works on Numpy arrays and
doesn’t change the shape or ordering of the array, then you can use it on a
larry,y, like this:y.x = myfunc(y.x)larry adds the convenience of labels, provides many built-in methods, and
let’s you use your existing array functions.LicenseThelapackage is distributed under a Simplified BSD license. Parts of
NumPy, Scipy, and numpydoc, which all have BSD licenses, are included inla. Parts of matplotlib are also included. See the LICENSE file, which
is distributed with thelapackage, for details.InstallRequirements:laPython, NumPy 1.5.1-1.6.1, Bottleneck 0.5.0Unit testsnoseOptional:Archive larrys in HDF5h5py, HDF 1.8Compile for speed boostgcc or MinGWlar.ranking(norm=’gaussian’)SciPy 0.8.0, 0.9.0You can download thelatest version of laandBottleneckfrom the Python
Package Index.GNU/Linux, Mac OS X et al.To installla:$ python setup.py build
$ sudo python setup.py installOr, if you wish to specify wherelais installed, for example inside/usr/local:$ python setup.py build
$ sudo python setup.py install --prefix=/usr/localAlternatively, you can use the makefile to installlainplace:$ make allWindowsIn order to (optionally) compile the C code in thelapackage you need a
Windows version of the gcc compiler. MinGW (Minimalist GNU for Windows)
contains gcc and has been used to successfully compilelaon Windows.Install MinGW and add it to your system path. Then installlawith the
commands:python setup.py build --compiler=mingw32
python setup.py installPost installAfter you have installedla, run the suite of unit tests:>>> import la
>>> la.test()
<snip>
Ran 3063 tests in 1.408s
OK
<nose.result.TextTestResult run=3063 errors=0 failures=0>Thelapackage contains C extensions that speed up common alignment
operations such as adding two unaligned larrys. If the C extensions don’t
compile when you buildlathen there’s an automatic fallback to python
versions of the functions. To see whether you are using the C functions or the
Python functions:>>> la.info()
la version      0.6.0
la file         /usr/local/lib/python2.6/dist-packages/la/__init__.pyc
NumPy           1.6.0
Bottleneck      0.5.0
HDF5 archiving  Available (h5py 2.0.0)
listmap         Faster C version
listmap_fill    Faster C versionSincelacan run in a pure python mode, you can uselaby just saving
it and making sure that python can find it.URLsdownloadhttp://pypi.python.org/pypi/ladocshttp://berkeleyanalytics.com/lacodehttps://github.com/kwgoodman/lamailing listhttp://groups.google.com/group/labeled-arrayissue trackerhttps://github.com/kwgoodman/la/issues