From rex@apl.washington.edu  Fri Dec  3 01:20:26 1999
From: rex@apl.washington.edu (Rex Andrew)
Date: Thu, 2 Dec 1999 17:20:26 -0800 (PST)
Subject: [Matrix-SIG] Q: scientific netcdf crashes python on import?
Message-ID: <Pine.GSO.4.10.9912021709330.25544-100000@kraken.apl.washington.edu>

Hi folks. I've spent about 8 hours on this one, so maybe I could
use some help. I'm trying to install the netCDF module from 
ScientificPython on a RH 6.0 linux box. The error is:
	Fatal python error: can't initialize module Scientific_netcdf
The crash obviously occurs in NetCDF.py on the line
>>>from Scientific_netcdf import *

OK, not being a guru, I tried (1) loading all the python RPMs and the 
new ScientificPython RPM, and/or (2) building both (and including
NumPy source to do so) from source. Several times, in case I wasn't
cleaning up after myself. To  no avail.

I tried launching python in gdb, but I'm pretty inept here.
I got python to crash with this error message:
gdb: program received signal SIGABRT Aborted
0x40066111 in __kill() from /lib/libc.so.6

Advice?


-rex "lost in linux land"


-------------------------
Rex K. Andrew                                  randrew@apl.washington.edu
Applied Physics Laboratory	                             206.543.1250
University of Washington                               206.543.6785 (FAX)
Seattle, Washington, USA             http://staff.washington.edu/rxandrew



From hinsen@cnrs-orleans.fr  Fri Dec  3 15:59:05 1999
From: hinsen@cnrs-orleans.fr (Konrad Hinsen)
Date: Fri, 3 Dec 1999 16:59:05 +0100
Subject: [Matrix-SIG] Q: scientific netcdf crashes python on import?
In-Reply-To: <Pine.GSO.4.10.9912021709330.25544-100000@kraken.apl.washington.edu>
 (message from Rex Andrew on Thu, 2 Dec 1999 17:20:26 -0800 (PST))
References: <Pine.GSO.4.10.9912021709330.25544-100000@kraken.apl.washington.edu>
Message-ID: <199912031559.QAA12085@chinon.cnrs-orleans.fr>

> Hi folks. I've spent about 8 hours on this one, so maybe I could
> use some help. I'm trying to install the netCDF module from 
> ScientificPython on a RH 6.0 linux box. The error is:
> 	Fatal python error: can't initialize module Scientific_netcdf
> The crash obviously occurs in NetCDF.py on the line
> >>>from Scientific_netcdf import *

Can you import Numerical Python correctly? Just start Python and type
"import Numeric". If that doesn't work, importing netCDF won't work
either, because it does the equivalent of "import Numeric" internally.
That (i.e. a missing or faulty NumPy installation) is the most
frequent cause for this error message in my experience. Also check if
your netCDF library is working (e.g. by running the ncdump utility).

> OK, not being a guru, I tried (1) loading all the python RPMs and the 
> new ScientificPython RPM, and/or (2) building both (and including
> NumPy source to do so) from source. Several times, in case I wasn't
> cleaning up after myself. To  no avail.

Which RPMs are you using? My laptop is a RedHat 6.0 system as well,
and it runs everything fine, using the RedHat Python RPMs, the NumPy
RPMs from Oliver Andrich's collection, and the ScientificPython RPMs
from my Web site.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------


From Robert.Harrison@pnl.gov  Thu Dec  9 22:14:54 1999
From: Robert.Harrison@pnl.gov (Harrison, Robert J)
Date: Thu, 09 Dec 1999 14:14:54 -0800
Subject: [Matrix-SIG] Version 1.0 of Python Interface to Global Arrrays
Message-ID: <D3D015A6FA03D31189D70008C7247D423054FF@pnlmse15.pnl.gov>

The link at the bottom is to an initial Python wrapper around the
Global Arrays library.  This is a numerically-oriented, portable, 
parallel programming environment including distributed, shared,
multi-dimension arrays with both one-sided and collective 
operations, message passing, and interfaces to parallel BLAS and 
linear algebra packages.  The Numeric extension is used to 
handle local data.

For sometime we've been using Python embedded into our
massively parallel computational chemistry code in order to
provide the end-user with the ability to control fairly
high-level capabilities.  However, we've become so enamored 
with Python that we're considering exposing a lot more 
of our C and Fortran APIs.  Most of these APIs are specific
to our application (molecular and solid state electronic structure
and molecular dynamics), but the parallel programming tools
may be of wider interest, hence this post.

The GA library (C and Fortran interfaces, and the Python interface) 
is freely distributed in the public domain, and, since many projects
rely upon it, it is well supported. It runs on every parallel 
computing platform to which we have access including both massively
parallel super-computers and clusters of SMP workstations. GA 
inter-operates with any of the MPI, TCGMSG or PVM message passing
libraries (the Python interface has only been tested with MPI and
TCGMSG).

There are many things still to do, including understanding how to
use the multiarray object to provide slicing, but the current
version is sufficiently complete and robust to be useful.

http://www.emsl.pnl.gov:2080/proj/tms/hpcc_actinides/pyGA/


Robert Harrison (robert.harrison@pnl.gov)


From johann@physics.berkeley.edu  Mon Dec 13 19:55:54 1999
From: johann@physics.berkeley.edu (Johann Hibschman)
Date: 13 Dec 1999 11:55:54 -0800
Subject: [Matrix-SIG] SWIG with recent NumPy
Message-ID: <mtln6y7gz9.fsf@astron.berkeley.edu>

Hello,

I'm trying to use SWIG to automatically wrap some C routines and
return the results as NumPy arrays (converting from my own pet vector
structure.)  I have typemaps that worked with old versions of NumPy,
but now I have had to insert a call to "import_array()" by hand in the
SWIG-generated C module in the module initialization section.

This means (AFAIK) that I have to hand-patch the C every time I run
SWIG.  That's bad.  Is there any way to get SWIG to insert the needed
"import_array()" call automatically?  Also, are there standard NumPy
SWIG typemaps?

Lots of questions, as ususal.  ;-)

--Johann

-- 
Johann Hibschman                           johann@physics.berkeley.edu


From managan@llnl.gov  Mon Dec 13 20:11:31 1999
From: managan@llnl.gov (Rob Managan)
Date: Mon, 13 Dec 1999 12:11:31 -0800
Subject: [Matrix-SIG] SWIG with recent NumPy
In-Reply-To: <mtln6y7gz9.fsf@astron.berkeley.edu>
References: <mtln6y7gz9.fsf@astron.berkeley.edu>
Message-ID: <v04210102b47b02af5882@[128.115.232.99]>

>Hello,
>
>I'm trying to use SWIG to automatically wrap some C routines and
>return the results as NumPy arrays (converting from my own pet vector
>structure.)  I have typemaps that worked with old versions of NumPy,
>but now I have had to insert a call to "import_array()" by hand in the
>SWIG-generated C module in the module initialization section.
>
>This means (AFAIK) that I have to hand-patch the C every time I run
>SWIG.  That's bad.  Is there any way to get SWIG to insert the needed
>"import_array()" call automatically?  Also, are there standard NumPy
>SWIG typemaps?
>
>Lots of questions, as ususal.  ;-)
>

I was about to start looking into this myself. Could you send me a 
copy of the typemaps so I can see if I can use them? I will be 
getting to this after the holidays.

  I think that what you want for the "import _array()" is the %init %{ 
... %} option in SWIG. It claims that code you insert in this block 
will be added to the initialization routine.

*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-
Rob Managan       <mailto://managan@llnl.gov>
LLNL                      ph:  925-423-0903
P.O. Box 808, L-095       FAX: 925-422-3389
Livermore, CA  94551-0808



From pavlos@gaaros.msrc.sunysb.edu  Mon Dec 13 20:38:49 1999
From: pavlos@gaaros.msrc.sunysb.edu (Pavlos Christoforou)
Date: Mon, 13 Dec 1999 15:38:49 -0500 (EST)
Subject: [Matrix-SIG] SWIG with recent NumPy
In-Reply-To: <v04210102b47b02af5882@[128.115.232.99]>
Message-ID: <Pine.LNX.4.04.9912131536020.32332-200000@gaaros.msrc.sunysb.edu>

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--830597660-686800328-945117529=:32332
Content-Type: TEXT/PLAIN; charset=US-ASCII

Rob -

I have these, originally from Michael Bell and  Michael Cherkassoff with
some modifications to make them work with Numerical recipes. But as Johann
mentioned, you will need to add the import_array() manually.

Pavlos

On Mon, 13 Dec 1999, Rob Managan wrote:

> >Hello,
> >
> >I'm trying to use SWIG to automatically wrap some C routines and
> >return the results as NumPy arrays (converting from my own pet vector
> >structure.)  I have typemaps that worked with old versions of NumPy,
> >but now I have had to insert a call to "import_array()" by hand in the
> >SWIG-generated C module in the module initialization section.
> >
> >This means (AFAIK) that I have to hand-patch the C every time I run
> >SWIG.  That's bad.  Is there any way to get SWIG to insert the needed
> >"import_array()" call automatically?  Also, are there standard NumPy
> >SWIG typemaps?
> >
> >Lots of questions, as ususal.  ;-)
> >
> 
> I was about to start looking into this myself. Could you send me a 
> copy of the typemaps so I can see if I can use them? I will be 
> getting to this after the holidays.
> 
>   I think that what you want for the "import _array()" is the %init %{ 
> ... %} option in SWIG. It claims that code you insert in this block 
> will be added to the initialization routine.
> 
> *-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-
> Rob Managan       <mailto://managan@llnl.gov>
> LLNL                      ph:  925-423-0903
> P.O. Box 808, L-095       FAX: 925-422-3389
> Livermore, CA  94551-0808
> 
> 
> _______________________________________________
> Matrix-SIG maillist  -  Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig
> 

--830597660-686800328-945117529=:32332
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="numrec.i"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.04.9912131538490.32332@gaaros.msrc.sunysb.edu>
Content-Description: 
Content-Disposition: attachment; filename="numrec.i"

LyogT3JpZ2luYWwgZHVlIHRvIE1pY2hhZWwgQmVsbCA8bWljaGFlbGJAZ29s
ZC5uZXQuYXU+DQogICBSZXZpc2VkIGJ5IE1pY2hhZWwgQ2hlcmthc3NvZmYg
PG1jaGVya0BnZW9nLnViYy5jYT4NCiAgICRSZXZpc2lvbjogMS4zICQgDQog
ICBSZXZpc2VkIGZvciB1c2Ugd2l0aCBOdW1SZWMuDQoqLw0KDQolbW9kdWxl
IG51bXJlYw0KJXsNCiNpbmNsdWRlICJhcnJheW9iamVjdC5oIg0KJX0NCg0K
JWluY2x1ZGUgdHlwZW1hcHMuaQ0KDQoldHlwZW1hcChweXRob24sIGluKSBk
b3VibGUqIERCXzJEIHsNCg0KICBQeUFycmF5T2JqZWN0ICphcnI7DQoNCiAg
LyogQ2hlY2sgdGhhdCBvYmogaXMgcmVhbGx5IGFuIDJEIGFycmF5IG9mIGJ5
dGVzICovDQogIGlmICghUHlBcnJheV9DaGVjaygkc291cmNlKSkgew0KICAg
IFB5RXJyX1NldFN0cmluZyhQeUV4Y19UeXBlRXJyb3IsIkZpcnN0IGFyZ3Vt
ZW50IGlzIG5vdCBhbiBhcnJheSIpOw0KICAgIHJldHV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Y3QgKilQeUFycmF5X0NvbnRpZ3VvdXNGcm9tT2JqZWN0
KCRzb3VyY2UsUHlBcnJheV9ET1VCTEUsMCwwKTsNCi8qICBhcnIgPSAoUHlB
cnJheU9iamVjdCAqKSRzb3VyY2U7ICovDQppZiAoIWFycikgew0KICAgIHJl
dHVybiBOVUxMOw0KICB9ICANCg0KICBpZiAoYXJyLT5uZCAhPSAxKSB7IC8q
IHdlIGFyZSByZWFsbHkgc3RyaWN0ICEgKi8NCiAgICBQeUVycl9TZXRTdHJp
bmcoUHlFeGNfVHlwZUVycm9yLCJJbmNvcnJlY3QgbnVtYmVyIG9mIGRpbXM6
IHdlIHdhbnQgYSAyZCBhcnJheSIpOw0KICAgIHJldHVybiBOVUxMOw0KICB9
DQoNCiAgJHRhcmdldCA9IChkb3VibGUgKilhcnItPmRhdGE7IC8qIHBvaW50
ZXIgb24gZmlyc3QgZWxlbSAqLw0KICAtLSR0YXJnZXQ7DQogICBQeV9ERUNS
RUYoYXJyKTsNCn0NCg0KI2V4dGVybiBkb3VibGUgdGVzdChkb3VibGUgKkRC
XzFELGRvdWJsZSAqREJfMUQsaW50IG4saW50IG0sZG91YmxlICpPVVRQVVQp
Ow0KZXh0ZXJuIHZvaWQgcGVyaW9kKGRvdWJsZSAqREJfMUQsIGRvdWJsZSAq
REJfMUQsIGludCBuLCBkb3VibGUgb2ZhYywgZG91YmxlIGhpZmFjLCBkb3Vi
bGUgKkRCXzFELGRvdWJsZSAqREJfMUQsIGludCBucCwgaW50ICpPVVRQVVQs
IGludCAqT1VUUFVULCBkb3VibGUgKk9VVFBVVCk7DQoNCg0KDQoNCg0KDQoN
Cg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0K
--830597660-686800328-945117529=:32332--


From ransom@cfa.harvard.edu  Mon Dec 13 20:41:36 1999
From: ransom@cfa.harvard.edu (Scott M. Ransom)
Date: Mon, 13 Dec 1999 20:41:36 +0000
Subject: [Matrix-SIG] SWIG with recent NumPy
References: <mtln6y7gz9.fsf@astron.berkeley.edu> <v04210102b47b02af5882@[128.115.232.99]>
Message-ID: <38555A00.18F47189@cfa.harvard.edu>

Rob Managan wrote:
> 
I have a working set of typemaps for various array types (more can be
added easily) at teh following location:

ftp://cfa-ftp.harvard.edu/pub/ransom/numpy.i

Good luck,

Scott

-- 
Scott M. Ransom                   Address:  Harvard-Smithsonian CfA
Phone:  (617) 495-4142                      60 Garden St.  MS 10 
email:  ransom@cfa.harvard.edu              Cambridge, MA  02138
PGP Fingerprint: D2 0E D0 10 CD 95 06 DA  EF 78 FE 2B CB 3A D3 53


From johann@physics.berkeley.edu  Mon Dec 13 20:46:38 1999
From: johann@physics.berkeley.edu (Johann Hibschman)
Date: 13 Dec 1999 12:46:38 -0800
Subject: [Matrix-SIG] SWIG with recent NumPy
In-Reply-To: Pavlos Christoforou's message of "Mon, 13 Dec 1999 15:38:49 -0500 (EST)"
References: <Pine.LNX.4.04.9912131536020.32332-200000@gaaros.msrc.sunysb.edu>
Message-ID: <mtd7sa7emp.fsf@astron.berkeley.edu>

Pavlos Christoforou writes:

> I have these, originally from Michael Bell and  Michael Cherkassoff with
> some modifications to make them work with Numerical recipes. But as Johann
> mentioned, you will need to add the import_array() manually.

I just tried it---Rob's suggestion of the %init directive works.
Somehow I'd missed that in the SWIG docs.  Just add the line:

   %init %{ import_array(); %}

to the .i file.

In case it's useful, I've placed my raw, ugly typemap code at:

  <http://astro.berkeley.edu/~johann/python/typemaps.i>

just in case anyone wants to take a look.

-- 
Johann Hibschman                           johann@physics.berkeley.edu


From pavlos@gaaros.msrc.sunysb.edu  Mon Dec 13 20:57:26 1999
From: pavlos@gaaros.msrc.sunysb.edu (Pavlos Christoforou)
Date: Mon, 13 Dec 1999 15:57:26 -0500 (EST)
Subject: [Matrix-SIG] SWIG with recent NumPy
In-Reply-To: <mtd7sa7emp.fsf@astron.berkeley.edu>
Message-ID: <Pine.LNX.4.04.9912131556080.32332-100000@gaaros.msrc.sunysb.edu>

On 13 Dec 1999, Johann Hibschman wrote:

>    %init %{ import_array(); %}

Thanks a lot Johann. 

And my apologies for sending the attachment on the list. It was intented
for Rob ...

Pavlos



From guido@CNRI.Reston.VA.US  Tue Dec 14 23:26:34 1999
From: guido@CNRI.Reston.VA.US (Guido van Rossum)
Date: Tue, 14 Dec 1999 18:26:34 -0500
Subject: [Matrix-SIG] Don't forget to register for the Python conference!
Message-ID: <199912142326.SAA00634@eric.cnri.reston.va.us>

We know that the Python conference isn't until the next millennium.
You still have THREE WHOLE WEEKS to register and qualify for the early
bird registration.  However, at least one of those weeks you will have
partying and family gatherings on your mind, and when that week's
over, recovery from the partying and gathering will probably take
priority over registering for the conference, and as a result you
might be PAYING FULL PRICE!  (The horror!)  That is, if your payment
isn't received by January 5, 2000.

So, be smart and register *before* Christmas.  That's still more than
ten days -- plenty of time to make travel arrangements, register for
the conference, and present your boss with the bill (in that order).

Our motto, due to Bruce Eckel, is: "Life's better without braces."

Some highlights from the conference program:

- 8 tutorials on topics ranging from JPython to Fnorb;
- a keynote by Open Source evangelist Eric Raymond;
- another by Randy Pausch, father of the Alice Virtual Reality project;
- a separate track for Zope developers and users;
- live demonstrations of important Python applications;
- refereed papers, and short talks on current topics;
- a developers' day where the feature set of Python 2.0 is worked out.

Come and join us at the Key Bridge Marriott in Rosslyn (across the
bridge from Georgetown), January 24-27 in 2000.  Make the Python
conference the first conference you attend in the new millennium!

The early bird registration deadline is January 5.  More info:

    http://www.python.org/workshops/2000-01/

--Guido van Rossum (home page: http://www.python.org/~guido/)


From cgw@fnal.gov  Thu Dec 16 19:14:34 1999
From: cgw@fnal.gov (Charles G Waldman)
Date: Thu, 16 Dec 1999 13:14:34 -0600 (CST)
Subject: [Matrix-SIG] bug in array constructor for type 'O'
Message-ID: <14425.14874.269412.634864@buffalo.fnal.gov>

Just noticed this:

>>> a=array(["foo","bar","baz"])
>>> a
array([[f, o, o],
       [b, a, r],
       [b, a, z]],'c')


This is slightly odd, but I can rationalize it, since each of the
strings "looks like" an array of characters.

But if I try to force the arraytype to "O" (Python Object)
I get:

>>> a=array(["foo","bar","baz"],'O')
>>> a
array([[foo , foo , foo ],
       [bar , bar , bar ],
       [baz , baz , baz ]],'O')


This just looks like a bug.




From pascucci@cs.utexas.edu  Fri Dec 17 23:25:45 1999
From: pascucci@cs.utexas.edu (pascucci)
Date: Fri, 17 Dec 1999 17:25:45 -0600
Subject: [Matrix-SIG] extending an array
References: <Pine.LNX.4.10.9911081105020.10064-100000@us2.mayo.edu>
Message-ID: <385AC679.FF1AE134@cs.utexas.edu>

This is a multi-part message in MIME format.
--------------7F5B61EB2560496D656966A2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Is it possible to extend an array "in place"?
Reshape does not do that but resize creates always a copy.
Is there something that behaves like a C realloc?
thanks
Valerio

--------------7F5B61EB2560496D656966A2
Content-Type: text/x-vcard; charset=us-ascii;
 name="pascucci.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for pascucci
Content-Disposition: attachment;
 filename="pascucci.vcf"

begin:vcard 
n:Pascucci;Valerio
tel;fax:(419) 735-3586
tel;work:(512) 232-4331
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:pascucci@acm.org
fn:Valerio Pascucci
end:vcard

--------------7F5B61EB2560496D656966A2--



From lee_barford@yahoo.com  Sat Dec 18 22:57:46 1999
From: lee_barford@yahoo.com (Lee Barford)
Date: Sat, 18 Dec 1999 14:57:46 -0800 (PST)
Subject: [Matrix-SIG] Additions to RandomArray
Message-ID: <19991218225746.23808.qmail@web3104.mail.yahoo.com>

The RandomArray module is an interface built on top of
the well-known ranlib random number generation
library. However, RandomArray doesn't bring out
interfaces to most of the kinds of random numbers that
ranlib can generate. I needed access to some of them.
So I extended RandomArray to provide all of the random
variables that ranlib generates.

Attached are documentation files (in HTML and raw
ASCII with identical contents) and patches to LLNL
Distribution 11.

I hope that these additions will be included in a
future LLNL Distribution.

--Lee Barford

__________________________________________________
Do You Yahoo!?
Thousands of Stores.  Millions of Products.  All in one place.
Yahoo! Shopping: http://shopping.yahoo.com


From tschinke@swissonline.ch  Sun Dec 19 15:43:35 1999
From: tschinke@swissonline.ch (Vincenzo Tschinke)
Date: Sun, 19 Dec 1999 16:43:35 +0100
Subject: [Matrix-SIG] Problem with arrays of arrays
Message-ID: <l03020900b482a60f0e3d@[195.24.94.138]>

Hi!

I am doing some basic molecular connectivity operation (graphs). Trying to
convert a list of bonds (list of edges) into a connectivity table (for each
vertex [atom], list of connected vertices), by filling an array of arrays, I
got the right or wrong result depending on how I define the initial arrays.

If I define an array of N emtpy arrays as

	array_of_empties = N * [[]]

I get the *wrong* result. If I use the more exotic definition

	array_of_empties = map ( lambda x : [] , range( N ))

I get the *right* result. Note that after being created, such two arrays
compare as equal.

Please see the listing below.

Is there anything wrong with the first definition, or do we have a
Python bug here?

===========================================================================

Python 1.5.2b1 (#47, Jan 13 1999, 15:14:59)  [CW PPC w/GUSI w/MSL]

>>> ee=[[1,2],[1,3],[1,4]]              # 3 edges : 3 vert. connected to centr. vertex
>>> ee
[[1, 2], [1, 3], [1, 4]]
>>> aa=4*[[]]                           # array of four empty arrays
>>> AA=map(lambda x : [], range(4))     # same as above
>>> aa==AA                              # arrays are equal !!!
1
>>> for p in ee:                        # build table of connected verteces
...     i=p[0]
...     j=p[1]
...     aa[i-1].append(j)
...     aa[j-1].append(i)
...     AA[i-1].append(j)
...     AA[j-1].append(i)
... 
>>> aa                                  # wrong result !!!
[[2, 1, 3, 1, 4, 1], [2, 1, 3, 1, 4, 1], [2, 1, 3, 1, 4, 1], [2, 1, 3, 1, 4, 1]]
>>> AA                                  # correct result
[[2, 3, 4], [1], [1], [1]]
>>> aa==AA
0
>>> 

=======================
Vincenzo Tschinke
Kernmattstr. 24
CH-4102 Binningen
Switzerland
+4161 422 1991 (T+F)
tschinke@swissonline.ch
=======================




From mkeller@cybercable.fr  Sun Dec 19 22:35:37 1999
From: mkeller@cybercable.fr (Marc Keller)
Date: Sun, 19 Dec 1999 23:35:37 +0100
Subject: [Matrix-SIG] Problem with arrays of arrays
References: <l03020900b482a60f0e3d@[195.24.94.138]>
Message-ID: <385D5DB9.A648E54D@cybercable.fr>


Vincenzo Tschinke wrote:

> Hi!
>
> I am doing some basic molecular connectivity operation (graphs). Trying to
> convert a list of bonds (list of edges) into a connectivity table (for each
> vertex [atom], list of connected vertices), by filling an array of arrays, I
> got the right or wrong result depending on how I define the initial arrays.
>
> If I define an array of N emtpy arrays as
>
>         array_of_empties = N * [[]]
>
> I get the *wrong* result. If I use the more exotic definition
>
>         array_of_empties = map ( lambda x : [] , range( N ))
>
> I get the *right* result. Note that after being created, such two arrays
> compare as equal.
>
> Please see the listing below.
>
> Is there anything wrong with the first definition, or do we have a
> Python bug here?
>
> ===========================================================================
>
> Python 1.5.2b1 (#47, Jan 13 1999, 15:14:59)  [CW PPC w/GUSI w/MSL]
>
> >>> ee=[[1,2],[1,3],[1,4]]              # 3 edges : 3 vert. connected to centr. vertex
> >>> ee
> [[1, 2], [1, 3], [1, 4]]
> >>> aa=4*[[]]                           # array of four empty arrays
> >>> AA=map(lambda x : [], range(4))     # same as above
> >>> aa==AA                              # arrays are equal !!!
> 1
> >>> for p in ee:                        # build table of connected verteces
> ...     i=p[0]
> ...     j=p[1]
> ...     aa[i-1].append(j)
> ...     aa[j-1].append(i)
> ...     AA[i-1].append(j)
> ...     AA[j-1].append(i)
> ...
> >>> aa                                  # wrong result !!!
> [[2, 1, 3, 1, 4, 1], [2, 1, 3, 1, 4, 1], [2, 1, 3, 1, 4, 1], [2, 1, 3, 1, 4, 1]]
> >>> AA                                  # correct result
> [[2, 3, 4], [1], [1], [1]]
> >>> aa==AA
> 0
> >>>
>
> =======================
> Vincenzo Tschinke
> Kernmattstr. 24
> CH-4102 Binningen
> Switzerland
> +4161 422 1991 (T+F)
> tschinke@swissonline.ch
> =======================
>
> _______________________________________________
> Matrix-SIG maillist  -  Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig

Using N * [[]], you are building a list with 4 references to the same list.
Using map ( lambda x : [] , range( N )), each call to lambda produces a new empty list.
Your exemple in an other way:
>>> aa=[[],[],[],[]]
>>> for p in ee:                        # build table of connected verteces
...     i=p[0]
...     j=p[1]
...     aa[i-1].append(j)
...     aa[j-1].append(i)
...
>>> aa
[[2, 3, 4], [1], [1], [1]]
>>>



From mkeller@cybercable.fr  Mon Dec 20 13:28:30 1999
From: mkeller@cybercable.fr (Marc Keller)
Date: Mon, 20 Dec 1999 14:28:30 +0100
Subject: [Matrix-SIG] bug in array constructor for type 'O'
References: <14425.14874.269412.634864@buffalo.fnal.gov>
Message-ID: <385E2EFE.97882F75@cybercable.fr>

Charles G Waldman wrote:

> Just noticed this:
>
> >>> a=array(["foo","bar","baz"])
> >>> a
> array([[f, o, o],
>        [b, a, r],
>        [b, a, z]],'c')
>
> This is slightly odd, but I can rationalize it, since each of the
> strings "looks like" an array of characters.
>
> But if I try to force the arraytype to "O" (Python Object)
> I get:
>
> >>> a=array(["foo","bar","baz"],'O')
> >>> a
> array([[foo , foo , foo ],
>        [bar , bar , bar ],
>        [baz , baz , baz ]],'O')
>
> This just looks like a bug.
>
> _______________________________________________
> Matrix-SIG maillist  -  Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig

Seems to be a bug...
But there is some logic here: stop the level of structure analysis when
type differ:
For example if
l= >>> l= 'floor', 'bar', 'ba'
>>> b=array(l,'O')
results in
>>> b
array([[floor , floor , floor , floor , floor ],
       [bar , bar , bar , bar , bar ],
       [ba , ba , ba , ba , ba ]],'O')
with
>>> b=array((None,)+l)
we get
>>> b
array([None , floor , bar , ba ],'O')
>>>



From emmanuel.viennet@lipn.univ-paris13.fr  Mon Dec 20 12:49:13 1999
From: emmanuel.viennet@lipn.univ-paris13.fr (Emmanuel Viennet)
Date: Mon, 20 Dec 1999 13:49:13 +0100
Subject: [Matrix-SIG] bug in array constructor for type 'O'
References: <14425.14874.269412.634864@buffalo.fnal.gov> <385E2EFE.97882F75@cybercable.fr>
Message-ID: <385E25C9.981399D@lipn.univ-paris13.fr>

 The 'O' typecode is seldom used and obviously needs some
debugging...
 While you're at it, the display (repr) code is also wrong:

>>> b
array([None , floor , bar , ba ],'O')

is incorrect: we should get

 array([None , 'floor' , 'bar' , 'ba' ],'O')


Emmanuel
-- 
Emmanuel Viennet: <emmanuel.viennet@lipn.univ-paris13.fr>
http://www-lipn.univ-paris13.fr/~viennet/


Return-Path: <owner-matrix-sig@python.org>
Delivered-To: matrix-sig@dinsdale.python.org
Received: from python.org (parrot.python.org [132.151.1.90])
	by dinsdale.python.org (Postfix) with ESMTP id 350081CD16
	for <matrix-sig@dinsdale.python.org>; Sat, 18 Dec 1999 18:06:50 -0500 (EST)
Received: from web3105.mail.yahoo.com (web3105.mail.yahoo.com [204.71.202.190])
	by python.org (8.9.1a/8.9.1) with SMTP id SAA14480
	for <matrix-sig@python.org>; Sat, 18 Dec 1999 18:06:47 -0500 (EST)
Message-ID: <19991218230702.25490.qmail@web3105.mail.yahoo.com>
Received: from [15.255.176.47] by web3105.mail.yahoo.com; Sat, 18 Dec 1999 15:07:02 PST
Date: Sat, 18 Dec 1999 15:07:02 -0800 (PST)
From: Lee Barford <lee_barford@yahoo.com>
To: Python Matrix Sig <matrix-sig@python.org>,
	LLNL Distribution Support <support@icf.llnl.gov>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="0-1804289383-945558422=:25420"
Subject: [Matrix-SIG] Additions to RandomArray
Sender: matrix-sig-admin@python.org
Errors-To: matrix-sig-admin@python.org
X-BeenThere: matrix-sig@python.org
X-Mailman-Version: 1.2 (experimental)
Precedence: bulk
List-Id: SIG for Built-in Matrix Types in Python <matrix-sig.python.org>

--0-1804289383-945558422=:25420
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

The attachments to my previous message didn't make it.
Please forgive this second attempt. If this doesn't
work, I'll look for some other way of submitting them.

--Lee Barford

__________________________________________________
Do You Yahoo!?
Thousands of Stores.  Millions of Products.  All in one place.
Yahoo! Shopping: http://shopping.yahoo.com
--0-1804289383-945558422=:25420
Content-Type: text/html; name="RandomArray-additions.html"
Content-Description: RandomArray-additions.html
Content-Disposition: inline; filename="RandomArray-additions.html"

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="GENERATOR" content="Mozilla/4.6 [en] (X11; I; Linux 2.2.10 i686) [Netscape]">
</head>
<body>

<h1>
Additions to RandomArray module</h1>

<h2>
Lee A. Barford&nbsp;&nbsp; 18 December 1999</h2>
The RandomArray.py module distributed with the LLNL Distribution 11 contains
an interface to portions of the widely used and well tested random number
generation package ranlib. Ranlib is capable of generating floating point
random variables with a wide variety of probability density functions and
some kinds of discrete random variables as well. Random variables with
these nonuniform distributions have uses in diverse areas like Monte Carlo
simulation and the testing of signal processing algorithms. However, RandomArray.py
did not provide interfaces to those ranlib routines. This document describes
functions that have been added to module RandomArray to allow access to
all of the kinds of random variables provided by ranlib.
<h3>
Floating point random arrays</h3>
<i>standard_normal(shape=ReturnFloat)</i>
<br>The <tt>standard_normal()</tt> function returns an array of the specified
shape that contains double precision floating point numbers normally (Gaussian)
distributed with mean zero and variance and standard deviation one. If
no shape is specified, a single number is returned.
<p><i>normal(mean, variance, shape=ReturnFloat)</i>
<br>The <tt>normal()</tt> function returns an array of the specified shape
that contains double precision floating point numbers normally distributed
with the specified mean and variance. If no shape is specified, a single
number is returned.
<p><i>multivariate_normal(mean, covariance) or multivariate_normal(mean,
covariance, leadingAxesShape)</i>
<br>The <tt>multivariate_normal()</tt> function takes a one dimensional
array argument <tt>mean</tt> and a two dimensional array argument <tt>covariance.</tt>
Suppose the shape of <tt>mean</tt> is <tt>(n,). </tt>Then the shape of
<tt>covariance
</tt>must
be <tt>(n,n).</tt>&nbsp;&nbsp; The <tt>multivariate_normal()</tt> function
returns a double precision floating point array. The effect of the <tt>leadingAxesShape</tt>
parameter is:
<ul>
<li>
If no <tt>leadingAxesShape</tt> is specified, then an array with shape
<tt>(n,)</tt> is returned containing a vector of numbers with a multivariate
normal distribution with the specified mean and covariance.</li>

<li>
If <tt>leadingAxesShape</tt> is specified, then an array of such vectors
is returned. The shape of the output is <tt>leadingAxesShape.append((n,)).
</tt>The
leading indices into the output array select a multivariate normal from
the array. The final index selects one number from within the multivariate
normal.</li>
</ul>
In either case, the behavior of <tt>multivariate_normal()</tt> is undefined&nbsp;
if <tt>covariance </tt>is not symmetric and positive definite.
<p><i>exponential(mean, shape=ReturnFloat)</i>
<br>The <tt>exponential() </tt>function returns an array of the specified
shape that contains double precision floating point numbers exponentially
distributed with the specified mean. If no shape is specified, a single
number is returned.
<p><i>beta(a, b, shape=ReturnFloat)</i>
<br>The <tt>beta() </tt>function returns an array of the specified shape
that contains double precision floating point numbers beta distributed
with alpha parameter <tt>a </tt>and beta parameter <tt>b. </tt>If no shape
is specified, a single number is returned.
<p><i>gamma(a, r, shape=ReturnFloat)</i>
<br>The <tt>gamma() </tt>function returns an array of the specified shape
that contains double precision floating point numbers beta distributed
with location parameter <tt>a </tt>and distribution shape parameter <tt>r.
</tt>If no <tt>shape</tt> is specified, a single number is returned.
<p><i>chi_square(df, shape=ReturnFloat)</i>
<br>The <tt>chi_square()</tt> function returns an array of the specified
shape that contains double precision floating point numbers with the chi
square distribution with <tt>df</tt> degrees of freedom. If no shape is
specified, a single number is returned.
<p><i>noncentral_chi_square(df, nonc, shape=ReturnFloat)</i>
<br>The <tt>noncentral_chi_square()</tt> function returns an array of the
specified shape that contains double precision floating point numbers with
the chi square distribution with <tt>df </tt>degrees of freedom and noncentrality
parameter nconc. If no shape is specified, a single number is returned.
<p><i>F(dfn, dfd, shape=ReturnFloat)</i>
<br>The <tt>F()</tt> function returns an array of the specified shape that
contains double precision floating point numbers with the F distribution
with
<tt>dfn</tt> degrees of freedom in the numerator and <tt>dfd</tt>
degrees of freedom in the denominator. If no shape is specified, a single
number is returned.
<p><i>noncentral_F(dfn, dfd, nconc, shape=ReturnFloat)</i>
<br>The <tt>noncentral_F()</tt> function returns an array of the specified
shape that contains double precision floating point numbers with the F
distribution with <tt>dfn</tt> degrees of freedom in the numerator, <tt>dfd</tt>
degrees of freedom in the denominator, and noncentrality parameter <tt>nconc</tt>.
If no shape is specified, a single number is returned.
<h3>
Integer random arrays</h3>
<i>binomial(trials, prob, shape=ReturnInt)</i>
<br>The <tt>binomial()</tt> function returns an array with the specified
shape that contains integer numbers with the binomial distribution with
<tt>trials</tt>
trials and event probability <tt>prob</tt>. In other words, each value
in the returned array is the number of times an event with probability
<tt>prob
</tt>occurred
within <tt>trials </tt>repeated trials. If no shape is specified, a single
number is returned.
<p><i>negative_binomial(trials, prob, shape=ReturnInt)</i>
<br>The <tt>negative_binomial()</tt> function returns an array with the
specified shape that contains integer numbers with the negative binomial
distribution with <tt>trials</tt> trials and event probability <tt>prob</tt>.
If no shape is specified, a single number is returned.
<p><i>poisson(mean, shape=ReturnInt)</i>
<br>The <tt>poisson()</tt> function returns an array with the specified
shape that contains integer numbers with the Poisson distribution with
the specified mean. If no shape is specified, a single number is returned.
<p><i>multinomial(trials, probs) or multinomial(trials, probs, leadingAxesShape)</i>
<br>The <tt>multinomial()</tt> function returns an array with that contains
integer numbers with the multinomial distribution with <tt>trials</tt>
trials and event probabilities given in <tt>probs</tt>. <tt>probs</tt>
must be a one dimensional array. There are <tt>len(probs)+1</tt> events.
<tt>probs[i</tt>] is the probability of the <tt>i</tt>-th event for <tt>0&lt;=i&lt;len(probs)</tt>.
The probability of event <tt>len(probs)</tt> is <tt>1.-Numeric.sum(prob).</tt>
<p>The first form returns an integer array of shape <tt>(len(probs)+1,)</tt>
containing one multinomially distributed vector. The second form returns
an array of shape <tt>(m, n, ..., len(probs)+1)</tt> where <tt>(m, n, ...)</tt>
is <tt>leadingAxesShape</tt>. In this case, each
<tt>output[i,j,...,:]</tt>
is an integer array of shape <tt>(len(prob)+1,)</tt> containing one multinomially
distributed vector..
<h3>
Examples</h3>
Mostof the functions in this package take zero or more distribution specific
parameters plus an optional shape parameter. The shape parameter gives
the shape of the output array:
<blockquote><tt>Python 1.5.1 (#1, Mar 21 1999, 22:49:36) [GCC egcs-2.91.66
19990314/Li on linux-i386</tt>
<br><tt>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam</tt>
<br><tt>>>> from RandomArray import *</tt>
<br><tt>>>> print standard_normal()</tt>
<br><tt>-0.435568600893</tt>
<br><tt>>>> print standard_normal(5)</tt>
<br><tt>[-1.36134553 0.78617644 -0.45038718 0.18508556 0.05941355]</tt>
<br><tt>>>> print standard_normal((5,2))</tt>
<br><tt>[[ 1.33448863 -0.10125473]</tt>
<br><tt>&nbsp;[ 0.66838062 0.24691346]</tt>
<br><tt>&nbsp;[-0.95092064 0.94168913]</tt>
<br><tt>&nbsp;[-0.23919107 1.89288616]</tt>
<br><tt>&nbsp;[ 0.87651485 0.96400219]]</tt>
<br><tt>>>> print normal(7., 4., (5,2)) % mean=7, std. dev.=4</tt>
<br><tt>[[ 2.66997623 11.65832615]</tt>
<br><tt>&nbsp;[ 6.73916003 6.58162862]</tt>
<br><tt>&nbsp;[ 8.47180378 4.30354905]</tt>
<br><tt>&nbsp;[ 1.35531998 -2.80886841]</tt>
<br><tt>&nbsp;[ 7.07408469 11.39024973]]</tt>
<br><tt>>>> print exponential(10., 5) % mean=10</tt>
<br><tt>[ 18.03347754 7.11702306 9.8587961 32.49231603 28.55408891]</tt>
<br><tt>>>> print beta(3.1, 9.1, 5) % alpha=3.1, beta=9.1</tt>
<br><tt>[ 0.1175056 0.17504358 0.3517828 0.06965593 0.43898219]</tt>
<br><tt>>>> print chi_square(7, 5) % 7 degrees of freedom (dfs)</tt>
<br><tt>[ 11.99046516 3.00741053 4.72235727 6.17056274 8.50756836]</tt>
<br><tt>>>> print noncentral_chi_square(7, 3, 5) % 7 dfs, noncentrality
3</tt>
<br><tt>[ 18.28332138 4.07550335 16.0425396 9.51192093 9.80156231]</tt>
<br><tt>>>> F(5, 7, 5) % 5 and 7 dfs</tt>
<br><tt>array([ 0.24693671, 3.76726145, 0.66883826, 0.59169068, 1.90763224])</tt>
<br><tt>>>> noncentral_F(5, 7, 3., 5) % 5 and 7 dfs, noncentrality 3</tt>
<br><tt>array([ 1.17992553, 0.7500126 , 0.77389943, 9.26798989, 1.35719634])</tt>
<br><tt>>>> binomial(32, .5, 5) % 32 trials, prob of an event = .5</tt>
<br><tt>array([12, 20, 21, 19, 17])</tt>
<br><tt>>>> negative_binomial(32, .5, 5) % 32 trials: prob of an event
= .5</tt>
<br><tt>array([21, 38, 29, 32, 36])</tt></blockquote>
Two functions that return generate multivariate random numbers (that is,
random vectors with some known relationship between the elements of each
vector, defined by the distribution).&nbsp; They are <tt>multivariate_normal()</tt>
and <tt>multinomial().</tt> For these two functions, the lengths of the
leading axes of the output may be specified. The length of the last axis
is determined by the length of some other parameter.
<blockquote><tt>>>> from Numeric import *</tt>
<br><tt>>>> multivariate_normal([1,2], [[1,2],[2,1]], [2,3])</tt>
<br><tt>array([[[ 0.14157988, 1.46232224],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [-1.11820295, -0.82796288],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ 1.35251635, -0.2575901
]],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [[-0.61142141, 1.0230465 ],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [-1.08280948, -0.55567217],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ 2.49873002, 3.28136372]]])</tt>
<br><tt>>>> x = multivariate_normal([10,100], [[1,2],[2,1]], 10000)</tt>
<br><tt>>>> x_mean = sum(x)/10000</tt>
<br><tt>>>> print x_mean</tt>
<br><tt>[ 9.98599893 100.00032416]</tt>
<br><tt>>>> x_minus_mean = x - x_mean</tt>
<br><tt>>>> cov = matrixmultiply(transpose(x_minus_mean), x_minus_mean)
/ 9999.</tt>
<br><tt>>>> cov</tt>
<br><tt>array([[ 2.01737122, 1.00474408],</tt>
<br><tt>[ 1.00474408, 2.0009806 ]])</tt></blockquote>
The a priori probabilities for a multinomial distribution must sum to one.
The prior probability argument to <tt>multinomial()</tt> doesn't give the
prior probability of the last event: it is computed to be one minus the
sum of the others.
<blockquote><tt>>>> multinomial(16, [.1, .4, .2]) % prior probabilities
[.1, .4, .2, .3]</tt>
<br><tt>array([2, 7, 1, 6])</tt>
<br><tt>>>> multinomial(16, [.1, .4, .2], [2,3]) % output shape [2,3,4]</tt>
<br><tt>array([[[ 1, 9, 1, 5],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ 0, 10, 3, 3],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ 4, 9, 3, 0]],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [[ 1, 6, 1, 8],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ 3, 4, 5, 4],</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ 1, 5, 2, 8]]])</tt></blockquote>

</body>
</html>

--0-1804289383-945558422=:25420
Content-Type: text/plain; name="RandomArray-additions.txt"
Content-Description: RandomArray-additions.txt
Content-Disposition: inline; filename="RandomArray-additions.txt"

Additions to RandomArray module
Lee A. Barford   18 December 1999

The RandomArray.py module distributed with the LLNL Distribution 11
contains an interface to portions of the widely used and well tested
random number generation package ranlib. Ranlib is capable of
generating floating point random variables with a wide variety of
probability density functions and some kinds of discrete random
variables as well. Random variables with these nonuniform
distributions have uses in diverse areas like Monte Carlo simulation
and the testing of signal processing algorithms. However,
RandomArray.py did not provide interfaces to those ranlib
routines. This document describes functions that have been added to
module RandomArray to allow access to all of the kinds of random
variables provided by ranlib.

Floating point random arrays

standard_normal(shape=ReturnFloat) 

The standard_normal() function returns an array of the specified shape
that contains double precision floating point numbers normally
(Gaussian) distributed with mean zero and variance and standard
deviation one. If no shape is specified, a single number is returned.

normal(mean, variance, shape=ReturnFloat) 

The normal() function returns an array of the specified shape that
contains double precision floating point numbers normally distributed
with the specified mean and variance. If no shape is specified, a
single number is returned.

multivariate_normal(mean, covariance) or multivariate_normal(mean, covariance, leadingAxesShape) 

The multivariate_normal() function takes a one dimensional array
argument mean and a two dimensional array argument covariance. Suppose
the shape of mean is (n,). Then the shape of covariance must be
(n,n). The multivariate_normal() function returns a double precision
floating point array. The effect of the leadingAxesShape parameter is:

If no leadingAxesShape is specified, then an array with shape (n,) is
returned containing a vector of numbers with a multivariate normal
distribution with the specified mean and covariance.

If leadingAxesShape is specified, then an array of such vectors is
returned. The shape of the output is
leadingAxesShape.append((n,)). The leading indices into the output
array select a multivariate normal from the array. The final index
selects one number from within the multivariate normal.  In either
case, the behavior of multivariate_normal() is undefined if covariance
is not symmetric and positive definite.

exponential(mean, shape=ReturnFloat) 

The exponential() function returns an array of the specified shape
that contains double precision floating point numbers exponentially
distributed with the specified mean. If no shape is specified, a
single number is returned.

beta(a, b, shape=ReturnFloat) 

The beta() function returns an array of the specified shape that
contains double precision floating point numbers beta distributed with
alpha parameter a and beta parameter b. If no shape is specified, a
single number is returned.

gamma(a, r, shape=ReturnFloat) 

The gamma() function returns an array of the specified shape that
contains double precision floating point numbers beta distributed with
location parameter a and distribution shape parameter r. If no shape
is specified, a single number is returned.

chi_square(df, shape=ReturnFloat) 

The chi_square() function returns an array of the specified shape that
contains double precision floating point numbers with the chi square
distribution with df degrees of freedom. If no shape is specified, a
single number is returned.

noncentral_chi_square(df, nonc, shape=ReturnFloat)

The noncentral_chi_square() function returns an array of the specified
shape that contains double precision floating point numbers with the
chi square distribution with df degrees of freedom and noncentrality
parameter nconc. If no shape is specified, a single number is
returned.

F(dfn, dfd, shape=ReturnFloat) 

The F() function returns an array of the specified shape that contains
double precision floating point numbers with the F distribution with
dfn degrees of freedom in the numerator and dfd degrees of freedom in
the denominator. If no shape is specified, a single number is
returned.

noncentral_F(dfn, dfd, nconc, shape=ReturnFloat) 

The noncentral_F() function returns an array of the specified shape
that contains double precision floating point numbers with the F
distribution with dfn degrees of freedom in the numerator, dfd degrees
of freedom in the denominator, and noncentrality parameter nconc. If
no shape is specified, a single number is returned.

Integer random arrays

binomial(trials, prob, shape=ReturnInt) 

The binomial() function returns an array with the specified shape that
contains integer numbers with the binomial distribution with trials
trials and event probability prob. In other words, each value in the
returned array is the number of times an event with probability prob
occurred within trials repeated trials. If no shape is specified, a
single number is returned.

negative_binomial(trials, prob, shape=ReturnInt) 

The negative_binomial() function returns an array with the specified
shape that contains integer numbers with the negative binomial
distribution with trials trials and event probability prob. If no
shape is specified, a single number is returned.

poisson(mean, shape=ReturnInt) 

The poisson() function returns an array with the specified shape that
contains integer numbers with the Poisson distribution with the
specified mean. If no shape is specified, a single number is returned.

multinomial(trials, probs) or multinomial(trials, probs, leadingAxesShape) 

The multinomial() function returns an array with that contains integer
numbers with the multinomial distribution with trials trials and event
probabilities given in probs. probs must be a one dimensional
array. There are len(probs)+1 events. probs[i] is the probability of
the i-th event for 0<=i<len(probs). The probability of event
len(probs) is 1.-Numeric.sum(prob).  The first form returns an integer
array of shape (len(probs)+1,) containing one multinomially
distributed vector. The second form returns an array of shape (m, n,
..., len(probs)+1) where (m, n, ...) is leadingAxesShape. In this
case, each output[i,j,...,:] is an integer array of shape
(len(prob)+1,) containing one multinomially distributed vector..

Examples

Most of the functions in this package take zero or more distribution
specific parameters plus an optional shape parameter. The shape
parameter gives the shape of the output array:

Python 1.5.1 (#1, Mar 21 1999, 22:49:36) [GCC egcs-2.91.66 19990314/Li on linux-i386 
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam 
>>> from RandomArray import * 
>>> print standard_normal() 
-0.435568600893 
>>> print standard_normal(5) 
[-1.36134553 0.78617644 -0.45038718 0.18508556 0.05941355] 
>>> print standard_normal((5,2)) 
[[ 1.33448863 -0.10125473] 
 [ 0.66838062 0.24691346] 
 [-0.95092064 0.94168913] 
 [-0.23919107 1.89288616] 
 [ 0.87651485 0.96400219]] 
>>> print normal(7., 4., (5,2)) % mean=7, std. dev.=4 
[[ 2.66997623 11.65832615] 
 [ 6.73916003 6.58162862] 
 [ 8.47180378 4.30354905] 
 [ 1.35531998 -2.80886841] 
 [ 7.07408469 11.39024973]] 
>>> print exponential(10., 5) % mean=10 
[ 18.03347754 7.11702306 9.8587961 32.49231603 28.55408891] 
>>> print beta(3.1, 9.1, 5) % alpha=3.1, beta=9.1 
[ 0.1175056 0.17504358 0.3517828 0.06965593 0.43898219] 
>>> print chi_square(7, 5) % 7 degrees of freedom (dfs) 
[ 11.99046516 3.00741053 4.72235727 6.17056274 8.50756836] 
>>> print noncentral_chi_square(7, 3, 5) % 7 dfs, noncentrality 3 
[ 18.28332138 4.07550335 16.0425396 9.51192093 9.80156231] 
>>> F(5, 7, 5) % 5 and 7 dfs 
array([ 0.24693671, 3.76726145, 0.66883826, 0.59169068, 1.90763224]) 
>>> noncentral_F(5, 7, 3., 5) % 5 and 7 dfs, noncentrality 3 
array([ 1.17992553, 0.7500126 , 0.77389943, 9.26798989, 1.35719634]) 
>>> binomial(32, .5, 5) % 32 trials, prob of an event = .5 
array([12, 20, 21, 19, 17]) 
>>> negative_binomial(32, .5, 5) % 32 trials: prob of an event = .5 
array([21, 38, 29, 32, 36])

Two functions that return generate multivariate random numbers (that is, random vectors with some known relationship between the elements of each vector, defined by the distribution).  They are multivariate_normal() and multinomial(). For these two functions, the lengths of the leading axes of the output may be specified. The length of the last axis is determined by the length of some other parameter. 

>>> from Numeric import * 
>>> multivariate_normal([1,2], [[1,2],[2,1]], [2,3]) 
array([[[ 0.14157988, 1.46232224], 
        [-1.11820295, -0.82796288], 
        [ 1.35251635, -0.2575901 ]], 
       [[-0.61142141, 1.0230465 ], 
        [-1.08280948, -0.55567217], 
        [ 2.49873002, 3.28136372]]]) 
>>> x = multivariate_normal([10,100], [[1,2],[2,1]], 10000) 
>>> x_mean = sum(x)/10000 
>>> print x_mean 
[ 9.98599893 100.00032416] 
>>> x_minus_mean = x - x_mean 
>>> cov = matrixmultiply(transpose(x_minus_mean), x_minus_mean) / 9999. 
>>> cov 
array([[ 2.01737122, 1.00474408], 
[ 1.00474408, 2.0009806 ]])

The a priori probabilities for a multinomial distribution must sum to
one. The prior probability argument to multinomial() doesn't give the
prior probability of the last event: it is computed to be one minus
the sum of the others.

>>> multinomial(16, [.1, .4, .2]) % prior probabilities [.1, .4, .2, .3] 
array([2, 7, 1, 6]) 
>>> multinomial(16, [.1, .4, .2], [2,3]) % output shape [2,3,4] 
array([[[ 1, 9, 1, 5], 
        [ 0, 10, 3, 3], 
        [ 4, 9, 3, 0]], 
       [[ 1, 6, 1, 8], 
        [ 3, 4, 5, 4], 
        [ 1, 5, 2, 8]]])

--0-1804289383-945558422=:25420
Content-Type: application/x-unknown; name="RandomArray.patch"
Content-Transfer-Encoding: base64
Content-Description: RandomArray.patch
Content-Disposition: attachment; filename="RandomArray.patch"

ZGlmZiAtLWNvbnRleHQgLS1yZWN1cnNpdmUgTnVtZXJpY2FsLW9yaWcvTGli
L1JhbmRvbUFycmF5LnB5IE51bWVyaWNhbC9MaWIvUmFuZG9tQXJyYXkucHkK
KioqIE51bWVyaWNhbC1vcmlnL0xpYi9SYW5kb21BcnJheS5weQlTYXQgRGVj
IDE4IDE0OjE1OjEwIDE5OTkKLS0tIE51bWVyaWNhbC9MaWIvUmFuZG9tQXJy
YXkucHkJU2F0IERlYyAxOCAxMDo1NzoyOSAxOTk5CioqKioqKioqKioqKioq
KgoqKiogMSw5ICoqKioKLS0tIDEsMTUgLS0tLQogIGltcG9ydCByYW5saWIK
ICBpbXBvcnQgTnVtZXJpYworIGltcG9ydCBMaW5lYXJBbGdlYnJhCiAgaW1w
b3J0IHN5cwogIGltcG9ydCBtYXRoCiAgZnJvbSB0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SAxOgorICAgICBp
ZiggIVB5QXJnX1BhcnNlVHVwbGUoYXJncywgImZ8aSIsICZhLCAmbikgKQor
ICAgICAgIHJldHVybiBOVUxMOworICAgICBicmVhazsKKyAgIGNhc2UgMjoK
KyAgICAgaWYoICFQeUFyZ19QYXJzZVR1cGxlKGFyZ3MsICJmZnxpIiwgJmEs
ICZiLCAmbikgKQorICAgICAgIHJldHVybiBOVUxMOworICAgICBicmVhazsK
KyAgIGNhc2UgMzoKKyAgICAgaWYoICFQeUFyZ19QYXJzZVR1cGxlKGFyZ3Ms
ICJmZmZ8aSIsICZhLCAmYiwgJmMsICZuKSApCisgICAgICAgcmV0dXJuIE5V
TEw7CisgICAgIGJyZWFrOworICAgfQorICAgaWYoIG4gPT0gLTEgKQorICAg
ICBuID0gMTsKKyAKKyAgIC8qIENyZWF0ZSBhIDEgZGltZW5zaW9uYWwgYXJy
YXkgb2YgbGVuZ3RoIG4gb2YgdHlwZSBkb3VibGUgKi8KKyAgIG9wID0gKFB5
QXJyYXlPYmplY3QqKSBQeUFycmF5X0Zyb21EaW1zKDEsICZuLCBQeUFycmF5
X0RPVUJMRSk7CisgICBpZiggb3AgPT0gTlVMTCApCisgICAgIHJldHVybiBO
VUxMOworIAorICAgb3V0X3B0ciA9IChkb3VibGUgKikgb3AtPmRhdGE7Cisg
ICBmb3IoaT0wOyBpPG47IGkrKykgeworICAgICBzd2l0Y2gobnVtX2Rpc3Rf
cGFyYW1zKSB7CisgICAgIGNhc2UgMDoKKyAgICAgICAqb3V0X3B0ciA9IChk
b3VibGUpICgoZmxvYXQgKCopKCkpIGZ1bikoKTsKKyAgICAgICBicmVhazsK
KyAgICAgY2FzZSAxOgorICAgICAgICpvdXRfcHRyID0gKGRvdWJsZSkgKChm
bG9hdCAoKikoZmxvYXQpKSBmdW4pKGEpOworICAgICAgIGJyZWFrOworICAg
ICBjYXNlIDI6CisgICAgICAgKm91dF9wdHIgPSAoZG91YmxlKSAoKGZsb2F0
ICgqKShmbG9hdC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MsCTEsIH0sCiAgIHtOVUxMLAkJTlVMTH0JCS8qIHNlbnRp
bmVsICovCiAgfTsKICAKICAKISAvKiBJbml0aWFsaXphdGlvbiBmdW5jdGlv
biBmb3IgdGhlIG1vZHVsZSAoKm11c3QqIGJlIGNhbGxlZCBpbml0ZmZ0cGFj
aykgKi8KICAKICBzdGF0aWMgY2hhciByYW5kb21fbW9kdWxlX2RvY3VtZW50
YXRpb25bXSA9IAogICIiCi0tLSAyNjYsMjk2IC0tLS0KICAgIHJldHVybiBQ
eV9CdWlsZFZhbHVlKCJsbCIsIHNlZWQxLCBzZWVkMik7CiAgfQogIAorIAog
IC8qIExpc3Qgb2YgbWV0aG9kcyBkZWZpbmVkIGluIHRoZSBtb2R1bGUgKi8K
ICAKICBzdGF0aWMgc3RydWN0IFB5TWV0aG9kRGVmIHJhbmRvbV9tZXRob2Rz
W10gPSB7CiEgIHsic2FtcGxlIiwgICAgIHJhbmRvbV9zYW1wbGUsICAgICAg
ICAgIDEsICAgICAgcmFuZG9tX3NhbXBsZV9fZG9jX199LAohICB7InN0YW5k
YXJkX25vcm1hbCIsIHN0YW5kYXJkX25vcm1hbCwgICAxLCAgICAgIHN0YW5k
YXJkX25vcm1hbF9fZG9jX199LAohICB7ImJldGEiLAliZXRhLCAgICAgICAg
ICAgICAgICAgICAxLCAgICAgIGJldGFfX2RvY19ffSwKISAgeyJnYW1tYSIs
CWdhbW1hLCAgICAgICAgICAgICAgICAgIDEsICAgICAgZ2FtbWFfX2RvY19f
fSwKISAgeyJmIiwJICAgICAgICBmLCAgICAgICAgICAgICAgICAgICAgICAx
LCAgICAgIGZfX2RvY19ffSwKISAgeyJub25jZW50cmFsX2YiLCBub25jZW50
cmFsX2YsICAgICAgICAgMSwgICAgICBub25jZW50cmFsX2ZfX2RvY19ffSwK
ISAgeyJjaGlzcXVhcmUiLAljaGlzcXVhcmUsICAgICAgICAgICAgICAxLCAg
ICAgIGNoaXNxdWFyZV9fZG9jX199LAohICB7Im5vbmNl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YiIpOwogIH0KLSAKLSAKLSAKLSAKLS0tIDMyMCwzMjIgLS0tLQo=

--0-1804289383-945558422=:25420--


From heather@v1.wustl.edu  Tue Dec 21 20:15:53 1999
From: heather@v1.wustl.edu (Heather Drury)
Date: Tue, 21 Dec 1999 14:15:53 -0600 (CST)
Subject: [Matrix-SIG] ValueError: object too deep for desired array (??)
Message-ID: <199912212015.OAA01848@v1.wustl.edu>


Hi,

I'm getting the following error on trying to do an array copy:

 File "volume.py", line 50, in __init__
    self.VoxData3D [:, :, :] = data.astype ('b')

ValueError: Object too deep for desired array

The relevant code is shown below ("data" is the input array", 
which in this case is 256x256x256):

	self.xdim = data.shape [2]
	self.ydim = data.shape [1]
	self.zdim = data.shape [0]
	self.VoxData3D = zeros ((self.zdim, self.ydim, self.xdim), 'b')
        self.VoxData3D [:, :, :] = data.astype ('b')
        self.VoxData = ravel (self.VoxData3D)

I can't seem to find anything in the doc about this...and since I'm 
allocating the space with the "zeros" command, I don't understand
why the object is "too deep". 

Any ideas?

Heather

-- 

Heather Drury                               	heather@v1.wustl.edu 
Washington University School of Medicine    	http://v1.wustl.edu	
Department of Anatomy & Neurobiology         	Phone: 314-362-4325
660 S. Euclid, MS 8108                       	FAX: 314-747-4370
St. Louis, MO 63110-1093


From guido@CNRI.Reston.VA.US  Wed Dec 22 20:00:19 1999
From: guido@CNRI.Reston.VA.US (Guido van Rossum)
Date: Wed, 22 Dec 1999 15:00:19 -0500
Subject: [Matrix-SIG] Two weeks Till Python Conference Early Bird Registration Deadline!
Message-ID: <199912222000.PAA17264@eric.cnri.reston.va.us>

We know that the Python conference isn't until the next millennium.
You have exactly two weeks left to register and qualify for the early
bird registration.  Since most of that time most people are taking off
for the holidays, it's really NOW OR NEVER!  If you haven't registered
and paid by January 5, you will paying full price...  So, be smart and
register NOW.  Also don't forget to book your hotel room by January 3.

Some highlights from the conference program:

- 8 tutorials on topics ranging from JPython to Fnorb;
- a keynote by Open Source evangelist Eric Raymond;
- another by Randy Pausch, father of the Alice Virtual Reality project;
- a separate track for Zope developers and users;
- live demonstrations of important Python applications;
- refereed papers, and short talks on current topics;
- a developers' day where the feature set of Python 2.0 is worked out.

Our motto, due to Bruce Eckel, is: "Life's better without braces."

Come and join us at the Key Bridge Marriott in Rosslyn (across the
bridge from Georgetown), January 24-27 in 2000.  Make the Python
conference the first conference you attend in the new millennium!

The early bird registration deadline is January 5.  More info:

    http://www.python.org/workshops/2000-01/

The program is now complete with the titles of all presentations.
There is still space in the demo session and in the short talks
session.

--Guido van Rossum (home page: http://www.python.org/~guido/)


From crabb2@llnl.gov  Thu Dec 23 00:28:54 1999
From: crabb2@llnl.gov (Charlie Crabb)
Date: Wed, 22 Dec 1999 16:28:54 -0800
Subject: [Matrix-SIG] Turning off the traceback on a raise
Message-ID: <38616CC6.2581E05C@glacier.llnl.gov>

    Is it possible to turn off the stack trace in python
    after raising an exception?
    e.g disable output from the first two lines:

  Traceback (innermost last):
  File "<stdin>", line 4, in ?
KeyError: nada

--
Charlie Crabb
Computer Scientist, LCPD/A/X Divisions
Lawrence Livermore National Laboratory, L-38
crabb2@llnl.gov 925-424-3265





From Oliphant.Travis@mayo.edu  Tue Dec 28 22:49:25 1999
From: Oliphant.Travis@mayo.edu (Travis Oliphant)
Date: Tue, 28 Dec 1999 16:49:25 -0600 (CST)
Subject: [Matrix-SIG] New Cephes module with arraymap method
Message-ID: <Pine.LNX.4.10.9912281627520.6360-100000@us2.mayo.edu>

I'm announcing the availability of Version 1.2 of the Cephes module at 
http://oliphant.netpedia.net

Cephes module provides many special functions of physics to the Numerical
Python user as ufuncs which are generalized functions that automatically
map over array arguments and follow useful broadcasting rules.  

I would like to see more special functions added to the library even if
they are written in Python.

Towards that end, version 1.2 contains a new python wrapper module called
SpecialFuncs.py that can include Python-only special functions.  

In addition, I have added a method to cephesmodule called arraymap that
acts like the map function but performs the broadcasting rules of ufuncs
and returns Numerical Python arrays as output.  

I have also included a class that allows wrapping a Python function that
takes scalar inputs and returns scalar outputs and returns a ufunc-like
function which automatically maps over array input arguments following the
ufunc broadcasting rules to return appropriately-sized outputs.

So, if you can't figure out how to "vectorize" your function.  You can
wrap it in this class and get mapping behavior automatically.  The
looping is all written in C and so is reasonably fast.

Comments and contributions are welcome.

Travis Oliphant
Oliphant.Travis@altavista.net


<P><A HREF="http://oliphant.netpedia.net/">SpecialFuncs 1.2</A> - an
extension module also known as cephes which provides many special
functions of physics to the Numerical Python user. (29-Dec-99)




From avoinov@exelixis.com  Wed Dec 29 22:16:36 1999
From: avoinov@exelixis.com (Alexander V. Voinov)
Date: Wed, 29 Dec 1999 14:16:36 -0800
Subject: [Matrix-SIG] import Numeric: add.reduce not found
Message-ID: <386A8844.4F3D46BA@exelixis.com>

Hi All

I tried to use Python-1.5.2 with LLNLNumeric11 on Solaris .2.5.1, and it
says:

Python 1.5.2 (#7, Dec 29 1999, 13:03:01)  [GCC 2.95 19990728 (release)]
on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import Numeric
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File
"/tools/Python-1.5.2/lib/python1.5/site-packages/numeric/Numeric.py",
line 319, in ?
    sum = add.reduce
NameError: add

Thank you in advance

Alexander




From avoinov@exelixis.com  Wed Dec 29 23:39:31 1999
From: avoinov@exelixis.com (Alexander V. Voinov)
Date: Wed, 29 Dec 1999 15:39:31 -0800
Subject: [Matrix-SIG] Re: [Fwd: import Numeric: add.reduce not found]
References: <386A9008.8D070112@exelixis.com>
Message-ID: <386A9BB3.B78E56ED@exelixis.com>

"Alexander V. Voinov" wrote:

> I tried to use Python-1.5.2 with LLNLNumeric11 on Solaris .2.5.1, and it
> says:
>
> Python 1.5.2 (#7, Dec 29 1999, 13:03:01)  [GCC 2.95 19990728 (release)]
> on sunos5
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import Numeric
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
>   File
> "/tools/Python-1.5.2/lib/python1.5/site-packages/numeric/Numeric.py",
> line 319, in ?
>     sum = add.reduce
> NameError: add

The same with LL*10.

Alexander




From avoinov@exelixis.com  Thu Dec 30 00:08:14 1999
From: avoinov@exelixis.com (Alexander V. Voinov)
Date: Wed, 29 Dec 1999 16:08:14 -0800
Subject: [Matrix-SIG] Re: [Fwd: import Numeric: add.reduce not found]
References: <386A9008.8D070112@exelixis.com> <386A9BB3.B78E56ED@exelixis.com>
Message-ID: <386AA26E.F4ED73D2@exelixis.com>

"Alexander V. Voinov" wrote:

> "Alexander V. Voinov" wrote:
>
> > I tried to use Python-1.5.2 with LLNLNumeric11 on Solaris .2.5.1, and it
> > says:
> >
> > Python 1.5.2 (#7, Dec 29 1999, 13:03:01)  [GCC 2.95 19990728 (release)]
> > on sunos5
> > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> > >>> import Numeric
> > Traceback (innermost last):
> >   File "<stdin>", line 1, in ?
> >   File
> > "/tools/Python-1.5.2/lib/python1.5/site-packages/numeric/Numeric.py",
> > line 319, in ?
> >     sum = add.reduce
> > NameError: add

I had to compile everything form Numeric/Setup statically into the 'python'
binary to make it work. It's ok for a short while, but I'd be very grateful
if somebody pointed me to the source of the problem.

Alexander




From jcollins@shell.pacificnet.net  Thu Dec 30 17:47:51 1999
From: jcollins@shell.pacificnet.net (Jeff Collins)
Date: Thu, 30 Dec 1999 09:47:51 -0800 (PST)
Subject: [Matrix-SIG] Re: [Fwd: import Numeric: add.reduce not found]
In-Reply-To: <386A9BB3.B78E56ED@exelixis.com>
Message-ID: <Pine.GSO.4.10.9912300944470.27532-100000@shell.pacificnet.net>

Just out of curiosity - do you have an old umathmodule.so
(or old version of NumPy) lying around in your path?  If so,
removing it could solve your problem.

Jeff


On Wed, 29 Dec 1999, Alexander V. Voinov wrote:

> "Alexander V. Voinov" wrote:
> 
> > I tried to use Python-1.5.2 with LLNLNumeric11 on Solaris .2.5.1, and it
> > says:
> >
> > Python 1.5.2 (#7, Dec 29 1999, 13:03:01)  [GCC 2.95 19990728 (release)]
> > on sunos5
> > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> > >>> import Numeric
> > Traceback (innermost last):
> >   File "<stdin>", line 1, in ?
> >   File
> > "/tools/Python-1.5.2/lib/python1.5/site-packages/numeric/Numeric.py",
> > line 319, in ?
> >     sum = add.reduce
> > NameError: add
> 
> The same with LL*10.
> 
> Alexander
> 
> 
> 
> _______________________________________________
> Matrix-SIG maillist  -  Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig
> 



From Oliphant.Travis@mayo.edu  Thu Dec 30 18:32:53 1999
From: Oliphant.Travis@mayo.edu (Travis Oliphant)
Date: Thu, 30 Dec 1999 12:32:53 -0600 (CST)
Subject: [Matrix-SIG] Problems with Numeric
In-Reply-To: <19991230170019.3ABAE1CD7A@dinsdale.python.org>
Message-ID: <Pine.LNX.4.10.9912301228400.10812-100000@us2.mayo.edu>

> I had to compile everything form Numeric/Setup statically into the 'python'
> binary to make it work. It's ok for a short while, but I'd be very grateful
> if somebody pointed me to the source of the problem.

I'm not sure what is wrong here, but add is a method of the ufunc module,
so it sounds like that is where the problem is.  The Numeric module
imports all of the methods of the ufunc module and so a NameError in this
circumstance seems to imply that the ufunc module is not completely
functional.

Try importing ufunc alone and looking at it's methods:

>>> import ufunc
>>> dir(ufunc)

You should see add there somewhere.  If it is not there then it is
probably a shared library problem.  Perhaps someone with more experience
on Solaris may have some insights.

Good luck,

Travis