[SciPy-user] NumPy in Teaching

Gary Ruben gruben at bigpond.net.au
Thu Mar 1 08:07:22 EST 2007


Hi Steven,

Last year I helped out in teaching some basic programming with no 
prerequisites to 3rd year undergrad physics students at Monash 
University. It was really a 1st or 2nd year level course, but we had a 
wide spectrum of background experience levels - from no programming 
experience to proficient in C++. To deal with this variation in 
experience, we created some basic and some more advanced teaching labs. 
We divided the subject in half, giving a single C lecture first, 
followed by a few C labs, then a single Python lecture followed by a few 
Python labs; a deliberately chosen order and obviously very ambitious.

Our department is fairly IDL-centric, but Python's advantage of being 
free and its greater general applicability/flexibility was accepted by 
the course coordinator as sufficient reason to teach it. The hope is to 
get continuing 4th year honours students comfortable with a language for 
their 4th year physics projects.

We took the view - shared by colleagues in the Computer Science dept. - 
that getting the students to struggle with pointers and see the C-syntax 
would be good for their character :-) and that numpy would allow much 
higher level tasks to be attempted at an early stage and would get them 
used to using an array-processing mindset. I think that, since some of 
the students had prior C experience, they were able to help each other a 
bit more in the C labs. We found that we were busier answering questions 
in the Python labs as a result.

We had them create arrays in C, populating them with sinc functions to 
get them to deal with division by zero etc. and repeat the exercise in 
Python with numpy. We had them do some file i/o in both languages - I 
used scipy.io read_array and write_array to read data printf'ed by their 
C code. We did some fft-based filtering with Python and used pylab to 
view the results. We used Enthought Python with "ipython -pylab" shells 
and Idle as the editor. One lesson learned is that I tried to be a bit 
too ambitious with Python - they struggled with trying to figure out how 
to use functions. The labs were written as a mixture of "modify this 
example" code and "find the function which does this" - they found the 
latter too hard because the number of functions in numpy/scipy is a bit 
overwhelming and not easily navigable for the uninitiated.

We'll be re-running this course in a few weeks and perhaps introducing a 
physics modelling/numerical methods subject (perhaps language-neutral) 
later in the year. It may also be a prerequisite for some of the 3rd 
year astronomical data processing labs currently being written.

Gary R.

Steven H. Rogers wrote:
> I'm doing an informal survey on the use of Array Programming Languages 
> for teaching.  If you're using NumPy in this manner I'd like to hear 
> from you.  What subject was/is taught, academic level, results, lessons 
> learned, etc.
> 
> Regards,
> Steve




More information about the SciPy-User mailing list