Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Tuesday, August 28, 2012

NodePy version 0.4 released

NodePy is a Python package for analyzing numerical integrators for initial value ODEs.  It's essentially a collection of all the kinds of analysis I've used in my time integrator research, collected in a single object-oriented package.  

If you have a new Runge-Kutta method and want to know all about it, NodePy can tell you most anything.  If you want to design new time integration methods, NodePy can help you.

Although I'm rather proud of it, it fills a very small niche in the world and I'm not aware of anyone using it outside of my group and close collaborators.  If you've used it, please let me know in the comments.

One of the thorniest issues in NodePy previously was that floating-point representations of method coefficients were sometimes insufficient, especially when studying very high order methods.  I've now updated NodePy to use Sympy Rationals (and radicals, etc.) wherever possible, allowing exact analysis of many properties.

That and much more awaits in NodePy version 0.4, now available via pip.

Monday, February 7, 2011

Python code for making a histogram of your e-mail volume

Here is the source code for the example in my last post. I haven't had time to clean it up, and some parts are not very elegant. But if you want to try it out with your own inbox, all you need to do is change the e-mail address and run it.

Three caveats:
1. If you need to download a large number of e-mail headers, it will take some time (maybe several minutes).
2. It sometimes gets the dates wrong. However, this seems to occur only in a statistically insignificant fraction of cases.
3. Running this will mark all the messages it accesses as read. I'm sure there's a way to avoid this, but haven't had time to track it down.

Sunday, February 6, 2011

Visualizing my inbox load

The other day I happened to notice that I had received well over 100 e-mails in one day.  While that may or may not seem high to you, in my case this meant that I spent most of the day handling e-mails, since the majority of these actually required a response or some other action on my part (I'm organizing two workshops right now, which accounts for much of the traffic).

I thought back to grad school days when I might or might not receive any e-mail on a given day.  When did it all get so crazy?  I decided it would be fun to find out.  A bit of searching turned up the Python package imaplib, which allowed me to download headers for all messages (ever!) from my Gmail account.  Then it was just a matter of extracting and reformatting the dates and plotting up a histogram with matplotlib.  Here's the result:


Can you tell when I graduated and started working for KAUST?  In the last few months prior to starting at KAUST, I got an average of about 250 messages a month.  Within 2 months of starting at KAUST, that average was well over 1000, with some months substantially higher.  Ah, the joys of being a professor...

Thursday, January 13, 2011

nodepy 0.3 available via easy_install

To facilitate my research and perhaps help someone else out there, I develop a python package based around numerical ODE solvers (Runge-Kutta methods, multistep methods, etc.) as objects. The package is called nodepy, and has somewhat limited functionality. However, it contains a very nice implementation of rooted trees, including the ability to compute all the things necessary for deriving order conditions of general linear methods. It also has a lot of nice functionality for Runge-Kutta methods, including a lot of things related to low-storage methods and embedded methods.

As of today, the package is finally available on the PyPI server, and therefore can be installed using

easy_install nodepy

Hopefully this will encourage interested parties to try it out (or better yet, to contribute!)

Thursday, January 6, 2011

Using pylint to clean up Python code

I just recently discovered a very useful package for anyone who writes python code: pylint. It took a little tweaking to get it to do what I wanted. Besides looking for outright errors, it checks all the recommended Python coding style conventions. Since I don't abide by many of those, pylint gave my nodepy code a rating of -4.5/10.0 (yes, that's a NEGATIVE rating) initially. More importantly, I couldn't find the real errors among the thousands of style complaints. To run pylint without checking all the style conventions, just type

pylint -d C xxxx

where "xxxx" is the name of a python package or module. It will still make a lot of subjective judgments about your code (like suggesting that no function should have more than 5 arguments), but to me it's a tolerable level (and sometimes the suggestions really are helpful). More information about pylint's output messages can be found here: http://www.logilab.org/card/pylintfeatures. I was able to uncover several previously unnoticed issues in my package in this way.

Tuesday, November 24, 2009

Getting things to install for the correct shell in Mac OS X

In addition to blogging about KAUST here, I'm also going to post little useful tidbits related to scientific computing in OS X. Today I was setting up my new Mac Pro. After installing the Enthought Python Distribution, I found that ipython was not in my path (and the python in my path was not the enthought-installed version).

The culprit was the following: I had changed shells in Terminal's preferences to tcsh, but somehow the EPD installer didn't detect this and thought I was still using bash. Thus the modifications to my path were placed in ~/.bash_profile rather than in ~/.cshrc. That was easy enough to fix, but to avoid similar problems in the future, I opened a Terminal and typed

chsh -s /bin/tcsh

so that next time the installer would know my default shell.