New Year But … er, a New Look

Yeah, yeah, happy arbitrary new year. What was wrong with having the new year begin on the first day of spring anyway? It makes a lot more sense than having it only a week after we celebrated the winter solstice by shoving presents under an evergreen tree (that, sigh, will soon be brown because we cut it down). Curmudgeonly impulses aside, I just wanted to note that the site is going to look a little different for a few days. It was time to update the PHP scripts that make the site go and it seemed best to use the latest offering from the WordPress folks themselves and then slowly hack the CSS back to something more of what the Logbook has looked like for the past year.

It’s not going completely back. I think the right sidebar is going to stick around, and so is my new friend L’hydre. I came across him on a crest having some connection to the town of Laudun, France, and I decided I kinda like the little guy. Hydras are apparently fairly rare in heraldry, and they represent the defeat of a significant enemy. For me, I like how friendly he looks. He’s an animal that would like to be able to fly (wings), clearly can make his way through the water (webbed feet), and has thoughts that go in too many directions (heads). Yup, I’m keeping him.

**UPDATE**: Okay, a new look. It was inevitable I suppose. I was looking for something that a more responsive design, in the sense that it would work well across a number of devices. I decided to give [Codium Extend][] a try. I’m fairly happy with it, except the “responsive” part of it makes for some pretty dense, and lengthy CSS. And I can’t quite get the gap between the posts and the sidebar to open up a bit more. That space feels too tight to me.

[Codium Extend]: http://wordpress.org/extend/themes/codium-extend

Hartmut Essinger

[DesignBoom](http://www.designboom.com/technology/hartmut-esslingers-early-apple-computer-and-tablet-designs/) has posted a lot of images from Hartmut Essinger’s archives detailing his early work with Apple. While the images are from 1982 to 1985, only a few of the designs were implemented during that period. The rest seemed to have seeped into the design consciousness of the company.

As I’ve noted before, I always like encountering past views of the future. What is really surprising about Essinger’s work is how *untied* it is to contemporary technological possibilities. The prototypes for a tablet computer and a notebook computer are particularly striking for just how close they were to what would come to be.

Joy = MacPorts (Python + Numpy + Scipy + Matplotlib + NLTK)

This is the TL:DR version of my previous post.

After installing [MacPorts](http://www.macports.org/install.php) via the package installer, open a terminal session and enter the following:

% sudo port selfupdate
% sudo port install python27
% sudo port install py27-numpy
% sudo port install py27-scipy
% sudo port install py27-matplotlib
% sudo port install py27-nltk
% sudo port install python_select
% sudo port select –set python python27

By the way, once I did all this. I was able to run a Python script that relied on `matplotlib` to run. *Sweet.*

MacPorts: The Key to Python Happiness

For those who want the TL;DR version which gives you all the commands you need to copy and paste into a terminal window, then it’s all here.

To do some of the work I do, I needed to have a working version of Python that included the numpy, scipy, and matplotlib libraries. I could not, however, get all these pieces to come together using homebrew. After trying a number of approaches from a variety of sources, I turned to StackOverflow for help. I got a response from tiago, who noted that “Homebrew and pip are great for minimalistic, pure python packages. But they stumble spectacularly with scipy or packages that require external non-python packages.” His advice was to turn, again, to MacPorts. (My first step was to un-install homebrew. After that, it was time to crank up the MacPorts assembly.)

Installing MacPorts

First, before you do anything else, you’ll need to make sure that you have Xcode’s command line tools installed. Installation is now as easy as typing the following in a terminal window:

xcode-select --install

You’ll get a GUI dialogue box, agree to the EULA, and then installation will happen. (And I believe software update / the App store will track updates for you.)

Second, Download the Mac OS X Package pkg Installer and step through the GUI install.

MacPorts should, as part of the install process, run sudo port selfupdate -v but you can always run it again. You know, just to make yourself feel better.

Third, you’ll need to install a version of Python. In my case, I am building a setup around Python 2.7, and so I entered sudo port -v install python27. The -v option gives you a verbose description of what’s happening. Be prepared to watch a lot of stuff scroll by. (If you’d rather not see all that and having the machine quietly do its thing, you can leave the -v off. Good for you for having quiet confidence in your Mac.)

MacPorts gives you some nice functionality with its search feature, which you can use to find MacPort portfiles. In my case, I wanted to start with numpy and so I entered port search numpy and got the following:

py-imread @0.2.5 (python, graphics)
    Reads images into numpy arrays

py-numpy @1.6.2 (python, math)
    The core utilities for the scientific library scipy for Python

py24-numpy @1.6.2 (python, math)
    The core utilities for the scientific library scipy for Python

py25-numpy @1.6.2 (python, math)
    The core utilities for the scientific library scipy for Python

py25-symeig @1.4 (python, science)
    Symeig - Symmetrical eigenvalue routines for NumPy.

py26-imread @0.2.5 (python, graphics)
    Reads images into numpy arrays

py26-numpy @1.6.2 (python, math)
    The core utilities for the scientific library scipy for Python

py26-scikits-audiolab @0.11.0 (python, science, audio)
    Audiolab is a python toolbox to read/write audio files from numpy arrays

py27-imread @0.2.5 (python, graphics)
    Reads images into numpy arrays

py27-numpy @1.6.2 (python, math)
    The core utilities for the scientific library scipy for Python

py31-numpy @1.6.2 (python, math)
    The core utilities for the scientific library scipy for Python

py32-numpy @1.6.2 (python, math)
    The core utilities for the scientific library scipy for Python

py33-numpy @1.6.2 (python, math)
    The core utilities for the scientific library scipy for Python

Found 13 ports.`

That py27-numpy is the one I want, and so I entered sudo port install py27-numpy. More scrolling. Done. Repeat these steps for scipy and matplotlib and nltk.

Finally, a crucial step is to make it so that your setup turns to your nice custom install of Python and not the one that came with the system. I usually accomplish this by editing my .bash_profile, but this did not work for me. Luckily, MacPorts has the solution: sudo port install python_select. Once you’ve done this, enter sudo port select --set python python27 and you’re done.

Is Your Python 64-bit?

Wouldn’t you like to know? I’d like to know because I’m trying to track down why I can’t get `matplotlib` to install. So I tried this:

>>> import sys
>>> is_64bits = sys.maxsize > 2**32
>>> print is_64bits
True

And back in the shell prompt:

% file -L $(python -c ‘import sys; print(sys.executable)’)
/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/
Resources/Python.app/Contents/MacOS/Python: Mach-O 64-bit executable x86_64

So I’m 64-bit with my [homebrew installation][].

[homebrew installation]: http://johnlaudun.org/20120131-nltk-on-mac-os-x/

What I Love about the Python Community

So I’m reading the [PIP documentation][], to see if there is a way to issue one `update` command either to update `pip` itself, a single library, or all libraries at once, when I come across this bit of documentation for bundles”

> ### Bundles

>> *Note Pip bundles are poorly supported, poorly tested, not widely used, and unnecessary (the same goals can be achieved by distributing a directory of sdists and using –find-links to reference it). The feature will likely be removed in a future version of pip.*

> Another way to distribute a set of libraries is a bundle format (specific to pip). This format is not stable at this time (there simply hasn’t been any feedback, nor a great deal of thought). A bundle file contains all the source for your package, and you can have pip install them all together. Once you have the bundle file further network access won’t be necessary.

I love that parenthetical clause: “there simply hasn’t been any feedback, nor a great deal of thought.” It’s refreshing to get an assertion that bold.

[PIP documentation]: http://www.pip-installer.org/en/latest/

Django on ASO

Hey, my own hosting service [A Small Orange][] supports running Python-based web apps. One user has a guide on [getting Django up and running on ASO][]. I’m not too interested in switching from WordPress at the moment, but I am in the midst of learning of Python, and it’s always good to have options.

[A Small Orange]:
http://asmallorange.com/
[getting Django up and running on ASO]:
https://help.asmallorange.com/index.php?/Knowledgebase/Article/View/140

Saturn as Seen by Cassini

Beautiful shot of Saturn from NASA’s Cassini space craft as it eclipses the sun:

Saturn as Seen by Cassini

This one is Lily who once wanted to be the first princess astronaut on Saturn and still maintains her interest in space and space travel. Thank you, my dear.

Python Text Processing for Freshmen

In my freshman introduction to academic writing, we do some reading, because, after all, you need something about which to write. I focus on a small group of texts because they can hold the evidence in their hands and because I teach how to think and work with texts when I am not introducing people to academic writing. That is, I assume that a biologist teaching an introduction to academic writing would use biological data as the basis for her course. That English professors are uniquely situated to teach academic writing, broadly construed, is something for another conversation. Or perhaps it is an empirical move on the English department’s part, to claim all of academic writing when what we know how to do, and thus can claim to teach, is writing about texts.

So we read a small number of texts, two of which are short stories and two of which are screenplays. All four of the texts are available to the students as both plain texts and PDFs. I have, in the past, used a collection of Java apps (applets) that allow students to do things like create word frequency lists, create word clouds, or examine word collocations. (For the latter I am entirely indebted to James Dombrowski for his excellent Wordij.) While running these apps does introduce students to the command line, it does not do much beyond that, and I would like, no matter how silly this seems, at least to introduce them to the idea that they can use a scripting language to do things in various dimensions of their lives. Plus I hope that, like me, they discover that learning to code is also a way to learn another way to think.

And so I have begun a hunt for a collection of Python scripts that do some of the things we already do in class and perhaps some scripts that take us new places.

*Please note that as of December 21 — Happy Mayan Apocalypse Day! — this post is still in process and this material is not yet curated. Plus, I’m really looking for feedback from readers on what kinds of text analysis they would want students to do. Keep in mind that this is not “big data” but single texts or a very small collection of texts.*

Okay, first thing we already do is generate a word frequency list, which we visualize both as bar charts and as word clouds. What good does this do? Well, first, it introduces the idea of *function words*, words which must be present in discourse for it to go but to which we, apparently, attribute very little meaning. Just as important as this idea is the idea that in addition to function words there is a list of other words within a text which do not have a significant impact on its meaning and which can be ignored: stopword lists are great for this because students get to make this happen, quite mechanically, and then see the results in their much more focused, and interesting, word clouds.

One thing that might be useful to add here is a script that lemmatizes the words in a text, or its resulting list of words.

Someone asked a question on StackExchange about [how Wordle creates its word clouds][], and they got an answer from a lot of people, including Wordle’s own Jonathon Feinberg. In particular, Reto Aebersold posted a link to his [PyTagCloud on GitHub][]. There is also a link to someone creating a word cloud with Processing, but that’s for another time. (I am thinking, for a technical writing course, how we could take some of these outputs, feed them into Processing, and then have some sort of real world output, using something like Arduino. Oh, yeah, I’m ready to have some fun.)

And then there’s this interesting bit of code, [Story Statistics on DaniWeb][]. I’m

### About the Texts

For those who are curious, the texts are:

* Richard Connell’s “The Most Dangerous Game”
* Frederic Brown’s “Arena”
* Star Trek (The Original Series) “Arena”
* Star Trek: The Next Generation “Darmok”

[how Wordle creates its word clouds]: http://stackoverflow.com/questions/342687/algorithm-to-implement-a-word-cloud-like-wordle
[PyTagCloud on GitHub]: http://github.com/atizo/PyTagCloud
[Story Statistics on DaniWeb]: http://www.daniweb.com/software-development/python/code/228125/story-statistics-python

TED Weekends

Okay, stop me if it feels like things are getting pushed just a little too far, but the Huffington Post now has a featured called [TED Weekends][]. The blurb in the lower part of the lefthand column reads: “TEDWeekends will highlight some of today’s most intriguing ideas and allow them to develop in real time through your voice!” Sorry, but I’ve seen the [TED discussions on LinkedIn][] — and that’s why this feels like the push too far — and it’s really very much a producer-consumer dynamic: you little people can talk among yourselves. I have never seen any of the TED authors or even any of the TED staff show up in any of those discussions.

Make no mistake, there is some great content on TED, but how long can you milk Ken Robinson’s “Do Schools Kill Creativity?” And this is from someone who came across it the same year the video was published and has used it in his classes ever since.

This feels, in this moment, a lot like the FoodNetwork, which made a small list of chef/personalities famous but hasn’t really been able to grow beyond that moment. In part, in the case of FoodNetwork, one has the sense that they can’t quite figure out what worked so well in the first place and so they can’t quite give up their first stars. They may have gotten past this, in part, with their, televised even, search for their next stars, which had produced a limited cast of useful characters. And Guy Fieri.

And so maybe the question is who will be TED’s Guy? Because when they find him, we’ll know it’s time.

[TED Weekends]: http://www.huffingtonpost.com/tedweekends/
[TED discussions on LinkedIn]: http://www.linkedin.com/groups?gid=138801&trk=group-name