Scipy

Cool mailing list quotes:

Tim Hochberg on adding more functions to numpy:

Without commenting on the desirability of this particular function,
people seem awfully eager to add functions and methods everywhere. These
aren't free you know. They cost in terms of maintenance and potential
bugs, and in terms of making the already large function set even harder
to wrap ones head around. That's partly an organizational problem but
partly an issue of sheer size, neither of which are helped by adding a
bunch more stuff.

    Not every two-line Python function has to come pre-written
        --Tim Peters

Installing numpy, scipy, matplotlib

Simply run

python setup.py --prefix=${HOME}

or use this script that updates from SVN and then builds:

PKG=$1
OPT=$2

if [[ ! -d $PKG ]]; then
  echo "Invalid package name."
  exit 1
fi

if [[ $OPT != "nosvn" ]]; then
  svn update $PKG
fi

rm -rf /tmp/$PKG.build
cp -r $PKG /tmp/$PKG.build
pushd /tmp/$PKG.build

python setup.py build
if [[ $? -ne 0 ]]; then
  echo "Error building package."
  exit 1
fi

rm -rf /home/stefan/lib/python2.4/site-packages/$PKG
python setup.py install --prefix=/home/stefan/
popd

Customising IPython numeric profile

To ~/.ipython/ipythonrc-numeric, add

import_mod numpy
execute N = numpy

or, maybe more elegantly,

execute exec __IP.compile('import numpy as N','<input>','single') in __IP.user_ns

making numpy accessable as N.

Remove any references to Numeric, gnuplot as well as this line:

#execute xaxis=gpfunc('0',title='',with='lines lt -1')

Add an alias to ~/.bashrc, or creating a small script in ~/bin/numpy that does

ipython -p numeric

or even

ipython -pylab -p numeric

Debugging using Valgrind

Call valgrind as follows

valgrind \
               --tool=memcheck \
               --leak-check=yes \
               --error-limit=no \
               --suppressions=valgrind-python.supp \
               --num-callers=10 \
               -v \
               python $*

after saving these suppresion rules to valgrind-python.supp (from the python2.4 repository):

#
# This is a valgrind suppression file that should be used when using valgrind.
#
#  Here's an example of running valgrind:
#
#	cd python/dist/src
#	valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \
#		./python -E -tt ./Lib/test/regrtest.py -u bsddb,network
#
# You must edit Objects/obmalloc.c and uncomment Py_USING_MEMORY_DEBUGGER
# to use the preferred suppressions with Py_ADDRESS_IN_RANGE.
#
# If you do not want to recompile Python, you can uncomment
# suppressions for PyObject_Free and PyObject_Realloc.
#
# See Misc/README.valgrind for more information.

# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
{
   ADDRESS_IN_RANGE/Invalid read of size 4
   Memcheck:Addr4
   fun:Py_ADDRESS_IN_RANGE
}

{
   ADDRESS_IN_RANGE/Invalid read of size 4
   Memcheck:Value4
   fun:Py_ADDRESS_IN_RANGE
}

{
   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
   Memcheck:Cond
   fun:Py_ADDRESS_IN_RANGE
}

{
   ADDRESS_IN_RANGE/Invalid read of size 4
   Memcheck:Addr4
   fun:PyObject_Free
}

{
   ADDRESS_IN_RANGE/Invalid read of size 4
   Memcheck:Value4
   fun:PyObject_Free
}

{
   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
   Memcheck:Cond
   fun:PyObject_Free
}

{
   ADDRESS_IN_RANGE/Invalid read of size 4
   Memcheck:Addr4
   fun:PyObject_Realloc
}

{
   ADDRESS_IN_RANGE/Invalid read of size 4
   Memcheck:Value4
   fun:PyObject_Realloc
}

{
   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
   Memcheck:Cond
   fun:PyObject_Realloc
}


# All the suppressions below are for errors that occur within libraries
# that Python uses.  The problems to not appear to be related to Python's
# use of the libraries.

{
   GDBM problems, see test_gdbm
   Memcheck:Param
   write(buf)
   fun:write
   fun:gdbm_open

}


# These occur from somewhere within the SSL, when running
#  test_socket_sll.  They are too general to leave on by default.

{
   somewhere in SSL stuff
   Memcheck:Cond
   fun:memset
}
{
   somewhere in SSL stuff
   Memcheck:Value4
   fun:memset
}

{
   somewhere in SSL stuff
   Memcheck:Cond
   fun:MD5_Update
}

{
   somewhere in SSL stuff
   Memcheck:Value4
   fun:MD5_Update
}

#
# All of these problems come from using test_socket_ssl
#
{
   from test_socket_ssl
   Memcheck:Cond
   fun:BN_bin2bn
}

{
   from test_socket_ssl
   Memcheck:Cond
   fun:BN_num_bits_word
}

{
   from test_socket_ssl
   Memcheck:Value4
   fun:BN_num_bits_word
}

{
   from test_socket_ssl
   Memcheck:Cond
   fun:BN_mod_exp_mont_word
}

{
   from test_socket_ssl
   Memcheck:Cond
   fun:BN_mod_exp_mont
}

{
   from test_socket_ssl
   Memcheck:Param
   write(buf)
   fun:write
   obj:/usr/lib/libcrypto.so.0.9.7
}

{
   from test_socket_ssl
   Memcheck:Cond
   fun:RSA_verify
}

{
   from test_socket_ssl
   Memcheck:Value4
   fun:RSA_verify
}

{
   from test_socket_ssl
   Memcheck:Value4
   fun:DES_set_key_unchecked
}

{
   from test_socket_ssl
   Memcheck:Value4
   fun:DES_encrypt2
}

{
   from test_socket_ssl
   Memcheck:Cond
   obj:/usr/lib/libssl.so.0.9.7
}

{
   from test_socket_ssl
   Memcheck:Value4
   obj:/usr/lib/libssl.so.0.9.7
}

{
   from test_socket_ssl
   Memcheck:Cond
   fun:BUF_MEM_grow_clean
}

{
   from test_socket_ssl
   Memcheck:Cond
   fun:memcpy
   fun:ssl3_read_bytes
}

{
   from test_socket_ssl
   Memcheck:Cond
   fun:SHA1_Update
}

{
   from test_socket_ssl
   Memcheck:Value4
   fun:SHA1_Update
}

sub-sahara africa
subrahaman
sahara trip IanKnot rainbow