Category: Python

Matplotlib TkAgg

Now that Matplotlib 1.4 has been released, BEFORE upgrading matplotlib with sudo pip3 install –upgrade matplotlib consider first installing tk-dev sudo apt-get install tk-dev

Cohen-Sutherland line clipping in Python

Here is my version of Cohen-Sutherland line clipping for Python:

Maximum Entropy Regularization on Python

I have ported to Python the maxent.m function now called This is for maximum entropy regularization, from PC Hansen’s Regutools.

Matplotlib 3D plotting: how to import

For 3D plotting to work in Matplotlib, near the beginning of the first .py file you use to start your program, you must have imports in this order: import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt If you try importing Axes3D in a later function that actually does the 3D plotting, […]

Cygwin Python 3 pip install: Segmentation fault

Note: I get segmentation fault upon pip3.2 command, has anyone solved this? This was tested on Cygwin 1.7.31 with Python 3.2 and may be out of date when you read this Prereqs: python3-setuptools In cygwin type easy_install-3.2 pip to use pip3 type in Cygwin pip3.2

installing LLVM-Py and Numba on Ubuntu 14.04

First, you need a custom compilation of LLVM 3.2 (as of July 2014). As of July 2014, LLVM-Py will NOT work with the default LLVM 3.4 in Ubuntu 14.04. Note, these commands are NOT sudo/root. I choose to install LLVM 3.2 to ~/LLVM32. the -j2 option is to use 2 CPU cores, you can increase […]

upgrading to Scipy 0.14 via pip

you may first need to do sudo apt-get install liblapack-dev libatlas-dev libsparskit-dev libarpack2-dev gfortran libfftw3-dev libblas-dev before sudo pip install –upgrade scipy reference:

Spyder 2.3 missing rope for Python3

The just-released Spyder 2.3 (on Ubuntu, get by typing) sudo pip3 install spyder but it’s missing rope. To get rope, type sudo pip3 install rope_py3k for great online help

Autoscaling imagesc() plot and imshow() plots

Octave 3.8 has default axis scaling that scales x and y axes proportionally to the axes values. So if one axis values span a much wider range than the other axis, the smaller span axis gets very thin. You can simply insert the line axis(‘normal’) after imagesc() In Matplotlib 1.3, the same issue occurs, which […]

Using P.C. Hansen’s AIRtools and ReguTools in Python using Oct2Py

For those working with real-world inverse problems, P.C. Hansen’s AIRtools and ReguTools are great ways to quickly try out inverse methods. As in general in Python and Matlab, you need to be sure that your column vector of observations “b” is actually passed into the functions as a column vector. I’ll illustrate the issue by […]