Posts
Installing Sage 4.7 on CentOS 5
I recently upgraded my desktop workstation from an old 32-bit version of Gentoo to 64-bit CentOS 5. I downloaded and installed the latest version of Sage, and the process went smoothly. If you find this post helpful, please check out the Sage Beginner’s Guide at Packt Publishing. Since I don’t use Sage every day, I actually refer to my own book on a regular basis!
Download
Since CentOS is designed to be binary compatible with Red Hat Enterprise Linux, the correct binary to download is sage-4.7.2-linux-64bit-red_hat_enterprise_linux_server_release_5.6_tikanga-x86_64-Linux.tar.gz
Python string format examples
The format method for Python strings (introduced in 2.6) is very flexible and powerful. It’s also easy to use, but the documentation is not very clear. It all makes sense with a few examples. I’ll add more as I have time:
Formatting Numbers in Python Strings
Formatting a floating-point number
[code language=“python”] “{0:.4f}".format(0.1234567890) “{0:.4f}".format(10.1234567890) [/code] The result is the following string:
'0.1235'
'10.1235'Braces { } are used to enclose the “replacement field” 0 indicates the first argument to method format : indicates the start of the format specifier .4 indicates four decimal places f indicates a floating-point number
Linux kernel 3.1 config for Gentoo guest on VMWare Fusion
The following kernel configuration was posted by Alessandro Di Marco as a comment on a previous post in which I provided a Linux kernel config for an earlier version of the kernel. In the interest of sharing his contribution, I’m placing it in its own post. I don’t know the author personally and I have not tried this config. Like any other free software, you are using it at your own risk and neither Alessandro nor I provide any warranty. Download the file from the link below, change the file extension from .txt. to .config and load the config into one of the standard kernel configuration tools (such as make menuconfig) and look over all the options before using it. Gentoo Kernel 3.1 Config
Alternate implementations of Python
This is a “skeleton” of a page that I want to write about various versions of Python that are optimized for various applications. However, I now recommend that you just check out this article about all the different implementations of Python (CPython, Jython, IronPython, PyPy, etc.) by Charles Marsh. Stackless Python is an implementation of Python that adds lightweight microthreads with scheduling and interthread communication. It’s aimed at concurrent programming. Note that Stackless microthreads do not take advantage of multicore or multiprocessor architectures. The threads all run within one Python process. Jython is an implementation of the Python programming language that runs on the Java Virtual Machine (JVM). PyPy is an alternative Python interpreter than incorporates a just-in-time (JIT) compiler that optimized bytecode to optimize performance. Cython is a language that allows you to write C extensions for Python in a language that is very much like Python.
TeXLive and Asymptote on CentOS 5
Tex Live
For reasons unknown, a TeX Live package is not available for Red Hat Enterprise Linux/Centos 5 from the major repositories (EPEL or DAG). I consider this to be a glaring omission, since TeXLive is a great improvement upon teTeX. Since I don’t have time right now to package it myself, I installed TeX Live manually in my user directory and it’s working fine. I used the network install process, which starts with downloading a command-line installer and then following the detailed installation instructions with the base path set to $HOME/texlive/2011.
How to install Octave video tools on CentOS 5
This post describes how to get GNU Octave up and running on a CentOS 5 Linux system for use in reading, processing, and writing video files. You will need to use the EPEL and DAG/rpmforge repositories, but I won’t explain how to do that here. NOTE: I had to go through some trial and error to get this working. I tried to summarize only the necessary steps, but I can’t guarantee I got it completely right until I try a fresh install on another system which does not have any of the dependencies already installed. Please leave a comment if you encounter any problems. As a superuser, use yumto install octave. You need octave-devel and ncurses-devel in order to install any Octave packages. You will need to have the EPEL repository enabled: yum install octave octave-devel ncurses-devel As a superuser, useyum to install ffmpeg and ffmpeg-devel from the rpmforge repo. The video package for octave uses the ffmpeg libraries (avilib) to perform the actual video processing. You will need the ffmpeg-devel package, because Octave builds the video package from source.
How to build ScipPy with Python 2.7.2 on CentOS5
EDIT: added –enable-shared to configure script for building Python, and added /home/yourname/lib to shared library path. This is necessary for building some packages such as pycairo (which you may need to build pygtk and matplotlib). EDIT 2: you should use the –prefix=/home/yourusername instead of –user. The prefix option places packages in the standard location: /home/yourusername/lib/python2.7/site-packages. The –user option places the packages in /home/yourusername/.local/lib/python2.7/site-packages which I think is screwed up! I use CentoOS5 because I want enterprise-class stability, as well as binary compatibility with a commercial application that is built for RHEL5. I need to use some “bleeding edge” packages, such as the latest version of SciPy, but I don’t want to affect the base stability of the system. Here is how I did it. First, with superuser privileges, use yum to install the following packages. You may need to set up epel as an alternate repository:
Parsing INI configuration files with FORTRAN
Fortran would not be my first choice for working with text, in any form! However, sometimes even numerical codes need to read data from configuration files. The easiest way to read a configuration file from a Fortran 90 routine is by using namelist I/O (I really need to add an example of that). If you’re stuck with INI files, I found an INI file parser written in Fortran buried in an index of free Fortran routine. I don’t even remember how I even found it, since it’s not well labeled and doesn’t come up in the first few pages of Google results, so I thought I’d better write a post about it in case I ever need such a thing in the future.
Visualization
Open-source visualization tools
This list is not exhaustive, and I haven’t used all these tools. Hopefully, you’ll find something useful.
asymptote chaco CDAT (Climate Data Analysis Tools) ImageVis3D (volume rendering) matplotlib (html 5 canvas) tikz/pgf (plotting for TeX) VisIt VisTrails (a workflow tool that utilizes other visualizers)