I recently discovered the following behavior when fetching values
from a Numeric array. Can somebody offer some insight?
a = Numeric.zeros((2, 2), 'i')
n = a[1, 1] # fetch interesting value from array
a[1, 1] = 10 # change array
print n # blam
print type(n) # huh
[bash]$ python 1.py
a = Numeric.zeros((2,), 'i')
n = a
a = 10
[bash]$ python 2.py
#2 works the way one would expect, and #1 does not (n changes).
They should at least both behave the same. :-) At a minimum, naive
use of arrays can lead to confusing or disastrous results, since
a single value fetched from an array can change behind your back.
It appears n is aliased into a, but preserves its value when a is
deleted (with del(a)). What happens to the "rest of" a?
I'm using Python 2.2, Numeric-21.0, on both Unix and Win32.
PyQwt = FAST and EASY data plotting for Python, Numeric and Qt!
PyQwt is a set of Python bindings for the Qwt C++ class library.
The Qwt library extends the Qt framework with widgets for
scientific and engineering applications. It contains QwtPlot,
a 2d plotting widget, and widgets for data input/output such as
and QwtCounter, QwtKnob, QwtThermo and QwtWheel.
PyQwt requires and extends PyQt, a set of Python bindings for Qt.
PyQwt requires Numeric. Numeric extends the Python language
with new data types that make Python an ideal language for
numerical computing and experimentation (maybe less efficient
than MatLab, but more expressive).
The home page of PyQwt is http://gerard.vermeulen.free.fr
NEW and IMPORTANT FEATURES of PyQwt-sip324_041:
1. requires PyQt-3.2.4 and sip-3.2.4.
2. implements practically all public and protected member
functions of Qwt-0.4.1.
3. compatible with Numeric-21.0 and lower.
4. simplified setup.py script for Unix/Linux and Windows.
5. *.exe installer for Windows (requires Qt-2.3.0-NC).
6. HTML documentation with installation instructions and a
reference listing the Python calls to PyQwt that are different
from the corresponding C++ calls to Qwt.
7. Tested on Linux with Qt-2.3.1 and Qt-3.0.4. Tested on Windows
I've found that the following fragment of code gives an error while with
other shapes of b there is no problem:
from Numeric import *
from Matrix import *
a = Matrix(zeros([4,4]))
b = Matrix(ones([2,1]))
print a, a.shape
print b, b.shape
q = a[1:3,1:2]
print q, q.shape
a[1:3,1:2] = b
Matrix([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]]) (4, 4)
]) (2, 1)
]) (2, 1)
Traceback (most recent call last):
File "./numpybug.py", line 11, in ?
a[1:3,1:2] = b
File "/usr/lib/python2.1/site-packages/Numeric/Matrix.py", line 180, in
def __setitem__(self, index, value): self.array[index] =
ValueError: matrices are not aligned for copy
The mentioned behaviour looks like a bug, because
a[1:3,1:2] and b have the same shape and according to docs
b must be copied to a-slice 1:1...
Numeric is version 21.0, Python 2.1 under Linux RedHat 7.2.
Thank you in advance!
Sincerely yours, Roman Suzi
\_ Russia \_ Karelia \_ Petrozavodsk \_ rnd(a)onego.ru \_
\_ Saturday, May 18, 2002 \_ Powered by Linux RedHat 7.2 \_
I submitted this to the Sourceforge bug tracker, but wanted also to let this
list know, as this is a potentially nasty bug.
MLab.std() gives completely incorrect answers for multidimensional arrays
when axis != 0.
array([[[ 1., 1., 1.],
[ 2., 2., 2.],
[ 3., 3., 3.]],
[[ 1., 4., 4.],
[ 2., 5., 5.],
[ 3., 6., 6.]]])
array([[ 0. , 2.12132034, 2.12132034],
[ 0. , 2.12132034, 2.12132034],
[ 0. , 2.12132034, 2.12132034]])
>>> std(foo, 1)
array([[ 0., 0., 0.],
[ 0., 0., 0.]])
The following should fix the problem (but I haven't tested it extensively):
"""std(m,axis=0) returns the standard deviation along the given
dimension of m. The result is unbiased with division by N-1.
If m is of integer type returns a floating point answer.
x = asarray(m)
n = float(x.shape[axis])
x2 = mean(x * x, axis)
x = mean(x, axis)
return sqrt((x2 - x * x) * n /(n-1.0))
Doing my first install on a linux system (Mandrake 8.2 on a PPC).
I downloaded the *.tar.gz and unzip/untarred it. I enter the command
'python setup.py install' and get the following error
"open '/usr/lib/python2.2/config/Makefile' (No such file or directory)"
This is the python that comes with mandrake. I have been able to download
and install a new version of python2.2 and sucessfully install Numpy there
but I was wondering what I needed to do to get it running in the 'base'
any pointers ?
i'm interested in this too?
in fact i am willing to help write some wavelet tools for python - but
you'll have to be patient as i've only just started on my PyObjects et al
... and i'm not an expert either - just very interested and entheusiastic!
[mailto:firstname.lastname@example.org]On Behalf Of
Sent: 22 May 2002 20:05
Subject: Numpy-discussion digest, Vol 1 #463 - 1 msg
Send Numpy-discussion mailing list submissions to
To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Numpy-discussion digest..."
1. Q: Wavelet tools with Python (Zaur Shiboukhov)
I'm happy to announce that Enthought is developing a platform independent
plotting library for Python. The Chaco project, as it is named, is funded by
the Space Telescope Science Institute (STScI) and licensed under a BSD style
open source license. Chaco is designed for presentation quality scientific 2D
graphics on a variety of output devices. The initial targets are wxPython,
TkInter, Mac OS X, and PDF for hard copy output. It's design is extensible so
that other backends, such as OpenGL, can be added. Currently, the low-level API
for wxPython, Mac OS X, and PDF are operational. The high level graphics
objects will be developed over the coming months. Chaco is hosted at the SciPy
site. For more information visit:
People are invited to comment on and contribute to the project. Chaco's
To subscribe, go to the mailing list's info page:
Eric Jones <eric at enthought.com>
Enthought, Inc. [www.enthought.com and www.scipy.org]