[Numpy-discussion] Numeric3
konrad.hinsen at laposte.net
konrad.hinsen at laposte.net
Mon Feb 7 01:48:28 CST 2005
On 06.02.2005, at 19:33, Stephen Walton wrote:
> I'm both largely a lurker here and a Python naif, at least when it
> comes to the more object oriented aspects. I'd be interested in
> seeing snippets of code illustrating the second approach here, as
> opposed to the array oriented approach with which I'm familiar.
>
You can find lots of examples in my ScientificPython library
(http://dirac.cnrs-orleans.fr/ScientificPython/). Some examples:
- Geometry. Array people would use arrays of shape (3,) to represent
points in 3D space. I use objects of class Scientific.Geometry.Vector.
Array people would also store rotation matrices in arrays of shape (3,
3), whereas I use the class Scientific.Geometry.
Transformation.Rotation.
- Function values on a grid. Array people would have an array of x
values (the grid) plus an array of y values, or a 2D array combining
both. I use instances of Scientific.Functions.InterpolatingFunction.
- Histograms. Array people would store a histogram in an array of bin
counts. I use the class Scientific.Statistics.Histogram.Histogram.
The rational behind these choices is the usual one cited for OO
approaches: the use of abstractions to increase readability and to
permit alternate implementations.
However, my experience with both programming and physics teaching shows
that the level of comfort for abstraction levels is not the same for
everyone. For example, some people (including myself) get a better
understanding of quantum mechanics when working with quantum states as
abstractions, whereas others prefer to work with wavefunctions (which
are the space representations of quantum states). Fortunately there are
textbooks for both groups.
My impression is that the optimal abstraction level is higher for
scientists than for engineers, though my data is perhaps a bit to weak
to back up such a conclusion. It doesn't really matter either.
Konrad.
More information about the Numpy-discussion
mailing list