From arb@connect.com.au Thu Oct 1 09:55:32 1998
From: arb@connect.com.au (Anthony Baxter)
Date: Thu, 01 Oct 1998 18:55:32 +1000
Subject: [Matrix-SIG] Int64 type on UltraSparc?
Message-ID: <199810010855.SAA28143@koro.off.connect.com.au>
More numpy newbie questions - is there any particular reason that Numeric
on the UltraSparc doesn't support the Int64 type, but does support Float64
and Complex64? Solaris2.6, compiled on an UltraSparc II system.
From cgw@pgt.com Fri Oct 2 22:33:29 1998
From: cgw@pgt.com (Charles G Waldman)
Date: Fri, 2 Oct 1998 17:33:29 -0400 (EDT)
Subject: [Matrix-SIG] Problem with integer arrays?
Message-ID: <13845.18089.247036.129551@janus.pgt.com>
Python 1.5 (#5, Sep 14 1998, 17:26:48) [GCC 2.7.2.3] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import Numeric
>>> Numeric.__version__
'1.4'
>>> a = Numeric.array((0.,0.))
>>> a**2
array([ 0., 0.])
>>> a = Numeric.array((0,0))
>>> a**2
Traceback (innermost last):
File "", line 1, in ?
OverflowError: math range error
From da@skivs.ski.org Fri Oct 2 22:45:23 1998
From: da@skivs.ski.org (David Ascher)
Date: Fri, 2 Oct 1998 14:45:23 -0700 (Pacific Daylight Time)
Subject: [Matrix-SIG] Problem with integer arrays?
In-Reply-To: <13845.18089.247036.129551@janus.pgt.com>
Message-ID:
On Fri, 2 Oct 1998, Charles G Waldman wrote:
> Python 1.5 (#5, Sep 14 1998, 17:26:48) [GCC 2.7.2.3] on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import Numeric
> >>> Numeric.__version__
> '1.4'
> >>> a = Numeric.array((0.,0.))
> >>> a**2
> array([ 0., 0.])
> >>> a = Numeric.array((0,0))
> >>> a**2
> Traceback (innermost last):
> File "", line 1, in ?
> OverflowError: math range error
Strange -- it's not a problem for me:
~/py:> python
Python 1.5.1 (#0, Apr 13 1998, 20:22:04) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import Numeric
>>> Numeric.__version__
'1.4'
>>> a = Numeric.array((0.0,0.0))
>>> a**2
array([ 0., 0.])
>>> a = Numeric.array((0,0))
>>> a**2
array([0, 0])
From busby@icf.llnl.gov Sat Oct 3 00:59:36 1998
From: busby@icf.llnl.gov (L. Busby)
Date: Fri, 2 Oct 98 16:59:36 PDT
Subject: [Matrix-SIG] Problem with integer arrays?
Message-ID: <9810022359.AA08771@icf.llnl.gov.llnl.gov>
[ Charles W., on Linux ]
>> >>> a = Numeric.array((0,0))
>> >>> a**2
>> Traceback (innermost last):
>> File "", line 1, in ?
>> OverflowError: math range error
[ David A., on Windows ]
>Strange -- it's not a problem for me:
It blows up for me also, on Linux, but not on Solaris or HP-UX.
Strangely, a*a is not a problem. It will be investigated.
Lee Busby
From tim.hochberg@ieee.org Sun Oct 4 18:40:26 1998
From: tim.hochberg@ieee.org (Tim Hochberg)
Date: Sun, 4 Oct 1998 11:40:26 -0600
Subject: [Matrix-SIG] JNumeric 0.1 alpha 4 is available.
Message-ID: <003801bdefbe$16a0bee0$75323fd1@R20CAREY.MAYO.EDU>
From the readme file:
---------------------------
JNumeric-0.1a4
WHAT IS JNUMERIC?
-----------------
JNumeric provides the functionality for JPython that Numeric does for
CPython. As the Numeric documentation states, Numeric is "...a
collection of extension modules to provide high-performance
multidimensional numeric arrays to the Python programming language."
As of JNumeric-0.1a4, JNumeric provides the same functionality as the
core of Numeric module, although it does not provide any of the
Standard extensions to Numeric module (FFT, LinearAlgebra,
RandomArray, Matrix, MLab, and UserArray).
OBTAINING JNUMERIC
------------------
The latest version of JNumeric can be obtained from
http://starship.skyport.net/~hochberg/jnumeric.tgz. If you plan to
use JNumeric, please subscribe to the jnumeric mailing list
(jnumeric@egroups.com) by sending a blank message to
jnumeric-subscribe@egroups.com. Bug reports, installation, problems,
etc. should be directed to this address. I would also appreciate it if
you send a message to the list if you successfully install and use
JNumeric, so that I have some idea how may people are using JNumeric.
If you have trouble downloading JNumeric as a tgz file (My version of
netscape does horrible things to tgz files), try
http://starship.skyport.net/~hochberg/jnumeric.tar.gz
____
/im (tim.hochberg@ieee.org)
From dlr@postbox.ius.cs.cmu.edu Tue Oct 6 17:50:50 1998
From: dlr@postbox.ius.cs.cmu.edu (dlr@postbox.ius.cs.cmu.edu)
Date: Tue, 6 Oct 98 12:50:50 EDT
Subject: [Matrix-SIG] Problem with integer arrays?
Message-ID: <199810061650.MAA02106@python.org>
Charles Waldman wrote:
>> >>> a = Numeric.array((0,0))
>> >>> a**2
>> Traceback (innermost last):
>> File "", line 1, in ?
>> OverflowError: math range error
In umathmodule.c, the function powll() has a range check:
> /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */
On my machine, the math range error is happening when we take
log2(0) = -inf. I think the best fix is to put a test around the
overflow check so that it's not executed if x == 0. I've modified my
version of umathmodule.c, and it seems to work fine (diffs appended).
Also, I noticed this strange behavior yesterday:
>>> import Numeric
>>> Numeric.__version__
'1.4'
>>> a = Numeric.ones(5)
>>> a
array([1, 1, 1, 1, 1])
>>> (-1) * a
array([-1, 1, -1, 1, -1])
I've made and mildly tested a change to umathmodule.c which I think
fixes this too (see below).
Of course, I'd welcome corrections or comments.
David LaRose
-------------------------------------
Note: This diff is for Numeric 1.4, from the LLNLPython5 distribution
diff umathmodule.c umathmodule.orig.c
261,271c261,263
<
< /******Added by dlr@cs.cmu.edu, 10/6/98**********/
< if(x != 0) { /* Range check unnecessary & dangerous if x == 0 */
< /******End of Addition by dlr@cs.cmu.edu, 10/6/98**********/
< logtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);
< if (logtwox * (double) n > (double) nbits)
< PyErr_SetString(PyExc_ArithmeticError, "Integer overflow in power.");
< /******Added by dlr@cs.cmu.edu, 10/6/98**********/
< } /* if(x != 0) */
< /******End of Addition by dlr@cs.cmu.edu, 10/6/98**********/
<
---
> logtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);
> if (logtwox * (double) n > (double) nbits)
> PyErr_SetString(PyExc_ArithmeticError, "Integer overflow in power.");
439,441d430
< /********Added by dlr, 10/6/98*******/
< s = 1; /* reset sign flag */
< /********End of addition by dlr, 10/6/98*******/
546,548d534
< /********Added by dlr, 10/6/98*******/
< s = 1; /* reset sign flag */
< /********End of addition by dlr, 10/6/98*******/
653,655d638
< /********Added by dlr, 10/6/98*******/
< s = 1; /* reset sign flag */
< /********End of addition by dlr, 10/6/98*******/
From gweon@umich.edu Tue Oct 6 18:42:57 1998
From: gweon@umich.edu (Gey-Hong Gweon)
Date: Tue, 06 Oct 1998 13:42:57 -0400
Subject: [Matrix-SIG] Problem with integer arrays?
References: <199810061650.MAA02106@python.org>
Message-ID: <361A56A1.DB9D43A2@umich.edu>
dlr@postbox.ius.cs.cmu.edu wrote:
> >>> import Numeric
> >>> Numeric.__version__
> '1.4'
> >>> a = Numeric.ones(5)
> >>> a
> array([1, 1, 1, 1, 1])
> >>> (-1) * a
> array([-1, 1, -1, 1, -1])
I am glad that you point this out! I had the same experience with LLNL
python package version 5. Then I found out that version 4 didn't have
this bug, so I am using this old version right now :( ... If I decide to
go back to version 5 (what are the benefits, I wonder ... pardon me, I
joined this discussion group only yesterday), I will try your fix.
--
Gey-Hong Gweon, Ph.D. candidate
The University of Michigan, Physics Department, Ann Arbor, MI 48109
(734) 647-9434 (Office), 763-3417 (Lab), 763-9694 (Fax)
From dlr@postbox.ius.cs.cmu.edu Tue Oct 6 19:38:57 1998
From: dlr@postbox.ius.cs.cmu.edu (dlr@postbox.ius.cs.cmu.edu)
Date: Tue, 6 Oct 98 14:38:57 EDT
Subject: [Matrix-SIG] Problem with integer arrays?
In-Reply-To: <199810061650.MAA02106@python.org> (dlr@postbox.ius.cs.cmu.edu)
Message-ID: <199810061838.OAA03339@python.org>
Folks, I just reread my previous post, and I think it sounds a little
arrogant. I think it was uncool for me to start hacking up the code
and posting diffs. In particular, I see from the README file that
I should have sent any suggestions to support@icf.llnl.gov .
I hope I haven't offended anyone. I especially hope I haven't
offended the people who've authored, distributed, and maintained this
fantastic package.
David
---
From: dlr@postbox.ius.cs.cmu.edu
Date: Tue, 6 Oct 98 12:50:50 EDT
[...]
In umathmodule.c, the function powll() has a range check:
[...]
From da@skivs.ski.org Tue Oct 6 19:49:06 1998
From: da@skivs.ski.org (David Ascher)
Date: Tue, 6 Oct 1998 11:49:06 -0700 (Pacific Daylight Time)
Subject: [Matrix-SIG] Problem with integer arrays?
In-Reply-To: <199810061838.OAA03339@python.org>
Message-ID:
> Folks, I just reread my previous post, and I think it sounds a little
> arrogant. I think it was uncool for me to start hacking up the code
> and posting diffs. In particular, I see from the README file that
> I should have sent any suggestions to support@icf.llnl.gov .
>
> I hope I haven't offended anyone. I especially hope I haven't
> offended the people who've authored, distributed, and maintained this
> fantastic package.
Geez, I doubt it!
The only suggestion I would make is to use context diffs, as the source
may have changed since the releases.
I think I can say that all patches are gratefully accepted for review.
The only reason you haven't heard a "thank you" yet is that the LLNL folk
are very busy w/ an upcoming conference. But I'll say it for them:
Thanks!
--david [not quite LLNL, but not too far =)]
From just@letterror.com Tue Oct 6 22:44:18 1998
From: just@letterror.com (Just van Rossum)
Date: Tue, 6 Oct 1998 23:44:18 +0200
Subject: [Matrix-SIG] array.index() in NumPy?
Message-ID:
How do I do the equivalent of
>>> a = range(10)
>>> a.index(5)
5
>>>
with NumPy?
Thanks!
Just
From HYoon@exchange.ml.com Tue Oct 6 23:32:05 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Tue, 6 Oct 1998 18:32:05 -0400
Subject: [Matrix-SIG] array.index() in NumPy?
Message-ID:
I do:
a = arrayrange(10)
nonzero(equal(a, 5))
Of course be prepared for mult matches, if you have many 5 in a.
Hope this helps,
Hoon,
> -----Original Message-----
> From: Just van Rossum
> Sent: Tuesday, October 06, 1998 5:44 PM
> To: matrix-sig@python.org
> Subject: [Matrix-SIG] array.index() in NumPy?
>
> How do I do the equivalent of
>
> >>> a = range(10)
> >>> a.index(5)
> 5
> >>>
>
> with NumPy?
>
> Thanks!
>
> Just
>
>
>
> _______________________________________________
> Matrix-SIG maillist - Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig
From jhauser@ifm.uni-kiel.de Wed Oct 7 09:43:38 1998
From: jhauser@ifm.uni-kiel.de (Janko Hauser)
Date: Wed, 7 Oct 1998 10:43:38 +0200 (CEST)
Subject: [Matrix-SIG] array.index() in NumPy?
In-Reply-To:
References:
Message-ID: <13851.10609.451228.889843@lisboa.ifm.uni-kiel.de>
>>> a=arange(10)
>>> nonzero(equal(a,5))
array([5])
>>>
__Janko
From HYoon@exchange.ml.com Wed Oct 7 19:39:18 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Wed, 7 Oct 1998 14:39:18 -0400
Subject: [Matrix-SIG] NaN
Message-ID:
Hello,
I get NaN's inside my array. And I would like to elimiate them using equal
or something like that, but I cannot
figure out how to mark them.
I tried:
equal(array, NaN)
equal(array, sqrt(-1))
Thank you,
Hoon,
From zcm@home.com Wed Oct 7 22:42:31 1998
From: zcm@home.com (Zane C. Motteler)
Date: Wed, 7 Oct 1998 13:42:31 -0800
Subject: [Matrix-SIG] Problem with integer arrays?
In-Reply-To: <361A56A1.DB9D43A2@umich.edu>
References: <199810061650.MAA02106@python.org>
Message-ID:
>dlr@postbox.ius.cs.cmu.edu wrote:
>
>> >>> import Numeric
>> >>> Numeric.__version__
>> '1.4'
>> >>> a = Numeric.ones(5)
>> >>> a
>> array([1, 1, 1, 1, 1])
>> >>> (-1) * a
>> array([-1, 1, -1, 1, -1])
>
>I am glad that you point this out! I had the same experience with LLNL
>python package version 5. Then I found out that version 4 didn't have
>this bug, so I am using this old version right now :( ... If I decide to
>go back to version 5 (what are the benefits, I wonder ... pardon me, I
>joined this discussion group only yesterday), I will try your fix.
I discovered and fixed this problem some weeks ago and it should be
in our latest or next (?) distribution. Sorry, I've been out of contact
for a couple of weeks, as I'm recovering from intestinal surgery. I
still read my email, but won't be back to work until next week. It
seems as if two weeks ago we were getting ready to release our latest
distribution, but I don't know how far that has got.
Zane
----------
Zane C. Motteler
Computer Scientist
Lawrence Livermore National Laboratory
writing from home
From Paul F. Dubois"
This worked for me on one machine.
C:\WINDOWS>python
Python 1.5.1 (#0, Apr 13 1998, 20:22:04) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from Numeric import *
>>> infinity=(array([1.0])/array([0.0]))[0]
>>> x=array([1.,2.,3.])
>>> y=array([1.,0.,1.])
>>> z=x/y
>>> print equal(z,infinity)
[0 1 0]
>>>
-----Original Message-----
From: Yoon, Hoon (CICG - NY Program Trading)
To: matrix-sig@python.org
Date: Wednesday, October 07, 1998 11:42 AM
Subject: [Matrix-SIG] NaN
>Hello,
>
> I get NaN's inside my array. And I would like to elimiate them using
equal
>or something like that, but I cannot
>figure out how to mark them.
>
> I tried:
>equal(array, NaN)
>equal(array, sqrt(-1))
>
> Thank you,
>
>Hoon,
>
>
>_______________________________________________
>Matrix-SIG maillist - Matrix-SIG@python.org
>http://www.python.org/mailman/listinfo/matrix-sig
>
>
From Paul F. Dubois"
On September 22 I believed that with one free day I could get the next NumPy
release out.
I still believe that. I'm sorry for those of you who have encountered bugs
we have already fixed. I've asked David Ascher to do it if he gets time,
thus doubling the infintesimal probability of success. Your patience will be
appreciated.
Paul Dubois
-----Original Message-----
From: Zane C. Motteler
To: Gey-Hong Gweon
Cc: matrix-sig@python.org
Date: Wednesday, October 07, 1998 1:38 PM
Subject: Re: [Matrix-SIG] Problem with integer arrays?
>>dlr@postbox.ius.cs.cmu.edu wrote:
>>
>>> >>> import Numeric
>>> >>> Numeric.__version__
>>> '1.4'
>>> >>> a = Numeric.ones(5)
>>> >>> a
>>> array([1, 1, 1, 1, 1])
>>> >>> (-1) * a
>>> array([-1, 1, -1, 1, -1])
>>
>>I am glad that you point this out! I had the same experience with LLNL
>>python package version 5. Then I found out that version 4 didn't have
>>this bug, so I am using this old version right now :( ... If I decide to
>>go back to version 5 (what are the benefits, I wonder ... pardon me, I
>>joined this discussion group only yesterday), I will try your fix.
>
>I discovered and fixed this problem some weeks ago and it should be
>in our latest or next (?) distribution. Sorry, I've been out of contact
>for a couple of weeks, as I'm recovering from intestinal surgery. I
>still read my email, but won't be back to work until next week. It
>seems as if two weeks ago we were getting ready to release our latest
>distribution, but I don't know how far that has got.
>
>Zane
>----------
>Zane C. Motteler
>Computer Scientist
>Lawrence Livermore National Laboratory
>writing from home
>
>_______________________________________________
>Matrix-SIG maillist - Matrix-SIG@python.org
>http://www.python.org/mailman/listinfo/matrix-sig
>
>
From HYoon@exchange.ml.com Wed Oct 7 23:16:10 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Wed, 7 Oct 1998 18:16:10 -0400
Subject: [Matrix-SIG] NaN (almost)
Message-ID:
Thanks Paul, but not quite....
>>> excP
array([ 9.12500000e+000, 9.27519777e+000, 9.25000000e+000,
9.06250000e+000,
8.93750000e+000, NaN, 9.00000000e+000,
9.00000000e+000, 9.00000000e+000, NaN,
9.00000000e+000, NaN, NaN,
9.00000000e+000, NaN, 9.00000000e+000,
NaN, 9.00000000e+000, NaN,
8.93750000e+000, 8.93750000e+000, NaN,
9.02269591e+000, NaN, NaN,
NaN, NaN, 0.00000000e+000])
>>> infini = (array([1.0])/array([0.0]))/[0]
>>> x = array([1.,2.,3.])
>>> y = array([1.,0.,1.])
>>> equal(x/y, infini)
array([0, 1, 0])
>>> NaNv = 1e1000000 - 1e10000000
>>> NaNv = array((1e1000000 - 1e10000000))
>>> NaNv
NaN
>>> NaNv = infini - infini
>>> NaNv
array([ NaN])
>>> equal(excP, NaNv)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,
0, 0])
No wonder
equal(NaNv, NaNv) is 0 too:
Appreciate it neverthless,
Hoon,
From ffjhl@uaf.edu Wed Oct 7 23:28:22 1998
From: ffjhl@uaf.edu (Jonah Lee)
Date: Wed, 7 Oct 1998 14:28:22 -0800 (AKDT)
Subject: [Matrix-SIG] Numpy array.tolist() memory leak ?
In-Reply-To:
Message-ID:
On Sun, 27 Sep 1998, David Ascher wrote:
Hi,
Thanks for the suggestion. I've played with this and other possibilities
for a while but could not get the problem solved. I think one of the
problems may be that the procedure is called recursively which makes the
release of memory less intuitive. I would appreciate it if anyone could
see a solution to this situation. I've used a workaround in my application
code to avoid using this particular method but would still like to see a
solution one day. Thanks.
>
>
> On Sun, 27 Sep 1998, Jonah Lee wrote:
> >
> > There seems to be a memory leak with the following example:
> >
> > from Numeric import *
> > a=array([[1,2,3],[4,5,6],[7,8,9]], Float)
> > for i in range(100000):
> > for j in range(100000):
> > c=a.tolist()
> >
> > If a=array([1,2,3,4]), then there is no leak.
> >
> > Any advice on this would be appreciated. Thanks.
>
> I could be wrong (reference counting was never my forte), but I believe
> that arrayobject.c's PyArray_ToList() should be modified to read:
>
> ...
>
> for (i=0; i ! PyArrayObject *elt;
> ! elt = array_item((PyArrayObject *)self, i);
> ! PyList_SetItem(lp, i, PyArray_ToList(elt));
> ! Py_DECREF(elt);
> }
>
> ...
>
> otherwise the subarrays ([1,2,3] etc. in the example above) never get
> DECREF'ed out.
>
> --david ascher
>
>
> _______________________________________________
> Matrix-SIG maillist - Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig
>
Regards,
Jonah
From tim_one@email.msn.com Thu Oct 8 04:55:25 1998
From: tim_one@email.msn.com (Tim Peters)
Date: Wed, 7 Oct 1998 23:55:25 -0400
Subject: [Matrix-SIG] NaN (almost)
In-Reply-To:
Message-ID: <000201bdf26f$7aea29a0$6a9e2299@tim>
[Hoon Yoon, trying to identify NaNs]
> ...
> >>> NaNv = 1e1000000 - 1e10000000
> ...
> No wonder
>
> equal(NaNv, NaNv) is 0 too:
That's interesting! That's what the IEEE-754 standard says NaN == NaN
should do (believe it or not ), but in core Python NaNv == NaNv
returns 1 (core comparisons test for object identity (and treat "x is y" as
"equal") before delegating to the type-specific comparison implementations).
I don't have Numeric here to test it, but the behavior you show above
suggests that the standard-approved NaN test
x is a NaN
if and only if
not x == x
should work reliably for you using Numeric's "equal". I.e., compare the
array to itself elementwise using equal, and the result will have 1's all &
everywhere a NaN isn't .
Using core Python ==, I don't think you can do anything *simple* better than
x is a NaN
if and only if
not x + 0 == x
But that can fail (by saying something's a NaN that actually isn't) if x is
a denorm and you're on flush-denorm-to-0 hardware.
not-sure-that's-helpful-but-it's-sure-accurate-ly y'rs - tim
From jhauser@ifm.uni-kiel.de Thu Oct 8 09:45:30 1998
From: jhauser@ifm.uni-kiel.de (Janko Hauser)
Date: Thu, 8 Oct 1998 10:45:30 +0200 (CEST)
Subject: [Matrix-SIG] NaN
In-Reply-To:
References:
Message-ID: <13852.31485.572139.307112@lisboa.ifm.uni-kiel.de>
Try to compare the data to itself. NaN is not_equal NaN
index_of_all_nans=nonzero(not_equal(ravel(data),ravel(data)))
__Janko
From ej@ee.duke.edu Thu Oct 8 10:00:58 1998
From: ej@ee.duke.edu (eric jones)
Date: Thu, 8 Oct 1998 05:00:58 -0400
Subject: [Matrix-SIG] whats the best way to combine 1D arrays into 2D arrays?
Message-ID: <000101bdf29a$2a927a90$83421098@elsie.duke.edu>
Hello,
I'd like to take two 1D arrays and combine them as the rows of a 2D array.
For example, in Matlab, the following works:
x=1:3;
y=1:3;
z=[x;y]
so that
z= [[1,2,3]
[1,2,3]]
The way I've done this in NumPy is:
x = arange(1,4)
y = arange(1,4)
z = concatenate( (reshape(x,[1,-1]),reshape(y,[1,-1]) ) )
Is there a more compact way of doing this?
thanks,
eric
From arne@requin.ppm.u-psud.fr Thu Oct 8 10:28:08 1998
From: arne@requin.ppm.u-psud.fr (Arne Keller)
Date: Thu, 08 Oct 1998 11:28:08 +0200
Subject: [Matrix-SIG] whats the best way to combine 1D arrays into 2D arrays?
References: <000101bdf29a$2a927a90$83421098@elsie.duke.edu>
Message-ID: <361C85A8.C4F5F85B@requin.ppm.u-psud.fr>
eric jones wrote:
>
> Hello,
>
> I'd like to take two 1D arrays and combine them as the rows of a 2D array.
> For example, in Matlab, the following works:
>
> x=1:3;
> y=1:3;
> z=[x;y]
>
> so that
> z= [[1,2,3]
> [1,2,3]]
>
> The way I've done this in NumPy is:
>
> x = arange(1,4)
> y = arange(1,4)
> z = concatenate( (reshape(x,[1,-1]),reshape(y,[1,-1]) ) )
>
> Is there a more compact way of doing this?
>
> thanks,
> eric
>
> _______________________________________________
> Matrix-SIG maillist - Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig
I use the following:
>>> a = array([1,2,3,4,5])
>>> b = array([6,7,8,9,10])
c = array((a,b))
>>> c
array([[ 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10]])
--
Arne Keller
Laboratoire de Photophysique Moleculaire du CNRS.
Universite de Paris-Sud, 91405 Orsay Cedex, France.
tel.: (33) 1 69 15 82 83 -- fax. : (33) 1 69 15 67 77
From jhauser@ifm.uni-kiel.de Thu Oct 8 12:30:51 1998
From: jhauser@ifm.uni-kiel.de (Janko Hauser)
Date: Thu, 8 Oct 1998 13:30:51 +0200 (CEST)
Subject: [Matrix-SIG] whats the best way to combine 1D arrays into 2D arrays?
In-Reply-To: <000101bdf29a$2a927a90$83421098@elsie.duke.edu>
References: <000101bdf29a$2a927a90$83421098@elsie.duke.edu>
Message-ID: <13852.41428.127941.226457@lisboa.ifm.uni-kiel.de>
>>> x = arange(1,4)
>>> y = arange(1,4)
>>> transpose(array([x[:], y[:]]))
array([[1, 1],
[2, 2],
[3, 3]])
Although transpose makes a copy. A little longer:
>>> xy = array([x[:], y[:]])
>>> xy.shape=(len(x),len(xy))
>>> xy
array([[1, 2],
[3, 1],
[2, 3]])
__Janko
From HYoon@exchange.ml.com Thu Oct 8 14:11:03 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Thu, 8 Oct 1998 09:11:03 -0400
Subject: [Matrix-SIG] More on NaN and bugs? : was [Matrix-SIG] NaN
Message-ID:
Paul,
Tried both scalar and vector (tried vector because I was following what
you were doing). Neither works.
A simple answer is multiply the scalar or vector or matrix with
zeros(vec.shape), then equal(org, zeros).
Any 0's should be either NaN or Infinity. That should be close as long as I
don't have infinity in there, but I
can use your inf cmp for that. So, your solution still helps.
Can anyone think of other exceptions I should worry about?
Thanks,
Hoon,
----
More NaN ?
There was a movement to get NaN as standard missing on a matrix for both
float and complex. Do anyone
know what happened to that?
Bugs?
I could not get binaryseach to work in my NumPy (comes back w/ Trace back
Name error) and
argsort seems to have a bug. It may due to the fact thatI have a very old
version of NumPy
(still was Beta 1.5 yr ago).
Has there been fix for either one since I installed?
How do I find out what version I have? My SA takes care of these things and
it takes me more than some effort
to upgrade my installation. (I am still using 1.4 heaven sakes)
Thanks,
Hoon,
> -----Original Message-----
> From: Paul F. Dubois
> Sent: Wednesday, October 07, 1998 7:24 PM
> To: Yoon, Hoon (CICG - NY Program Trading)
> Subject: Re: [Matrix-SIG] NaN (almost)
>
> Uh, maybe I'm missing something, but NaNv is a vector, not a scalar; don't
> you want NaNv[0] passed to equal?
> -----Original Message-----
> From: Yoon, Hoon (CICG - NY Program Trading)
> To: 'Paul F. Dubois' ; matrix-sig@python.org
>
> Date: Wednesday, October 07, 1998 3:17 PM
> Subject: RE: [Matrix-SIG] NaN (almost)
>
>
> >Thanks Paul, but not quite....
> >
> >>>> excP
> >array([ 9.12500000e+000, 9.27519777e+000, 9.25000000e+000,
> >9.06250000e+000,
> > 8.93750000e+000, NaN, 9.00000000e+000,
> > 9.00000000e+000, 9.00000000e+000, NaN,
> > 9.00000000e+000, NaN, NaN,
> > 9.00000000e+000, NaN, 9.00000000e+000,
> > NaN, 9.00000000e+000, NaN,
> > 8.93750000e+000, 8.93750000e+000, NaN,
> > 9.02269591e+000, NaN, NaN,
> > NaN, NaN, 0.00000000e+000])
> >>>> infini = (array([1.0])/array([0.0]))/[0]
> >>>> x = array([1.,2.,3.])
> >>>> y = array([1.,0.,1.])
> >>>> equal(x/y, infini)
> >array([0, 1, 0])
> >>>> NaNv = 1e1000000 - 1e10000000
> >>>> NaNv = array((1e1000000 - 1e10000000))
> >>>> NaNv
> >NaN
> >>>> NaNv = infini - infini
> >>>> NaNv
> >array([ NaN])
> >>>> equal(excP, NaNv)
> >array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0,
> >0, 0, 0,
> > 0, 0])
> >
> >No wonder
> >
> >equal(NaNv, NaNv) is 0 too:
> >Appreciate it neverthless,
> >
> >Hoon,
> >
From HYoon@exchange.ml.com Thu Oct 8 17:16:29 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Thu, 8 Oct 1998 12:16:29 -0400
Subject: [Matrix-SIG] binarysearch? & Little more on combine 1D arrays into 2D arrays?
Message-ID:
Hi,
>>> binarysearch(a, 0)
Traceback (innermost last):
File "", line 0, in ?
NameError: binarysearch
I uploaded latest Window versio of NumPy152.exe from Triple L site. So, I
know
that I am not getting problems due to having old version. I copied the func
Name
from the docs.
-------------------------------
>>> a
array([0, 1, 2])
>>> d
array([[0, 1, 2],
[3, 4, 5]])
Just wanted to see I can extend this ? a bit more.
Let's say I wanted to see
a | d
Is there a simpler way? (This isn't too bad, but I would like to skip
a.shape = () step).
a.shape = (1,3)
concatenate((a,d),0)
array([[0, 1, 2],
[0, 1, 2],
[3, 4, 5]])
Thanks,
Hoon,
P.S: Thanks for all help from Paul, Janko, David, Tim, Eric, etc... for NaN
clean solutions.
From da@skivs.ski.org Thu Oct 8 17:18:28 1998
From: da@skivs.ski.org (David Ascher)
Date: Thu, 8 Oct 1998 09:18:28 -0700 (Pacific Daylight Time)
Subject: [Matrix-SIG] binarysearch? & Little more on combine 1D arrays
into 2D arrays?
In-Reply-To:
Message-ID:
On Thu, 8 Oct 1998, Yoon, Hoon (CICG - NY Program Trading) wrote:
> Just wanted to see I can extend this ? a bit more.
> Let's say I wanted to see
> a | d
>
> Is there a simpler way? (This isn't too bad, but I would like to skip
> a.shape = () step).
>
> a.shape = (1,3)
> concatenate((a,d),0)
> array([[0, 1, 2],
> [0, 1, 2],
> [3, 4, 5]])
The trick is to remember to use NewAxis:
>>> a
array([0, 1, 2])
>>> d
array([[0, 1, 2],
[3, 4, 5]])
>>> concatenate((a[NewAxis,:], d))
array([[0, 1, 2],
[0, 1, 2],
[3, 4, 5]])
Whenever you find yourself doing a reshape w/ a 1 somewhere, chances are
you can get away with a NewAxis operation instead, which is quicker and
simpler to read (IMO).
--david
From jhauser@ifm.uni-kiel.de Thu Oct 8 22:36:54 1998
From: jhauser@ifm.uni-kiel.de (Janko Hauser)
Date: Thu, 8 Oct 1998 23:36:54 +0200 (CEST)
Subject: [Matrix-SIG] More on NaN and bugs? : was [Matrix-SIG] NaN
In-Reply-To:
References:
Message-ID: <13853.12260.642340.812840@lisboa.ifm.uni-kiel.de>
May I add these two functions to this thread?
def isnan(m):
"""
Returns a condition array, which is true where m has a NaN value.
"""
return Numeric.not_equal(m,m)
def isinf(m):
"""
Returns a condition array, which is true where m has an Inf value.
Does not look for sign of Inf.
"""
n = isnan(m)
return isnan(Numeric.where(n,0,m)*0.)
Is there some obvious case, which is not covered?
__Janko
From HYoon@exchange.ml.com Thu Oct 8 21:46:32 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Thu, 8 Oct 1998 16:46:32 -0400
Subject: [Matrix-SIG] More on NaN and bugs? : was [Matrix-SIG] NaN
Message-ID:
In case we are adding functions. I wrote the following.
def packr( M):
"""
Returns only rows or colums, which is Not NaN (Packr is Gauss by
Aptech func)
works for 2d. axis is bit confusing for a Gauss person
"""
return take( M, isanx(M))
def isanx(d, axis=1):
if len(d.shape) == 2:
return nonzero(equal(add.reduce(equal(d,d),axis),
d.shape[axis]))
elif len(d.shape) == 1:
return nonzero(equal(d,d))
else: raise IndexError, "function : packr is for up to 2D matrix
only"
I can't really make this work for more than 2D. I hope someone can figure
out something better.
Thanks Janko,
Hoon,
> -----Original Message-----
> From: Janko Hauser
> Sent: Thursday, October 08, 1998 5:37 PM
> To: Yoon, Hoon (CICG - NY Program Trading)
> Cc: matrix-sig@python.org
> Subject: [Matrix-SIG] More on NaN and bugs? : was [Matrix-SIG] NaN
>
> May I add these two functions to this thread?
>
> def isnan(m):
> """
> Returns a condition array, which is true where m has a NaN value.
> """
> return Numeric.not_equal(m,m)
>
> def isinf(m):
> """
> Returns a condition array, which is true where m has an Inf value.
> Does not look for sign of Inf.
> """
> n = isnan(m)
> return isnan(Numeric.where(n,0,m)*0.)
>
>
> Is there some obvious case, which is not covered?
>
> __Janko
>
> _______________________________________________
> Matrix-SIG maillist - Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig
From HYoon@exchange.ml.com Thu Oct 8 22:03:27 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Thu, 8 Oct 1998 17:03:27 -0400
Subject: [Matrix-SIG] Error NaN on Numpy152.exe
Message-ID:
>>> INF
1.#INF
>>> NA = INF - INF
>>> NA
-1.#IND
>>> equal(NA,NA)
1
>>>
I hope I am not driving everyone crazy with this, but I get >>> equal(NA,NA)
-> 1 on windows
version of NumPy. Like most people I use windows not as much as Unix, but
this is problematic for cross platform issues. And non of the tricks we
talked
about would work for NaN.
Thanks,
Hoon,
Using:
PythonWin 1.5.1 (#0, Apr 13 1998, 20:22:04) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Portions copyright 1994-1998 Mark Hammond (MHammond@skippinet.com.au)
Don't think this is problem, because works fine on my Solaris 1.4Py.
From neves@inf.puc-rio.br Fri Oct 9 00:01:54 1998
From: neves@inf.puc-rio.br (Paulo Eduardo Neves)
Date: Thu, 08 Oct 1998 20:01:54 -0300
Subject: [Matrix-SIG] Where are the Unsigned Ints?
Message-ID: <361D4462.E4BCBA0C@inf.puc-rio.br>
Hi,
Maybe this is a stupid question, since I'm a new to NumPy.
It looks like in NumPy we just have unsigned integers of 8 bits. Is
there any reason for the inexistence of unsigneds of 32 bits?
Shouldn't it be easy to implement? I still didn't look in the code.
regards,
--
Paulo Eduardo Neves
PUC-Rio de Janeiro
Pager: Central: 292-4499 cod. 213 99 64
ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html
From Paul F. Dubois"
While we volunteered to be the "keepers" of NumPy, we don't have as much
time as we would like to improve it. This is open source software. You are
welcome to add what you want and submit the changes for consideration. Be
aware that the NumPy source is hard to understand.
-----Original Message-----
From: Paulo Eduardo Neves
To: matrix-sig@python.org
Date: Thursday, October 08, 1998 4:01 PM
Subject: [Matrix-SIG] Where are the Unsigned Ints?
>Hi,
>Maybe this is a stupid question, since I'm a new to NumPy.
>
>It looks like in NumPy we just have unsigned integers of 8 bits. Is
>there any reason for the inexistence of unsigneds of 32 bits?
>
>Shouldn't it be easy to implement? I still didn't look in the code.
>regards,
>--
>Paulo Eduardo Neves
>PUC-Rio de Janeiro
>Pager: Central: 292-4499 cod. 213 99 64
>ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html
>
>_______________________________________________
>Matrix-SIG maillist - Matrix-SIG@python.org
>http://www.python.org/mailman/listinfo/matrix-sig
>
>
From hinsen@cnrs-orleans.fr Sun Oct 11 14:48:50 1998
From: hinsen@cnrs-orleans.fr (Konrad Hinsen)
Date: Sun, 11 Oct 1998 15:48:50 +0200
Subject: [Matrix-SIG] Syntactic sugar for constructing arrays
In-Reply-To: (message from Charles G Waldman on
29 Sep 1998 13:12:06 -0400)
References:
Message-ID: <199810111348.PAA15472@dirac.cnrs-orleans.fr>
> Since the array is such a useful type, I'd like to see a
> cleaner-looking syntax for creating array objects. I'd like to be
> able to write, for instance,
>
> center = <256,256>
> point = <10,-20>
>
> What do people think of this suggestion?
I'd like it too, but the only relevant opinion when it comes to
syntax issues in Python is Guido's ;-)
Moreover, with the current state of Python and NumPy this would be
impossible to implement. The interpreter would have to recognize
the syntax and create the array object - but the array type is defined
in an extension that most Python users don't even have!
--
-------------------------------------------------------------------------------
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 HYoon@exchange.ml.com Mon Oct 12 14:13:16 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Mon, 12 Oct 1998 09:13:16 -0400
Subject: [Matrix-SIG] Syntactic sugar for constructing arrays
Message-ID:
Hi,
I think there was a long discussion on a very similar issue proposed by
David Ascher. Please read that. You should get a clearer picture of Konrad's
point. Look in David's Starship site and look for keywords in News Archive.
Hack, I love to see:
A' (transpose)
A .* B (dotproduct)
A > B (greater(A,B))
A^2 (A**2)
A[ [1,2,13], [2,9] ] = NA
dataframes (Splus)
standard NA (msg values)
This will make Python on par with Gauss, Splus, Mathlab, etc...
The reason I am trying to do more on Python is still because the data
manipulation (which is about 70%+ of my work) is much much easier on Python.
I can put many things in production without using bulky Stat packages and
still have speed on C on matricies. So, I am happy enough.
Hoon,
> -----Original Message-----
> From: Konrad Hinsen
> Sent: Sunday, October 11, 1998 9:49 AM
> To: cgw@pgt.com
> Cc: matrix-sig@python.org
> Subject: Re: [Matrix-SIG] Syntactic sugar for constructing arrays
>
> > Since the array is such a useful type, I'd like to see a
> > cleaner-looking syntax for creating array objects. I'd like to be
> > able to write, for instance,
> >
> > center = <256,256>
> > point = <10,-20>
> >
> > What do people think of this suggestion?
>
> I'd like it too, but the only relevant opinion when it comes to
> syntax issues in Python is Guido's ;-)
>
> Moreover, with the current state of Python and NumPy this would be
> impossible to implement. The interpreter would have to recognize
> the syntax and create the array object - but the array type is defined
> in an extension that most Python users don't even have!
> --
> --------------------------------------------------------------------------
> -----
> 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
> --------------------------------------------------------------------------
> -----
>
> _______________________________________________
> Matrix-SIG maillist - Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig
From hweaver@pdx.oneworld.com Mon Oct 12 18:28:16 1998
From: hweaver@pdx.oneworld.com (Harold L. Weaver)
Date: Mon, 12 Oct 1998 10:28:16 -0700
Subject: [Matrix-SIG] Syntactic sugar for constructing arrays
References: <199810121600.MAA17661@python.org>
Message-ID: <36223C30.A4751C3C@pdx.oneworld.com>
Check out OMatrix, http://www.omatrix.com . I think it may be a Python application, and
there is a free trial version which is not particularly crippled.
- Hal
> 1. RE: Syntactic sugar for constructing arrays (Yoon, Hoon (CICG - NY Program Trading))
>
> ------------------------------------------------------------------------
>
> Subject: RE: [Matrix-SIG] Syntactic sugar for constructing arrays
> Date: Mon, 12 Oct 1998 09:13:16 -0400
> From: "Yoon, Hoon (CICG - NY Program Trading)"
> CC: matrix-sig@python.org
>
> Hi,
>
> I think there was a long discussion on a very similar issue proposed by
> David Ascher. Please read that. You should get a clearer picture of Konrad's
> point. Look in David's Starship site and look for keywords in News Archive.
> Hack, I love to see:
> A' (transpose)
> A .* B (dotproduct)
> A > B (greater(A,B))
> A^2 (A**2)
> A[ [1,2,13], [2,9] ] = NA
> dataframes (Splus)
> standard NA (msg values)
> This will make Python on par with Gauss, Splus, Mathlab, etc...
> The reason I am trying to do more on Python is still because the data
> manipulation (which is about 70%+ of my work) is much much easier on Python.
> I can put many things in production without using bulky Stat packages and
> still have speed on C on matricies. So, I am happy enough.
>
> Hoon,
From HYoon@exchange.ml.com Mon Oct 12 21:22:25 1998
From: HYoon@exchange.ml.com (Yoon, Hoon (CICG - NY Program Trading))
Date: Mon, 12 Oct 1998 16:22:25 -0400
Subject: [Matrix-SIG] Syntactic sugar for constructing arrays
Message-ID:
Harold,
I actually know of omatrix. What makes you think it may be Python App?
Windows only, no OO, no COM, DDE only, etc... If I can wrap this around
Python that would be great, because it's probably the speed king on Stat
Packages.
http://www.informatik.uni-frankfurt.de/~stst/ncrunch.html
Check this site out. Stefan has good info on various stat packages.
Hoon,
> -----Original Message-----
> From: Harold L. Weaver
> Sent: Monday, October 12, 1998 1:28 PM
> To: matrix-sig@python.org
> Subject: Re: [Matrix-SIG] Syntactic sugar for constructing arrays
>
> Check out OMatrix, http://www.omatrix.com . I think it may be a Python
> application, and
> there is a free trial version which is not particularly crippled.
>
>
Andrew Mullhaupt Said,
>A' (transpose)
I would do almost anything to stop people from propagating this one. If it
was legal to shoot statisticians, I'd have done it already.
------
Andrew, you would have to kill nearly all staticians (a lot of
bullets). This is standard practice in all Econometric books I've seen. I do
realize that this is probably not likely in Python. It would be really
hard to tell what's inside quote and what's transpose. Again, I do
not quite mind using slight long hand. I heard that better slicing will come
in future version of Python. Still pretty damn good without it. I was just
illustrating that you don't get everything you want in manner you want and
Python doesn't have to.
From dubois1@llnl.gov Tue Oct 13 21:04:43 1998
From: dubois1@llnl.gov (Paul F. Dubois)
Date: Tue, 13 Oct 1998 13:04:43 -0700
Subject: [Matrix-SIG] LLNL PyGraphics documentation release
Message-ID: <000b01bdf6e4$b8d84700$f4160218@c1004579-C.plstn1.sfba.home.com>
The LLNL PyGraphics documentation has been updated on our web site,
http://xfiles.llnl.gov. It is now all in Acrobat 3 format. There is a link
to the Adobe site if you need to get the plugin for your browser.
This format has the advantage over our previous HTML format that the reader
comes with good searching, the TOC and Index are all linked, and there are
many fewer problems producing the correct document for the web compared to
our previous tool. You can print a copy of a manual from the reader, too.
From hweaver@pdx.oneworld.com Tue Oct 13 19:15:55 1998
From: hweaver@pdx.oneworld.com (Harold L. Weaver)
Date: Tue, 13 Oct 1998 11:15:55 -0700
Subject: [Matrix-SIG] Syntactic sugar for constructing arrays
References: <199810131600.MAA00899@python.org>
Message-ID: <362398DB.937AEC0E@pdx.oneworld.com>
Hoon,
I think that OMatrix may be a Python app because it seem to have similar speed performance to
Python when running my program scripts and because OMatrix also has awkward syntax for
constructing arrays. However I don't know much about Python, and even less about other
scripting languages -- other than OMatrix.
Thanks for the pointer to Steinhaus' web site featuring comparisons of data analysis programs.
- Hal
>
>
> I actually know of omatrix. What makes you think it may be Python App?
> Windows only, no OO, no COM, DDE only, etc... If I can wrap this around
> Python that would be great, because it's probably the speed king on Stat
> Packages.
> http://www.informatik.uni-frankfurt.de/~stst/ncrunch.html
> Check this site out. Stefan has good info on various stat packages.
>
> Hoon,
> > -----Original Message-----
> > From: Harold L. Weaver
> > Sent: Monday, October 12, 1998 1:28 PM
> > To: matrix-sig@python.org
> > Subject: Re: [Matrix-SIG] Syntactic sugar for constructing arrays
> >
> > Check out OMatrix, http://www.omatrix.com . I think it may be a Python
> > application, and
> > there is a free trial version which is not particularly crippled.
From dubois1@llnl.gov Wed Oct 14 18:31:29 1998
From: dubois1@llnl.gov (Paul F. Dubois)
Date: Wed, 14 Oct 1998 10:31:29 -0700
Subject: [Matrix-SIG] LLNLDistribution 6 and NumPy-16.exe available
Message-ID: <003301bdf798$7acbace0$f4160218@c1004579-C.plstn1.sfba.home.com>
At ftp://ftp-icf.llnl.gov/pub/python, you can download LLNLDistribution.tgz
and/or NumPy.exe.
The former is a full source distribution for the LLNL-managed packages
(NumPy, CXX, Gist, Gist3D, OOG, Arrayfns, PyHistory, PyPDB, RNG) while the
latter is a Windows 95/98/NT installer for either binary or binary+source
for NumPy.
The release notes are attached. (Release_Notes.htm).
My thanks to David Ascher for getting this release finalized.
I have removed some of the older versions of the sources and documentation
from the FTP site. The correct site for the documentation that is not
included in the distribution is http://xfiles.llnl.gov.
begin 666 Release_Notes.htm
M/&AT;6P^#0H-"CQH96%D/@T*/'1I=&QE/CPO=&ET;&4^#0H\+VAE860^#0H-
M"CQB;V1Y/@T*#0H\:#$^4F5L96%S92!N;W1E3PO83X@/"]L
M:3X-"B @/&QI/CQA(&AR968](E).1R]214%$344N:'1M(CY23D<\+V$^(#PO
M;&D^#0H@(#QL:3X\82!H'1E;G-I=F4@8G5G(&9I>&5S(&EN($=I3PO;&D^#0H@(#QL:3Y0>4AI2!A;F0@+F,@9FEL97,@=&\@3&5G
M86PN:'1M("A:86YE($UO='1E;&5R*2X\+VQI/@T*(" \;&D^0VAA;F=E9"!+
M;VYR860@2&EN2!T;R!T:&4@4AI'0-"B @("!T86=S(&YO=R!I;B!H:7-T;W)Y
M+G!Y(')A=&AE**&5S(&)U9W,@:6X@
M3$%086-K+"!-871R:7@N<'DN(%-E92!214%$344@:6X@3G5M97)I8V%L+CPO
M;&D^#0H\+W5L/@T*#0H\:#(^4F5L96%S92 S("A*=6YE(#$R+" Q.3DX*3PO
M:#(^#0H-"CQU;#X-"B @/&QI/D9I>&5S('1O($=I'AM;V1U;&4N8WAX('1O(&-X>'-U<'!O&5S(&EN($=I2P@1VES=#-$+TQI8B]Q=6%D;65S:"YP>2 H5&AO;6%S
M($=E;&QE:W5M*2X@/"]L:3X-"CPO=6P^#0H-"CQH,CY296QE87-E(#$@*$UA
M>2P@,3DY."D\+V@R/@T*#0H\<#Y4:&ES(')E;&5A71H;VX@97AT96YS:6]N('!A8VMA9V5S(&-U2!M86EN
M=&%I;F5D(&)Y($Q,3DPN#0I)="!S=7!E7-T96T@;V8@9&ES=')I8G5T:6YG(&]U****71H;VX-"G-O=7)C92!T
LLNLPython6.tgz turned out to have its text files in Windows format, due to
a misunderstanding I had with David. It is fixed as of 14:10 PST Weds.
10/14. Our apologies to anyone who was inconvenienced.
From ransom@cfa.harvard.edu Sun Oct 18 05:36:41 1998
From: ransom@cfa.harvard.edu (Scott M. Ransom)
Date: Sun, 18 Oct 1998 04:36:41 +0000
Subject: [Matrix-SIG] Python interface for PPGPLOT
Message-ID: <36297059.79CB8A5E@cfa.harvard.edu>
Hello all,
As a first Python project, I decided to write Python wrappers
(Pgplot.py) around the 'PPGPLOT' CPython wrappers around the 'cpgplot' C
wrappers around the 'pgplot' Fortran library! ;)
The reason for doing such a ludicrous sounding thing is to make high
quality 1D and 2D plotting as blatantly easy from Python as it is in
IDL, Matlab, etc... And the end result is that it does (pretty much)
just that.
And besides, it was a good project to help me learn Python (which I am
now completely addicted to).
I have posted the file at the following URL:
ftp://cfa0.harvard.edu/pub/ransom/Pgplot.py
The code is well commented and includes string comment blocks describing
how each procedure is used. The code can also be run straight from the
command line (i.e. 'python Pgplot.py') where it will demo a few of its
abilities.
Please feel free to use, modify, or ignore any or all of it as you see
fit.
I would definitely be interested in any feedback, bug reports, or
suggestions that you might have.
Scott Ransom
PS: I am also interested in seeing if anyone can suggest a better way
of performing the following function (it is included in the demo code):
------------
import Numeric
def distance(width):
"""
distance(width):
Return a 'width' x 'width' Numeric Python array with each
point set to the geometric distance from the array's center.
"""
x = Numeric.arange(-width/2.0+0.5, width/2.0+0.5, 1.0)
x = Numeric.resize(x, (width,width))
return Numeric.sqrt(x**2 + Numeric.transpose(x)**2)
------------
--
Scott M. Ransom
Phone: (580) 536-7215 Address: 703 SW Chaucer Cir.
email: ransom@cfa.harvard.edu Lawton, OK 73505
PGP Fingerprint: D2 0E D0 10 CD 95 06 DA EF 78 FE 2B CB 3A D3 53
From ransom@cfa.harvard.edu Sun Oct 18 05:56:21 1998
From: ransom@cfa.harvard.edu (Scott M. Ransom)
Date: Sun, 18 Oct 1998 04:56:21 +0000
Subject: [Matrix-SIG] Python interface for PPGPLOT
References: <36297059.79CB8A5E@cfa.harvard.edu>
Message-ID: <362974F5.CAADB58A@cfa.harvard.edu>
Scott M. Ransom wrote:
> PS: I am also interested in seeing if anyone can suggest a better way
> of performing the following function (it is included in the demo code):
>
> ------------
> import Numeric
>
> def distance(width):
> """
> distance(width):
> Return a 'width' x 'width' Numeric Python array with each
> point set to the geometric distance from the array's center.
>
> """
> x = Numeric.arange(-width/2.0+0.5, width/2.0+0.5, 1.0)
> x = Numeric.resize(x, (width,width))
> return Numeric.sqrt(x**2 + Numeric.transpose(x)**2)
> ------------
Wow I'm stupid.
About 2 seconds after I sent this, I noticed that I could save a bunch of
FLOPs by simply changing the routine to read:
------------
import Numeric
def distance(width):
"""
distance(width):
Return a 'width' x 'width' Numeric Python array with each
point set to the geometric distance from the array's center.
"""
x = Numeric.arange(-width/2.0+0.5, width/2.0+0.5, 1.0)
x = x**2
x = Numeric.resize(x, (width,width))
return Numeric.sqrt(x + Numeric.transpose(x))
------------
Anyone see anything else?
Scott
--
Scott M. Ransom
Phone: (580) 536-7215 Address: 703 SW Chaucer Cir.
email: ransom@cfa.harvard.edu Lawton, OK 73505
PGP Fingerprint: D2 0E D0 10 CD 95 06 DA EF 78 FE 2B CB 3A D3 53
From ransom@cfa.harvard.edu Tue Oct 20 02:09:57 1998
From: ransom@cfa.harvard.edu (Scott M. Ransom)
Date: Tue, 20 Oct 1998 01:09:57 +0000
Subject: [Matrix-SIG] Python interface for PPGPLOT
References: <199810191831.OAA20512@orion.pppl.gov>
Message-ID: <362BE2E5.D5062022@cfa.harvard.edu>
Greg Hammett wrote:
> Hi,
>
> I've done a little dabling with Numerical Python. I was puzzled by your
> recent message on interfacing to PPGPLOT. You said you wanted:
>
> > The reason for doing such a ludicrous sounding thing is to make high
> > quality 1D and 2D plotting as blatantly easy from Python as it is in
> > IDL, Matlab, etc... And the end result is that it does (pretty much)
>
> but Livermore's Numerical Python distribution
> http://xfiles.llnl.gov/python.htm already includes interfaces to at least 2
> different plotting packages (gist and an oop plotting package) that allow
> one to do this. Is there some advantage to PPGPLOT over those packages, or
> are you just more familiar with the naming conventions in PPGPLOT? I just
> thought I'd save you some time if you didn't know about these already.
>
> Greg
Good question. There are a few reasons why I decided to write my own instead
of using the LLNL packages:
1. I have used PGPLOT before, in both its 'C' and Perl variants, and was
quite impressed with the quality of the output as well as the large number of
device types that it supports (and therefore I also knew the syntax).
2. PGPLOT is _very_ common in the astronomical community. And being an
astronomer, almost every single computer I could dream of running Python with
graphics on, already has PGPLOT installed. (whereas Gist or Yorick are
virtually unheard of).
3. I wanted to create plotting commands much like IDL's, where you can get a
professional looking plot with only a single command. This is, of course,
probably possible with Gist/OOG, but I have only dabbled with the demos and
not done much else.
4. PGPLOT allows you to have a second X or Y axis with different ranges and
labels. While I know that Gist allows the 2nd label, I am not sure that it
supports the 2nd set of ranges (please correct me if I am wrong). These
secondary axes are very important for my current work.
5. I wanted a fairly simple (but useful) project to undertake to help me
learn Python for my current project -- using Parallel Python with graphics and
NumPy on large MPP machines as a glue language for a large 'C' pulsar search
code I have written.
Could I have accomplished all of this with Gist/OOG? Sure. Why not? But now
people using Tim Pearson's PGPLOT along with Nick Patavalis' PPGPLOT under
Python have another little addition to their bag of tricks. And isn't that
what open source is all about?
Personally, I think that the best bet for a publication-quality plotting
library for Python lies in the already very good GNU Plotutils
(http://www.gnu.org/software/plotutils/plotutils.html). The use of postscript
fonts allows for terrific looking plot labels/titles. Once the scripting
language interfaces are in place (I believe their goal is to have calls from
all of the popular scripting languages) I don't think that many other
libraries will be able to touch it (for 2D graphics -- we will still need a
high-quality 3D solution which includes axes and labeling, IMHO). And of
course it uses GPL and should be portable to any platform on the planet.
Scott
--
Scott M. Ransom
Phone: (580) 536-7215 Address: 703 SW Chaucer Cir.
email: ransom@cfa.harvard.edu Lawton, OK 73505
PGP Fingerprint: D2 0E D0 10 CD 95 06 DA EF 78 FE 2B CB 3A D3 53
From miller5@uiuc.edu Tue Oct 20 16:11:46 1998
From: miller5@uiuc.edu (Mike Miller)
Date: 20 Oct 1998 10:11:46 -0500
Subject: [Matrix-SIG] Python interface for PPGPLOT
References: <199810191831.OAA20512@orion.pppl.gov> <362BE2E5.D5062022@cfa.harvard.edu>
Message-ID:
>>>>> "Scott" == Scott M Ransom writes:
>> Greg Hammett wrote:
>> ... but Livermore's Numerical Python distribution
>> http://xfiles.llnl.gov/python.htm already includes
>> interfaces to at least 2 different plotting packages (gist
>> and an oop plotting package) that allow one to do this.
>> Is there some advantage to PPGPLOT over those packages ...
> Good question. There are a few reasons why I decided to
> write my own instead of using the LLNL packages:
> Personally, I think that the best bet for a
> publication-quality plotting library for Python lies in the
> already very good GNU Plotutils
> (http://www.gnu.org/software/plotutils/plotutils.html).
I agree. While libplot is not nearly as fast as the llnl
graphics, I find it to be much easier to use to make high quality
graphics. It is also capable of a larger number of output
formats. The 2.2 release will include plotting routines that
will do things similar to what graph does. There's a SWIGed
version of libplot version 2.1.5 at
.
Mike
--
Michael A. Miller miller5@uiuc.edu
Department of Physics, University of Illinois, Urbana-Champaign
From Ted.Horst@wdr.com Tue Oct 20 16:59:06 1998
From: Ted.Horst@wdr.com (Ted Horst)
Date: Tue, 20 Oct 98 10:59:06 -0500
Subject: [Matrix-SIG] Python interface for PPGPLOT
In-Reply-To:
References: <199810191831.OAA20512@orion.pppl.gov>
<362BE2E5.D5062022@cfa.harvard.edu>
Message-ID: <9810201559.AA01401@ch1d2833nwk>
Can I compile any of these plotting packages on Unix without X windows ?
2D PostScript output is all I need to start, but it would be nice to get 3D
as well at some point.
Thanks,
Ted Horst
(not speaking for any Swiss banks)
From miller5@uiuc.edu Tue Oct 20 19:33:55 1998
From: miller5@uiuc.edu (Mike Miller)
Date: 20 Oct 1998 13:33:55 -0500
Subject: [Matrix-SIG] Python interface for PPGPLOT
References: <199810191831.OAA20512@orion.pppl.gov> <362BE2E5.D5062022@cfa.harvard.edu> <9810201559.AA01401@ch1d2833nwk>
Message-ID:
>>>>> "Ted" == Ted Horst writes:
> Can I compile any of these plotting packages on Unix
> without X windows ? 2D PostScript output is all I need to
> start, but it would be nice to get 3D as well at some
> point.
For plotutils, you should be able to use the --without-x option
when you configure it.
Mike
--
Michael A. Miller miller5@uiuc.edu
Department of Physics, University of Illinois, Urbana-Champaign
From tim.hochberg@ieee.org Thu Oct 22 14:39:22 1998
From: tim.hochberg@ieee.org (Tim Hochberg)
Date: Thu, 22 Oct 1998 07:39:22 -0600
Subject: [Matrix-SIG] Bug in convolve.
Message-ID: <009601bdfdc1$6dd60560$2db73fd1@R20CAREY.MAYO.EDU>
While working on JNumeric I found what appears to be a bug in convolve.
Here's an illustration:
CNumeric:
>>> from Numeric import *
>>> a = arange(5)
>>> convolve(a,a,2)
array([ 0, 4, 11, 20, 30, 20, 11, 4, 0])
>>> convolve(a,a[::-1],2)
array([ 0, 0, 1, 4, 10, 20, 25, 24, 16])
>>> convolve(a[::-1],a,2)
array([16, 24, 25, 20, 10, 4, 1, 0, 0])
JNumeric:
>>> from Numeric import *
>>> a = arange(5)
>>> convolve(a,a,2)
array([ 0, 0, 1, 4, 10, 20, 25, 24, 16])
>>> convolve(a, a[::-1], 2)
array([ 0, 4, 11, 20, 30, 20, 11, 4, 0])
>>> convolve(a[::-1], a, 2)
array([ 0, 4, 11, 20, 30, 20, 11, 4, 0])
One of these is obviously wrong. Since convolve(a, b) = convolve(b,a) should
hold, the culprit appears to be CNumeric's convolve. It appears that:
convolve_CNumeric(a, b, mode) = convolve_JNumeric(a, b[::-1], mode)
This means a quick fix could be implemented in Python by defining:
def convolve(a, b, mode=0):
return convolve(a, b[::-1], mode)
in Numeric.
____
/im (tim.hochberg@ieee.org)
From alan@groucho.med.jhmi.edu Fri Oct 23 15:20:01 1998
From: alan@groucho.med.jhmi.edu (Alan Grossfield)
Date: Fri, 23 Oct 1998 10:20:01 -0400
Subject: [Matrix-SIG] problems pickling arrays of PyObjects
Message-ID: <199810231420.KAA01349@groucho.med.jhmi.edu>
I think I've found a fairly serious problem with Numeric's pickler:
when you try to use it on arrays of arbitrary objects, it sometimes will
cause a core dump either upon unpickling or upon access to the array
after unpickling.
Consider the following test:
m Numeric import *
class test:
def __init__(self,a,b):
self.a=a
self.b=b
if __name__ == '__main__':
a=5
b=7
t=test(a,b)
print 'Create instance t of class test --'
print 't.a=',t.a, 't.b=', t.b
t2=test(b,a)
print t2.a, t2.b
print 'Create instance t2 of class test --'
print 't2.a=',t2.a, 't2.b=', t2.b
arr=array( [t,t2] )
print 'Create array arr = array( [t,t2] )'
print arr
file=open('array.pick', 'w')
p=Pickler(file)
p.dump(arr)
file.close()
print 'Pickle arr using Numeric pickler'
# cut here
file=open('array.pick', 'r')
u=Unpickler(file)
arr2=u.load()
print 'Extract arr to arr2 using Numeric'
print arr2
# dump core on the print
print 'I managed to extract arr2'
If you just run this as a single script, it works fine. However, if,
after creating the pickle using this script, you then use last piece
(below #cut here) to unpickle, you'll get a core dump either on the load()
or on the print. There seems to be some architecture dependence here --
using Konrad's latest distribution under Irix 6.2, the core dump comes upon
access, while using the RPMs from Oliver Andrich's page on Redhat 5.0 the dump comes on load.
Thanks,
Alan Grossfield
--------------------------------------------------------------------------
|"In theory, there is no difference between theory and practice. In |
|practice, there is." Jan L.A. van de Snepscheut |
--------------------------------------------------------------------------
From hinsen@cnrs-orleans.fr Fri Oct 23 18:04:53 1998
From: hinsen@cnrs-orleans.fr (Konrad Hinsen)
Date: Fri, 23 Oct 1998 19:04:53 +0200
Subject: [Matrix-SIG] problems pickling arrays of PyObjects
In-Reply-To: <199810231420.KAA01349@groucho.med.jhmi.edu> (message from Alan
Grossfield on Fri, 23 Oct 1998 10:20:01 -0400)
References: <199810231420.KAA01349@groucho.med.jhmi.edu>
Message-ID: <199810231704.TAA19354@dirac.cnrs-orleans.fr>
> I think I've found a fairly serious problem with Numeric's pickler:
> when you try to use it on arrays of arbitrary objects, it sometimes will
> cause a core dump either upon unpickling or upon access to the array
> after unpickling.
Now that I understand what the problem really is, the explanation is
fairly simple: There is no provision to pickle general-object arrays
at all in the current NumPy code, as is obvious from a quick glance at
module Numeric. The pickled file contains simply the addresses of the
elements.
Array pickling needs a serious revision anyway (with cPickle support),
so maybe this is a good opportunity to attack that problem. Maybe the
easiest solution for general-object arrays is conversion to a nested
list before pickling and reconversion upon loading. But an explicit
pickle routine for this case is not difficult either.
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 alan@groucho.med.jhmi.edu Tue Oct 27 18:50:59 1998
From: alan@groucho.med.jhmi.edu (Alan Grossfield)
Date: Tue, 27 Oct 1998 13:50:59 -0500
Subject: [Matrix-SIG] problems pickling arrays of PyObjects
In-Reply-To: Your message of "Fri, 23 Oct 1998 19:04:53 +0200."
<199810231704.TAA19354@dirac.cnrs-orleans.fr>
Message-ID: <199810271850.NAA19220@groucho.med.jhmi.edu>
Konrad>Now that I understand what the problem really is, the explanation is
Konrad>fairly simple: There is no provision to pickle general-object arrays
Konrad>at all in the current NumPy code, as is obvious from a quick glance at
Konrad>module Numeric. The pickled file contains simply the addresses of the
Konrad>elements.
Konrad>
Konrad>Array pickling needs a serious revision anyway (with cPickle support),
Here's a trivial patch to Numeric.py, which makes it complain if
you try to pickle an array of PyObjects.
diff -u Numeric.py.orig Numeric.py
--- Numeric.py.orig Tue Oct 27 13:15:24 1998
+++ Numeric.py Tue Oct 27 13:19:50 1998
@@ -186,6 +186,10 @@
# byte-order issues for portability.
def DumpArray(m, fp):
+
+ # patch -- check for array of PyObjects
+ if m.typecode() == 'O':
+ raise TypeError, "Numeric Pickler can't pickle arrays of Objects"
s = m.shape
if LittleEndian: endian = "L"
else: endian = "B"
Alan Grossfield
--------------------------------------------------------------------------
|"In theory, there is no difference between theory and practice. In |
|practice, there is." Jan L.A. van de Snepscheut |
--------------------------------------------------------------------------
From just@letterror.com Tue Oct 27 19:59:59 1998
From: just@letterror.com (Just van Rossum)
Date: Tue, 27 Oct 1998 20:59:59 +0100
Subject: [Matrix-SIG] ANN: NumPy 1.6 distributions for Mac
Message-ID:
I've put a binary distribution of NumPy 1.6 for MacPython 1.5.1 at:
and CodeWarrior stuff for people who want to build it themselves here:
Note that the latter is just a folder containing a CW project and some .exp
files, it merely supplements the official LLNL sources.
Oh, it is PPC-only, sorry.
Just
**