i have a simple array with floating values
>>> print a
array([ 0. , 0.2, 0.4, 0.6, 0.8])
what i need to do is change each index into another
dimension with 3 indices. hmm, kind of confusing, an
example will explain better
>>> b = array(zip(a,a,a))
>>> print b
array([[ 0. , 0. , 0. ],
[ 0.2, 0.2, 0.2],
[ 0.4, 0.4, 0.4],
[ 0.6, 0.6, 0.6],
[ 0.8, 0.8, 0.8]])
ok, this does the job, but once i start using large
arrays, the back-n-forth conversion between arrays and
python lists is costing me quite a bit. is there a way
i can reshape the array this way without the call to
python's 'zip'? (no, 'map' doesn't count either)
i've tried much fooling with NewAxis, resize, and friends.
but either i haven't stumbled upon the correct combination
or i'm not trying the correct tools. i'd like to keep this
as quick as possible, so hopefully it can be done without
anything too elaborate.
(doh, sorry for the previous distutils related post...
hit the wrong mailing list)
When attempting to install Numeric 17.0 with Python 1.5.2 and Distutils 1.0
on Red Hat 7.0, I get the following error after issuing the command 'python
Traceback (innermost last):
File "setup.py", line 15, in ?
vs = map(string.atoi, v.groups())
AttributeError: 'None' object has no attribute 'groups'
This error occurs regardless of whether or not I am root. I have also tried
uninstalling the Red Hat Python packages and installing all from source, but I
get the same error.
Any help would be appreciated.
Because the Numpy sub-packages use '#include "Numeric/arratobject.h", the
Numeric package will not build from scratch. This may not matter if one
does a 'python setup_all.py install' as long as the base Numeric package is
installed before the sub-packages are built. I don't think that this is
what setup_all.py does because the core setup.py is called with no
arguments. In any case, I'm trying to build RPMs and the build and install
processes are seperated.
In order to build the packages seprately I am now putting a symbolic link in
each package's Include directory called Numeric that points to the Include
directory for the core package. I would like to suggest that the core
header files be put in a directory 'Include/Numeric' rather than directly in
'Include'. That way the header file locations more acurately mirror the way
that they are installed.
At 3:14 PM -0700 14/9/00, <dubois(a)users.sourceforge.net> wrote:
>Well, I certainly didn't mean to flame anyone in particular, so I'm sorry
>that Frank was offended.
Publicly apologized, and publicly accepted. I'm sorry I lost my cool.
Ray Beausoleil and I are having a look at this too. He's coming at
the problem from a Windows perspective, and I'm coming at it from a
It's going to be a little slow going for me at first, since it
appears that I'm going to have to get my head around the distutils
way of doing things....
Just in case it saves anyone else following a false lead, yes, there
is a bug in the (Linux Mandrake 7.1; but probably any unix-ish box)
compile line for building the lapack_lite.so shared library (i.e.
what is generated on my box is "-L/usr/lib-llapack" which obviously
is missing a blank before the "-llapack" substring). However, when I
coerced the distutils system to get around that bug (by specifying
"/usr/lib " with a trailing blank for the BLASLIBDIR and LAPACKLIBDIR
variables in setup.py) the same problem (i.e. an "ImportError:
/usr/lib/liblapack.so.3: undefined symbol: e_wsfe" in importing
lapack_lite) ultimately manifested itself. So my advice is not to
bother tracking that one down (although it probably should be
reported as a bug in distutils, since adding that trailing blank
algorithmically instead of in a user modifiable configuration string
is the "right thing to do", TM.).
I'm still puzzled by Thomas Breul's report of preloading an f2c
library squashing the bug under RedHat 6.2(?). That does not work
under Mandrake, although clearly there is some bloody symbol table
missing from somewhere. The trouble is to find out where, and then to
coerce distutils to deal with that in a portable way...
Frank Horowitz frank(a)ned.dem.csiro.au
CSIRO-Exploration & Mining, PO Box 437, Nedlands, WA 6009, AUSTRALIA
Direct: +61 8 9284 8431; FAX: +61 8 9389 1906; Reception: +61 8 9389 8421
Sorry this is in HTML, but the documentation below requires it.
The latest source release is 17.2.0.
Revised documentation in HTML and PDF is available at
Package MA contains a number of new constructors. The complete list is:
Constructing masked arrays
1.. array (data, typecode = None, copy = 1, savespace = 0, mask = None,
fill_value = None) creates a masked array with the given data and mask. The
name array is simply an alias for the class name, MA. This constructor sets
the data area of the resulting masked array to filled (data, value =
fill_value, copy = copy, savespace = savespace), the mask to make_mask
(mask, savespace), and the fill value is set to fill_value. The class name
MA may also be used instead of the name array.
2.. masked_array (data, mask = None, fill_value = None) is an easier to
use version of array, for the common case of typecode = None, copy = 0. When
data is newly-created this function can be used to make it a masked array
without copying the data if data is already a Numeric array.
3.. masked_values (data, value, rtol=1.e-5, atol=1.e-8, typecode = None,
copy = 1, savespace = 0) constructs a masked array whose mask is set at
those places where
abs (data - value) < atol + rtol * abs (data).
That is a careful way of saying that those elements of the data that have
value = value (to within a tolerance) are to be treated as invalid.
4.. masked_object (data, value, copy=1, savespace=0) creates a masked
array with those entries marked invalid that are equal to value. Again, copy
and savespace are passed on to the Numeric array constructor.
5.. masked_where (condition, data) creates a masked array whose shape is
that of condition, whose values are those of data, and which is masked where
elements of condition are true.
6.. masked_greater (data, value) is equivalent to masked_where
(greater(data, value), data)). Similarly, masked_greater_equal,
masked_equal, masked_not_equal, masked_less, masked_less_equal are called in
the same way with the obvious meanings. Note that for floating point data,
masked_values is preferable to masked_equal in most cases.
On entry to any of these constructors, data must be any object which the
Numeric package can accept to create an array (with the desired typecode, if
specified). The mask if given must be None or any object that can be turned
into a Numeric array of integer type (it will be converted to typecode
MaskType, if necessary), have the same shape as data, and contain only
values of 0 or 1.
If the mask is not None but its shape does not match that of data, an
exception will be thrown, unless one of the two is of length 1, in which
case the scalar will be resized (using Numeric.resize) to match the other.
I'm playing around with CXX because I'm going to be writing an extension in
the next few days. I'm on WinNT running Microsoft Visual C++ 6.0 with
service pack 3 installed. Also, Python 2.0. I've gotten all of CXX-5.0b
to compile, and I compiled the demo. This required a slight edit of
cxx_extensions.cxx which was documented in the SourceForge buglist for CXX.
I was pleasantly surprised that VC++ was able to compile this code.
However, when I import CXX.example python crashes. Is this a known
problem, is there a workaround, or should I try CXX-4.2 instead? For some
reason, I am really adverse to writing another extension using C.
I uploaded Numeric 17.2.0 but then got errors from Sourceforge's web pages
for actually releasing it. I'm going to wait a day or two and try again. I
may be forced to renumber around the one that is already there. I don't
think users can actually see this file yet.
CVS is up to date with what will become 17.2.? when I finally succeed.
I took the liberty to forward your email to
The only document i know of is located at the Python
---------- Forwarded message ----------
Date: 13 Dec 2000 11:27:08 +0000
From: José Luis Gómez Dans <j.l.gomez-dans(a)sheffield.ac.uk>
Subject: Tutorial in Numerical Python?
I am wondering whether such a thing exists. Is there a nice
tutorial for NumPy that guides you through the basic steps? Say, a
little hands-on introduction to Linear Algebra, Transforms and
possibly the inclusion of some of the graphic modules?
There are some willing students to be converted around these
parts, and a hands-on tutorial would be great. Unfortunately, I am a
beginner in these waters myself, but can see the opportunity for this.
Thanks in advance,
José L Gómez Dans PhD student
Tel: +44 114 222 5582 Radar & Communications Group
FAX; +44 870 132 2990 Department of Electronic Engineering
University of Sheffield UK
I'm trying to find out what format a matrix input file should have in
I have the matrix :
[[1 2 3
4 5 6
7 8 9]]
and want to read it to nympy from a text-filen that is easy for a user
to generate in an editor.
Can you tell me how to do that. I read the manual and it didnøt given
much af on idea.
I thank you in advance
Peter I. Hansen