[PYTHON MATRIX-SIG] New Tutorial / Some Questions
David Ascher
da@maigret.cog.brown.edu
Sun, 4 Feb 1996 18:00:26 -0500 (EST)
Given that I'm starting a course on Python on Tuesday for a bunch of
neural net folks, I had to take a good hard look at the Numeric package.
Jim H. has gotten more mail from me than he probably wanted. The good
thing is that I didn't see myself teaching them about a feature that had
no documentation. So, I started a more detailed tutorial than that Jim
shipped in 0.33. I aimed it at people who have very little python
experience, and no prior experience w/ matlab, basis, yorick or anything
like it (i.e. undergraduates =). It's obviously too basic for the
folks in this SIG, but I'd appreciate it if you could give it a
once-over and make sure I'm not lying outright.
It's available at http://maigret.cog.brown.edu/python/arraytut.html
for now. It is very much under construction (I haven't explained rubber
indices and pseudo indices, for example, mostly because I'm not sure I
understand them yet).
I came up with a few questions in the process. Some have gone to jim
h. and hinsen, but I thought I'd spread the load:
1. I can't seem to find the counterpart to the toFile() method.
I've tried just the array constructor w/ a file object, which I
thought might work, but I get:
>>> a
0 0 1
0 0 0
1 2 3
>>> f = open('myarray', 'w')
>>> a.toFile(f)
>>> f.close()
>>> f = open('myarray', 'r')
>>> b = array(f)
>>> b
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python/numeric/Numeric.py", line 37, in
arrayToString
items_per_line = a.shape[-1]
IndexError: tuple index out of range
2. The choose() and take() methods are a little fuzzy for me. Can
someone give me a description of what they do, and more useful even
examples of why they're useful?
3. Shouldn't typecodes look more like real types than strings, sort of
like exceptions?
>>> b.typecode()
'l'
vs.
>>> b.typecode()
LongInteger or whatever.
That's all for now. Let me know what you think of the tutorial.
--david
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================