Saturday, June 22, 2013

Software Carpentry

I'm taking a Software Carpentry bootcamp on Monday and Tuesday. It is a two-day workshop to make you a more productive programming. I'm most comfortable programming in Ubuntu (what we use in lab), so I'm borrowing my friend's laptop for the course (until I get my own dedicated Ubuntu programming machine). I need to install required software for the course. I'll be installing this on my machine once I get it, so I'm keeping a record of how to do the installations here:

6 required packages:
1) Bash. This is the default shell in linux! Win #1 for using linux! No intallation needed here.
2) Git. I checked the version with "git --version" and got "git version 1.8.1.2" Latest stable release is 1.8.3.1. I'll run "sudo apt-get upgrade" just to make sure there isn't a newer version in the Ubuntu package manater.
3) Code editor. I've been looking for a better code editor. The course staff recommends Kate. I'll download that and give it a try. "sudo apt-get install kate." I also want gedit... my old stand-by, just in case. It was already installed! There is a warning when I start it, but other people in web forum say just to ignore.
4) Python version 2.7. They recommend Anaconda for an all-in-one installation. I have used enthought before. I have Python 2.7.4 ("python --version"). But, I don't have ipython. I'll try installing Anaconda and see if that gets me all the way. Download took about 20 minutes, but the installation is running well after accepting a user agreement.
5) SQL. Install SQLite manager (requires firefox). This is just a firefox add on. Needed to make the bookmarks toolbar visible before I could see the SQLite icon.
6) Lastly, virtual box and a virtual machine in case the rest didn't work.

The test script passed! Success!

The only other things I know I want are LaTex and Mayavi.

Thursday, June 20, 2013

"The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"

I see the error in the post title a lot when I'm trying to check values in arrays. I'm finally going to really figure out what it means by a.any() and a.all()!

I have a four element array, and I want to know if it has any 1's in it:

a = array([2, 3, 3, 2])
a.any()

This will return True, because it is checking to see if any of the elements in a are greater than zero. This is not helpful. We need to define an intermediate matrix that has truth values for the condition we want to test.

a = array([2, 3, 3, 2])
b =  a==0
b.any()

works!

Or,

a = array([2, 3, 3, 2])
any(a>0)

works!

a.all()  and all() should work in the same way, but be testing for ALL the values to be true.