Posted on June 26, 2013 by

A Numpy CodeKata

On Tuesday NOVAPython put on its very first CodeKata at the Excella Consulting offices in Arlington VA. The Kata was focused on using Numpy in place of list iteration in Python programs. We hosted the problems in the NOVAPython github repository, and people worked in teams to solve the problems. After the problems were solved, solutions were discussed and ideas were exchanged. As usual, I want to reflect a little on what went well and what went not-so-well.


Excella was great. The room was perfect, the food was tasty, and the internet was fast. The room was laid out with 10 2-person desks. This created a very simple pair programming setup that forced perhaps-otherwise-introverted-developers to work together and share ideas. The projector made it easy to go over examples, and let people plug in to share their own solutions. All in all, the location and environment were perfect.

Numpy Problems

Our goal was to change your mode of thinking from simple list iteration to applying functions to arrays and matrices. In order to do this, Jonathan Street and Skipper Seabold wrote some great problems and also wrote a naive solution to each of those problems using list iteration. We asked the attendees to solve the problems using Numpy. We wanted people to see the difference in the code, and be able to look at a familiar Python solution to help explain the new Numpy solution.

This is were we hit a few snags.

  1. Numpy has a huge function set and everything we wanted to do was already built into Numpy. It was possible to write your own code to solve the problems, but it was also very easy to simply search the documentation for functions.
  2. To really explore Numpy, you need a strong math background. I don’t mean a Wiki search for matrix multiplication either. I mean understanding how some of these equations work, and when you can use what for speed. I can’t give examples because I don’t have the strong background required. I just know that solutions were presented and some attendees would nod and say “Oh that is an interesting way to do that” and I didn’t know why.
  3. It was impossible to estimate problem completion time. Amazingly enough we only had one problem left when we had to wrap up, which I consider perfect. I feel like the problems were almost like trivia though. If you understood the type of problem, you knew just what kind of Numpy function to use.

Next Time

Suggestions were made, and I hope they keep coming in.

  1. More visual. We concentrated on correct answers and execution time (silly developers). But what about working with graphs or waves or point distributions? Visually see your progress as you go through the problem set. I think this makes a lot of sense.
  2. More collaborative code. As usual, we had Linux/OSX/Windows users. I wanted to get the code out to the attendees early, so we used Github. But there are several tools (Anaconda, IPython, Wakari) that would allow everyone to build graphs and share through notebooks to the main projector. I think this is also a good way to go for the next one


It seems that everyone learned something and it was worth while to show up. I think by narrowing the goal of the Kata, we can come up with more focused problems and really work on some specific skills. I think by following the suggestions from the attendees, the next Kata will be even better.