Article

Programming Potpourri

So supposedly I was done talking about point duplicate detection in linear time, but one of the guys at work suggested another good trick: using polar coordinates rather than cartesian. This comes with a pretty significant expense (the conversion requires using atan2), but it's worth considering if you're working in polar coordinates already. Spherical should work, too.

The next bit of fun I've been having lately has been playing with numpy. I've had some number-crunching to do at work, and it integrates into the suite of programs/scripts I've written fairly nicely already. Plus it's been a goal to spend some time with it anyway.

A few years ago I wrote a hacky stock analysis tool to decide whether to follow a financial advisor's recommendations (I didn't). Numpy would've been useful then, I think, although I rather enjoyed coding up the simple stats algorithms and putting it altogether. One of the effects of spending time working with a new package is that you get to learn a little more about how to code idiomatically—casting about for how to turn all those points into separate X, Y, and Z coordinates, for example:

    x, y, z = list( zip(*points) )

It was delicious. This is the sort of thing I knew—or at least had known—but took a bit of time to remember. And suddenly it all made some intuitive sense.

Along with numpy comes matplotlib for visualizing some of the data, and that's been fun, too. Now if only the results were as much fun...