Multiprocessing Niceness in Python

Quick and dirty one that tripped me up. Recently I’ve been doing lots of multiprocessing and joblib-based parallel processing, with loooong simulation times. In an effort to make sure that my machine was still useable during these runs, I changed the ’niceness’ value of the spawned processes… or so I thought. import os ... def thread_mask(args): # Properly Parallel RNG #http://stackoverflow.com/questions/444591/convert-a-string-of-bytes-into-an-int-python myid=current_process()._identity[0] np.random.seed(myid^struct.unpack("<L",os.urandom(4))[0]) os.nice(5) return long_simulation(args) First part is a handy way to make sure that your subprocess simulations actually use different random numbers…. which for Monte Carlo style simulation is pretty damned important… ...

May 7, 2014 · Andrew Bolster

Generating a unit 3 vector in Python (Uniform Spherical Projection)

Quick one more as a reminder to me than anything else. As part of my PhD work I’m building different behaviours for virtual submarines. I’ll be explaining some parts of my work in a separate post, but basically, I needed to random walk. Random walk in 2 dimensions is easy; pick two random numbers, go that way. Unfortunately doesn’t work that way on a spherical surface So to make things easier, I stole this StackOverflow answer from dmckee and tidied it up a bit for my purposes. (Assuming everyone else is like me and does import numpy as np) ...

April 9, 2014 · Andrew Bolster

Review: Learning Cython Programming

About 6 months ago now, I had the pleasure of getting Phil Herron to talk at the Farset Labs PyBelfast group about his work in GCC/Cython fron end optimisation work, which was simultaneously waaaaay over my head and really interesting. I’ve been a ‘Python Primary’ software engineer now for about 5 years, in web-dev, infrastructure monitoring, data analysis, and scientific computing, with some esoteric stuff involving small-vector linear algebra optimisation on GPU CUDA, Matlab bridging with Octave / Oct2Py, and distributed state systems. But somehow, I’ve managed to dodge hardcore Cython. ...

January 31, 2014 · Andrew Bolster

Octave 3.8 on Mint (or Ubuntu)

My work has be flittering between Python and Matlab recently, and lets say I’m not a massive fan of Matlab at the best of time, and VM matlab isn’t the most performant thing in the world. So I was happy to hear that octave, an open source, Matlab compatible analysis framework have started testing their GUI. Package Requirements sudo aptitude -y build-deps octave sudo aptitude -y install gfortran libgfortran3-dbg-arm64-cross liblapack-dev libblas-dev libarpack2-dev llvm-dev libfltk1.3-dev libglu1-mesa-dev libcurl4-gnutls-dev libfreetype6-dev libqt4-dev libfontconfig1-dev libfftw3-dev libqrupdate-dev libqscintilla2-designer texlive Download I used /dev/shm as the build directory as it’s effectivly a RAM disk, but YMMV. ...

January 22, 2014 · Andrew Bolster

Unicode Madness in Jekyll

Ok so this was a weird one. I’ve been lurking on #jekyll for a while, trying to ‘give back’ with slightly-more-than-noob-knowledge. Mostly it’s simple mistakes or misunderstandings that I went through myself, so easy enough. Then there was kaffeebohne and the infernal BOM. To make a long story short (And to index the Googles), the symptoms were that this source file in German (i.e. lots of tasty unicode ü’s etc) was garbling the unicode, not activating the template layouts, and basically not doing anything, while Jekyll was perfectly happy with no errors what so ever. ...

January 20, 2014 · Andrew Bolster

The Making of a Timelapse

Starting in May 2012 (a few weeks after we ‘opened’) I set up an eventcam in Farset Labs, and I don’t think I ever officially explained it… Well, first off we were using a Microsoft Lifecam that was kindly donated by Josh Holmes. This was wired up to an even-then-ancient Asus Eee 7001, wired with power and network, and left in the roof. That was about it. The Linux motion utility was used to drive the camera and after fiddling with motion’s many many options, I settled on this config file to strike a balance between dropping boring frames when nothing was happening but to also maintain ‘day night’ cycle more or less realistically. ...

January 11, 2014 · Andrew Bolster

Installing Ubuntu Touch on the Nexus 7

I’m always amazed by Canonical. Particularly their documentation. Ubuntu Touch is the grand movement to bring Ubuntu into the mobile domain, and it’s developing fast. Can’t say the same about the documentation; too long and doesn’t really make sense. And for what is actually a fantastically simple process, it deserves better. The phablet-flash folks have done an amazing job. So without further ado, the assumption: If you’re thinking of putting Ubuntu on your device, I’d say it’s reasonable to assume that: ...

December 20, 2013 · Andrew Bolster

TEDx: How it went and how it could have gone

So I did a TEDx Belfast, and had loads of fun (as you can probably see). Check out the rest of the playlist here, and I highly recommend fellow Dalriad, Leon McCarron’s talk on adventuring, Tony Gallagher’s discussion of the benefits and future of shared education, and definitely check out two talks that must have been spying on my preparations; Lisa McElherron talking about dissidents, and Charo Lanao-Madden on the power of changing perspectives. Thanks go to Davy and everyone else involved in running this great event! ...

December 19, 2013 · Andrew Bolster

Remember Remember ... November 1963?

Turns out that November 1963 was a pretty stupendous month all in all, in particular the couple of days (20-24) we’re currently wading through. C.S Lewis (Good Belfast Man) who was not only the beloved childrens author, but also an accomplished scholar, and one of the pioneers of the Science Fiction form, popped his clogs due to long term illness on Friday 22nd at around 2pm GMT aged 64 Aldous Huxley, one of the greatest thinkers of the 20th century and author of one of my favourite books (Brave New World) spun off his mortal coil at the age of 69 taking one more tab of LSD to lighten his passage at 5pm the same day ...

November 22, 2013 · Andrew Bolster

Response to the Draft Innovation Strategy for Northern Ireland - Part 2 - Knowledge Generation

See Part 1 for an introduction to this series. Response to Part 1 Two things came out of my posting of Part 1; I was “strongly encouraged” to have a look at the evidence pack as well as the initial strategy document (unfortunately changing what was intended to be a 3-part break down into more like a 8 part). So I’ll plod on through the rest of the strategy as read and then go through the evidence pack and see what got lost in the wash. ...

November 1, 2013 · Andrew Bolster