You can subscribe to this list here.
2000 |
Jan
(8) |
Feb
(49) |
Mar
(48) |
Apr
(28) |
May
(37) |
Jun
(28) |
Jul
(16) |
Aug
(16) |
Sep
(44) |
Oct
(61) |
Nov
(31) |
Dec
(24) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(56) |
Feb
(54) |
Mar
(41) |
Apr
(71) |
May
(48) |
Jun
(32) |
Jul
(53) |
Aug
(91) |
Sep
(56) |
Oct
(33) |
Nov
(81) |
Dec
(54) |
2002 |
Jan
(72) |
Feb
(37) |
Mar
(126) |
Apr
(62) |
May
(34) |
Jun
(124) |
Jul
(36) |
Aug
(34) |
Sep
(60) |
Oct
(37) |
Nov
(23) |
Dec
(104) |
2003 |
Jan
(110) |
Feb
(73) |
Mar
(42) |
Apr
(8) |
May
(76) |
Jun
(14) |
Jul
(52) |
Aug
(26) |
Sep
(108) |
Oct
(82) |
Nov
(89) |
Dec
(94) |
2004 |
Jan
(117) |
Feb
(86) |
Mar
(75) |
Apr
(55) |
May
(75) |
Jun
(160) |
Jul
(152) |
Aug
(86) |
Sep
(75) |
Oct
(134) |
Nov
(62) |
Dec
(60) |
2005 |
Jan
(187) |
Feb
(318) |
Mar
(296) |
Apr
(205) |
May
(84) |
Jun
(63) |
Jul
(122) |
Aug
(59) |
Sep
(66) |
Oct
(148) |
Nov
(120) |
Dec
(70) |
2006 |
Jan
(460) |
Feb
(683) |
Mar
(589) |
Apr
(559) |
May
(445) |
Jun
(712) |
Jul
(815) |
Aug
(663) |
Sep
(559) |
Oct
(930) |
Nov
(373) |
Dec
|
From: Charles L. B. Ph.D. <bo...@ac...> - 2001-07-18 22:33:08
|
Hello, I have python2.1.1c1 in I:\python21. It's up and running OK. I downloaded Numeric-20.1.0.win32-py2.1.exe, placed it in I:\python21, opened up a DOS window and ran the installer. The desktop flickered *very* briefly. Import Numeric returns "No module named Numeric". I cannot find any files named numeric.py. Does the installer assume python2.1 is in C:\python21? If so, how can I pass the correct drive information to the installer? Thanks for your help. Charles Bowman |
From: Konrad H. <hi...@cn...> - 2001-07-18 15:22:36
|
> I would appreciate it, if Numpy could handle the Kronecker-product of > two matrices X, Y. > > kron(X,Y) is the Kronecker tensor product of X and Y. import Numeric def kron(x, y): return Numeric.multiply.outer(x, y) > The result is a large matrix formed by taking all possible products > between the elements of X and those of Y. If X is m-by-n > and Y is p-by-q, then kron(X,Y) is m*p-by-n*q. OK, there's one difference: the function shown about returns an array of shape (m, n, p, q). If the input arrays are always 2D, the following will do what you need: import Numeric def kron(x, y): z = Numeric.transpose(Numeric.multiply.outer(x, y), [0, 2, 1, 3]) z.shape = (z.shape[0]*z.shape[1], z.shape[2]*z.shape[3]) return z Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hi...@cn... Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- |
From: Charles G W. <cg...@al...> - 2001-07-18 15:05:22
|
Nils Wagner writes: > > How can I rearrange the result of outerproduct to the result of > Kronecker product with numpy ? > def kron(a,b): o = outerproduct(a,b) o.shape = a.shape + b.shape return concatenate(concatenate(o, axis=1), axis=1) |
From: Nils W. <nw...@is...> - 2001-07-18 14:54:55
|
"Paul F. Dubois" schrieb: > Using the outer product you get a matrix that has the right size and > contents but it is m*n by p*q > Was that a misprint in your post? > >>> x > array([1, 2, 3, 4, 5, 6]) > >>> x.shape=(3,2) > >>> y = 10*transpose(x) > >>> y > array([[10, 30, 50], > [20, 40, 60]]) > >>> z = outerproduct(x.flat, y.flat) > >>> z > array([[ 10, 30, 50, 20, 40, 60], > [ 20, 60, 100, 40, 80, 120], > [ 30, 90, 150, 60, 120, 180], > [ 40, 120, 200, 80, 160, 240], > [ 50, 150, 250, 100, 200, 300], > [ 60, 180, 300, 120, 240, 360]]) > >>> > > -----Original Message----- > From: num...@li... > [mailto:num...@li...]On Behalf Of Nils > Wagner > Sent: Wednesday, July 18, 2001 4:10 AM > To: num...@li... > Subject: [Numpy-discussion] Kronecker product > > Hi, > > I would appreciate it, if Numpy could handle the Kronecker-product of > two matrices X, Y. > > kron(X,Y) is the Kronecker tensor product of X and Y. > The result is a large matrix formed by taking all possible products > between the elements of X and those of Y. If X is m-by-n > and Y is p-by-q, then kron(X,Y) is m*p-by-n*q. > > Nils > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > http://lists.sourceforge.net/lists/listinfo/numpy-discussion >>> a > array([[1, 2], > [3, 4]]) > >>> b > array([[11, 12], > [13, 14]]) > >>> outerproduct(a,b) > array([[11, 12, 13, 14], > [22, 24, 26, 28], > [33, 36, 39, 42], > [44, 48, 52, 56]]) The Kronecker product applied to A,B is kron(A,B) = array([[11,12,22,24], [13,14,26,28], [33,36,44,48], [39,42,52,56]]) How can I rearrange the result of outerproduct to the result of Kronecker product with numpy ? Cheers, Nils |
From: Paul F. D. <pa...@pf...> - 2001-07-18 14:49:57
|
Using the outer product you get a matrix that has the right size and contents but it is m*n by p*q Was that a misprint in your post? >>> x array([1, 2, 3, 4, 5, 6]) >>> x.shape=(3,2) >>> y = 10*transpose(x) >>> y array([[10, 30, 50], [20, 40, 60]]) >>> z = outerproduct(x.flat, y.flat) >>> z array([[ 10, 30, 50, 20, 40, 60], [ 20, 60, 100, 40, 80, 120], [ 30, 90, 150, 60, 120, 180], [ 40, 120, 200, 80, 160, 240], [ 50, 150, 250, 100, 200, 300], [ 60, 180, 300, 120, 240, 360]]) >>> -----Original Message----- From: num...@li... [mailto:num...@li...]On Behalf Of Nils Wagner Sent: Wednesday, July 18, 2001 4:10 AM To: num...@li... Subject: [Numpy-discussion] Kronecker product Hi, I would appreciate it, if Numpy could handle the Kronecker-product of two matrices X, Y. kron(X,Y) is the Kronecker tensor product of X and Y. The result is a large matrix formed by taking all possible products between the elements of X and those of Y. If X is m-by-n and Y is p-by-q, then kron(X,Y) is m*p-by-n*q. Nils _______________________________________________ Numpy-discussion mailing list Num...@li... http://lists.sourceforge.net/lists/listinfo/numpy-discussion |
From: Nils W. <nw...@is...> - 2001-07-18 12:09:04
|
Hi, I would appreciate it, if Numpy could handle the Kronecker-product of two matrices X, Y. kron(X,Y) is the Kronecker tensor product of X and Y. The result is a large matrix formed by taking all possible products between the elements of X and those of Y. If X is m-by-n and Y is p-by-q, then kron(X,Y) is m*p-by-n*q. Nils |
From: Jochen <jo...@un...> - 2001-07-17 20:31:03
|
>>>>> Paul F Dubois wrote on Tue, 17 Jul 2001 12:53:52 -0700: Paul> This file is no longer in the distribution. Uhm, what am I doing wrong? cvs up && cvs stat -v Src/fastumathmodule.c =================================================================== File: fastumathmodule.c Status: Locally Modified Working revision: 1.1 Repository revision: 1.1 /cvsroot/numpy/Numerical/Src/fastumathmodule.c,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none) Existing Tags: No Tags Exist Paul> -----Original Message----- Paul> Another little patch needed for NumPy as of today to compile on Paul> Cygwin: Paul> Index: Src/fastumathmodule.c Paul> =================================================================== Paul> RCS file: /cvsroot/numpy/Numerical/Src/fastumathmodule.c,v Greetings, Jochen -- University of North Carolina phone: 919-962-4403 Department of Chemistry phone: 919-962-1579 Venable Hall CB#3290 fax: 919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E |
From: Paul F. D. <pa...@pf...> - 2001-07-17 20:03:10
|
This file is no longer in the distribution. -----Original Message----- From: num...@li... [mailto:num...@li...]On Behalf Of Jochen K=FCpper Sent: Tuesday, July 17, 2001 12:18 PM To: Numpy Discussion Subject: [Numpy-discussion] Cygwin Another little patch needed for NumPy as of today to compile on Cygwin: Index: Src/fastumathmodule.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/numpy/Numerical/Src/fastumathmodule.c,v retrieving revision 1.1 diff -u -r1.1 fastumathmodule.c --- Src/fastumathmodule.c 2001/07/16 23:19:23 1.1 +++ Src/fastumathmodule.c 2001/07/17 19:16:39 @@ -2123,7 +2123,7 @@ {NULL, NULL, 0} /* sentinel */ }; -void initfastumath() { +DL_EXPORT(void) initfastumath() { PyObject *m, *d, *s; /* Create the module and add the functions */ Greetings, Jochen -- Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper= .de Libert=E9, =C9galit=E9, Fraternit=E9 GnuPG key: 44BCCD= 8E Sex, drugs and rock-n-roll _______________________________________________ Numpy-discussion mailing list Num...@li... http://lists.sourceforge.net/lists/listinfo/numpy-discussion |
From: Jochen <jo...@un...> - 2001-07-17 19:17:44
|
Another little patch needed for NumPy as of today to compile on Cygwin: Index: Src/fastumathmodule.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/numpy/Numerical/Src/fastumathmodule.c,v retrieving revision 1.1 diff -u -r1.1 fastumathmodule.c --- Src/fastumathmodule.c 2001/07/16 23:19:23 1.1 +++ Src/fastumathmodule.c 2001/07/17 19:16:39 @@ -2123,7 +2123,7 @@ {NULL, NULL, 0} /* sentinel */ }; =20 -void initfastumath() { +DL_EXPORT(void) initfastumath() { PyObject *m, *d, *s; =20 /* Create the module and add the functions */ Greetings, Jochen --=20 Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper= .de Libert=E9, =C9galit=E9, Fraternit=E9 GnuPG key: 44BCCD= 8E Sex, drugs and rock-n-roll |
From: Paul F. D. <pa...@pf...> - 2001-07-10 20:09:54
|
Release 20.1 is available for your dining pleasure. |
From: Konrad H. <hi...@cn...> - 2001-07-10 18:54:27
|
> Is there any intention for inclusion of the missing functions in > future releases of Numpy ? Usually code submissions are gratefully accepted. But I am not aware of anyone working on any of these topics at the moment. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hi...@cn... Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- |
From: Nils W. <nw...@is...> - 2001-07-10 15:12:56
|
Konrad Hinsen schrieb: > > I would appreciate it, if Numpy could handle the following functions : > > > > 1. Fix eig to also be able to solve the generalized eigenvalue problem > > and polynomial eigenvalue problems > > That would be a relatively simple addition to LinearAlgebra, but > would also require some additional routines from LAPACK. > > > 2. Support for matrix functions like logm, expm, sqrtm > > That can be done in Python code. > > > 3. Wavelet transform > > For efficiency, that should be done in C/Fortran. Are there any wavelet > libraries out there? Anyway, this should become a separate package. > > > 4. Solver for ODE's and DAE's > > Given the variety of equations and solvers, this looks like a big > project. Good Python integration is also not trivial. So that's not > only a separate package, but even a major one. > > Konrad. > -- > ------------------------------------------------------------------------------- > Konrad Hinsen | E-Mail: hi...@cn... > Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 > Rue Charles Sadron | Fax: +33-2.38.63.15.17 > 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ > France | Nederlands/Francais > ------------------------------------------------------------------------------- Is there any intention for inclusion of the missing functions in future releases of Numpy ? Nils. |
From: Konrad H. <hi...@cn...> - 2001-07-10 14:56:29
|
> I would appreciate it, if Numpy could handle the following functions : > > 1. Fix eig to also be able to solve the generalized eigenvalue problem > and polynomial eigenvalue problems That would be a relatively simple addition to LinearAlgebra, but would also require some additional routines from LAPACK. > 2. Support for matrix functions like logm, expm, sqrtm That can be done in Python code. > 3. Wavelet transform For efficiency, that should be done in C/Fortran. Are there any wavelet libraries out there? Anyway, this should become a separate package. > 4. Solver for ODE's and DAE's Given the variety of equations and solvers, this looks like a big project. Good Python integration is also not trivial. So that's not only a separate package, but even a major one. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hi...@cn... Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- |
From: John J. L. <ph...@cs...> - 2001-07-10 14:56:15
|
On Tue, 10 Jul 2001, Nils Wagner wrote: [...] > I would appreciate it, if Numpy could handle the following functions : [...] > 2. Support for matrix functions like logm, expm, sqrtm [...] What do you mean by 'matrix functions'? John |
From: Nils W. <nw...@is...> - 2001-07-10 10:51:43
|
Hi, Is there any wish-list of projects and feature requests for Numpy ? I would appreciate it, if Numpy could handle the following functions : 1. Fix eig to also be able to solve the generalized eigenvalue problem and polynomial eigenvalue problems 2. Support for matrix functions like logm, expm, sqrtm 3. Wavelet transform 4. Solver for ODE's and DAE's Nils Wagner |
From: Paul F. D. <pa...@pf...> - 2001-07-09 18:10:06
|
It is an advertised difference between MA and Numeric that index operations return copies, not references. -----Original Message----- From: num...@li... [mailto:num...@li...]On Behalf Of Joe Van Andel Sent: Thursday, June 28, 2001 3:42 PM To: numpy-discussion Subject: [Numpy-discussion] MA : assignment to slices doesn't work like Numeric. I retrieved the latest MA from CVS. I've noticed that assigning to a slice doesn't work the same as Numeric. Here's a simple test program: -------------------------------- from MA import * #from Numeric import * numBeams,numGates = (5,4) result = ones((numBeams, numGates),'f') * -327.68 print 'result = ', result t1 = ones((numGates,),'f') t2 = 2* ones((numGates,),'f') result[0] = t1 result[1][:] = t2 print 'result = ', result ----------------------------------------- Output using 'MA': result = [[-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,]] result = [[ 1. , 1. , 1. , 1. ,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,]] However, if I use Numeric, rather than MA, I get: result = [[-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68]] result = [[ 1. 1. 1. 1. ] [ 2. 2. 2. 2. ] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68]] So, a[x][:] = my_array doesn't seem to work using 'MA'. -- Joe VanAndel National Center for Atmospheric Research http://www.atd.ucar.edu/~vanandel/ Internet: van...@uc... _______________________________________________ Numpy-discussion mailing list Num...@li... http://lists.sourceforge.net/lists/listinfo/numpy-discussion |
From: Paul F. D. <pa...@pf...> - 2001-07-09 18:06:20
|
I receive a steady stream of questions sent to me about Numerical Python. Frequently, in their zeal to protect themselves from spam, the senders obscure their sending address. This causes my reply to bounce. I sometimes drop the ball and fail to reply promptly due to the volume of letters I receive, advancing senility, or because the question requires research and it goes onto my stack for too long. But before you conclude that I'm not answering you because of ineptitude, please be sure I *can* answer your mail with a simple reply. Thanks, Paul |
From: Jochen <jo...@un...> - 2001-07-03 14:13:14
|
Dear All, I have had some problems with=20 Cannot export _bss_end__: symbol not defined messages and friends again for the cvs Numerical Python package. Although the LAPACK-module uses the DL_EXPORT approach and works fine, the other packages apparently try the .def-approach (which I barely heard about); this packages do not build for me on latest Cygwin. (I have not tried it on older ones.) Putting DL_EXPORTs around all the init-functions fixes this for me: Index: Packages/FFT/Src/fftpackmodule.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/numpy/Numerical/Packages/FFT/Src/fftpackmodule.c,v retrieving revision 1.1 diff -u -r1.1 fftpackmodule.c --- Packages/FFT/Src/fftpackmodule.c 2000/07/06 16:54:16 1.1 +++ Packages/FFT/Src/fftpackmodule.c 2001/07/03 14:06:48 @@ -238,7 +238,7 @@ "" ; =20 -void +DL_EXPORT(void) initfftpack() { PyObject *m, *d; Index: Packages/RNG/Src/RNGmodule.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/numpy/Numerical/Packages/RNG/Src/RNGmodule.c,v retrieving revision 1.1 diff -u -r1.1 RNGmodule.c --- Packages/RNG/Src/RNGmodule.c 2000/07/06 16:54:17 1.1 +++ Packages/RNG/Src/RNGmodule.c 2001/07/03 14:06:49 @@ -613,7 +613,7 @@ "Random number generator: independent random number streams." ; =20 -void +DL_EXPORT(void) initRNG() { PyObject *m, *d; Index: Packages/kinds/Src/_kindsmodule.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/numpy/Numerical/Packages/kinds/Src/_kindsmodule.c,v retrieving revision 1.1 diff -u -r1.1 _kindsmodule.c --- Packages/kinds/Src/_kindsmodule.c 2001/04/17 23:35:10 1.1 +++ Packages/kinds/Src/_kindsmodule.c 2001/07/03 14:06:49 @@ -10,7 +10,7 @@ {NULL, NULL, 0} /* sentinel */ }; =20 -void +DL_EXPORT(void) init_kinds() { PyObject *m, *d; Greetings, Jochen --=20 Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper= .de Libert=E9, =C9galit=E9, Fraternit=E9 GnuPG key: 44BCCD= 8E Sex, drugs and rock-n-roll |
From: Adrian F. <fe...@ma...> - 2001-07-02 21:43:29
|
I'm pleased to announce the new release of Scigraphica with bugfixes and enhancements. Among other things, embedding images is now possible, as well as setting background images for the plots. Clipboard for plots: copy a plot, and paste it on a different plot window. Improved PostScript and WYSIWYG. It includes pysga.py, a Python module for interacting with plots and worksheets from terminal. New scheme for storing numerical data in worksheets. Examples are included. Scigraphica is a powerful tool for scientific graphics and data analysis. It pretends to be a clone of the popular commercial (and expensive) application "Microcal Origin". It fully supplies plotting features for 2D, 3D and polar charts. The aim is to obtain a fully-featured, cross-plattform, user-friendly, self-growing scientific application. It is free and open-source, released under the GPL license. Main features: -You can plot functions and manipulate data in worksheets. -You can open several worksheets and plots and work with them at the same time. -The plots are fully configurable using a control panel dialog. -The look and feel is completely WYSIWYG. -Publication quality PostScript output. -You can interact with the plots double-clicking, dragging and moving objects with the mouse. -Export/Import features in XML format. -You can insert Python expressions in the worksheets. -Terminal with command-line Python interface for interacting with plots and worksheets URL: http://scigraphica.sourceforge.net Enjoy! The SciGraphica Team.- ------------------------------------------------------------------------ TODO for sg-0.8.0: sg-0.8.0 will have a completely different structure, more modular, built ontop of reusable libraries. SGplot, SGworksheet, SGlayer, and SGdataset will be GtkWidgets and part of a shareable library, that could be used by other applications, and from Python. |
From: Adrian F. <fe...@ma...> - 2001-07-02 16:04:00
|
Hi everybody, I'm the author of SciGraphica (http://scigraphica.sourceforge.net), an application for scientific graphics and data analysis that uses Python and Numpy. Among other things, it features spreadheets that can contain Python data, like formulas. The Python stuff was mainly done by Conrad Steenberg, because I don't have much experience, specially embedding Python into C. However, I decided to get started this weekend because we needed badly a GUI for non-linear least squares fits. The result is gtkLeastSquares.py, which is attached below. It's going to be distributed with SG, but it works independently and needs gtk.py and Scientific. Basically it is a gtk GUI for Scientific.Functions.LeastSquares. I'm quite satisfied with the result, considering that I'm a newbie ;-) I'm writting because I'd like to have some feedback, and people interested in contributing. The code is still immature, and needs enhancements, like user defined functions and parameters (either editing the existing in the GUI, or adding new ones interactively). I still have to learn. It is very simple, and easy to use. You'll find the code below, with an example at the bottom of the file. I hope you like it. All comments, and suggestions are very welcome (as well as contributors ;-) Thank you, <ADRIAN> -------------- Cut here ---------------------- # # gtkLeastSquares.py : GUI for the module Scientific.Functions.LeastSquares # Implementation of the Levenberg-Marquardt algorithm for general # non-linear least-squares fits. # # Copyright (C) 2001 Adrian E. Feiguin <fe...@if...> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # from string import * from gtk import * from Numeric import * from Scientific.Functions.LeastSquares import * from Scientific.Functions.FirstDerivatives import * def fit_linear(parameters, values): a, b = parameters x = values return (a + b * x) def fit_cuadratic(parameters, values): a, b, c, x0 = parameters x = values return(a + b * (x - x0) + c * (x - x0)**2) return def fit_gauss(parameters, values): y0, x0, a, w = parameters x = values return(y0 + a * exp(-2*(x-x0)**2/w**2)) return def fit_lorentz(parameters, values): x0, y0, a, b = parameters x = values return(y0 + 2*a/pi * w / (4 * (x - x0)**2 + w**2)) return def fit_boltzman(parameters, values): x0, a1, a2, dx = parameters x = values return((a1 - a2)/(1 + exp((x - x0)/dx)) + a2) def fit_logistic(parameters, values): x0, a1, a2, p = parameters x = values return((a1 - a2)/(1 + (x/x0)**p) + a2) def fit_expdecay(parameters, values): x0, y0, a, t = parameters x = values return(y0 + a * exp(-(x - x0)/t)) def fit_expgrow(parameters, values): x0, y0, a, t = parameters x = values return(y0 + a * exp((x - x0)/t)) def fit_expassoc(parameters, values): y0, a1, t1, a2, t2 = parameters x = values return(y0 + a1 * (1 + exp(-x/t1)) + a2 * (1 + exp(-x/t2))) def fit_hyperbl(parameters, values): p1, p2 = parameters x = values return(p1 * x/ (p2 + x)) def fit_pulse(parameters, values): x0, y0, a, t1, t2 = parameters x = values return(y0 + a * (1 + exp(-(x - x0)/t1)) * exp(-(x - x0)/t2)) def fit_rational0(parameters, values): a, b, c = parameters x = values return((b + c*x)/(1 + a*x)) def fit_sine(parameters, values): x0, a, w = parameters x = values return(a * sin(pi*(x - x0)/w)) def fit_gaussamp(parameters, values): x0, y0, a, w = parameters x = values return(y0 + a * exp(-(x - x0)**2/(2*w**2))) def fit_allometric(parameters, values): a, b = parameters x = values return(a * x**b) fit_linear_dic = { "Doc" : "Linear Function", "Exp" : "y = a + b * x", "Par" : ("a", "b"), "NumPar" : 2, "IVar" : "x", "DVar" : "y", "Function" : fit_linear } fit_cuadratic_dic = { "Doc" : "Cuadratic Function", "Exp" : "y = a + b * (x - x0) + c * (x - x0)**2", "Par" : ("a", "b", "c", "x0"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_cuadratic } fit_gauss_dic = { "Doc" : "Amplitude version of Gaussian Function", "Exp" : "y = y0 + a * exp(-2*(x-x0)**2/w**2)", "Par" : ("x0", "y0", "a", "w"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_gauss } fit_lorentz_dic = { "Doc" : "Lorentzian Peak Function", "Exp" : "y = y0 + 2*a/pi * w / (4 * (x - x0)**2 + w**2)", "Par" : ("x0", "y0", "a", "w"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_lorentz } fit_boltzman_dic = { "Doc" : "Boltzman Function: sigmoidal curve", "Exp" : "y = (a1 - a2)/(1 + exp((x - x0)/dx)) + a2", "Par" : ("x0", "a1", "a2", "dx"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_boltzman } fit_logistic_dic = { "Doc" : "Logistic dose/response", "Exp" : "y = (a1 - a2)/(1 + (x/x0)**p) + a2", "Par" : ("x0", "a1", "a2", "p"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_logistic } fit_expdecay_dic = { "Doc" : "Exponential Decay", "Exp" : "y = y0 + a * exp(-(x - x0)/t)", "Par" : ("x0", "y0", "a", "t"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_expdecay } fit_expgrow_dic = { "Doc" : "Exponential Growth", "Exp" : "y = y0 + a * exp((x - x0)/t)", "Par" : ("x0", "y0", "a", "t"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_expgrow } fit_expassoc_dic = { "Doc" : "Exponential Associate", "Exp" : "y = y0 + a1 * (1 + exp(-x/t1)) + a2 * (1 + exp(-x/t2))", "Par" : ("y0", "a1", "t1", "a2", "t2"), "NumPar" : 5, "IVar" : "x", "DVar" : "y", "Function" : fit_expassoc } fit_hyperbl_dic = { "Doc" : "Hyperbola Function", "Exp" : "y = p1 * x/ (p2 + x)", "Par" : ("p1", "p2"), "NumPar" : 2, "IVar" : "x", "DVar" : "y", "Function" : fit_hyperbl } fit_pulse_dic = { "Doc" : "Pulse Function", "Exp" : "y = y0 + a * (1 + exp(-(x - x0)/t1)) * exp(-(x - x0)/t2)", "Par" : ("y0", "a", "t1", "t2"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_pulse } fit_rational0_dic = { "Doc" : "Rational Function , type 0", "Exp" : "y = (b + c*x)/(1 + a*x)", "Par" : ("a", "b", "c"), "NumPar" : 3, "IVar" : "x", "DVar" : "y", "Function" : fit_rational0 } fit_sine_dic = { "Doc" : "Sine Function", "Exp" : "y = a * sin(pi*(x - x0)/w)", "Par" : ("a", "x0", "w"), "NumPar" : 3, "IVar" : "x", "DVar" : "y", "Function" : fit_sine } fit_gaussamp_dic = { "Doc" : "Amplitude version of Gaussian Peak Function", "Exp" : "y = y0 + a * exp(-(x - x0)**2/(2*w**2))", "Par" : ("x0", "y0", "a", "w"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_gaussamp } fit_allometric_dic = { "Doc" : "Classical Freundlich Model", "Exp" : "y = a * x**b", "Par" : ("a", "b"), "NumPar" : 4, "IVar" : "x", "DVar" : "y", "Function" : fit_allometric } functions = { "Linear" : fit_linear_dic, "Cuadratic" : fit_cuadratic_dic, "Gauss" : fit_gauss_dic, "Lorentz" : fit_lorentz_dic, "Boltzman" : fit_boltzman_dic, "Logistic" : fit_logistic_dic, "ExpDecay" : fit_expdecay_dic, "ExpGrow" : fit_expgrow_dic, "ExpAssoc" : fit_expassoc_dic, "Hyperbl" : fit_hyperbl_dic, "Pulse" : fit_pulse_dic, "Rational0" : fit_rational0_dic, "Sine" : fit_sine_dic, "GaussAmp" : fit_gaussamp_dic, "Allometric" : fit_allometric_dic } def fit(data): main_window = GtkWindow() main_window.set_title("Curve Fitting") main_window.set_border_width(5) main_window.connect("destroy", mainquit) main_window.connect("delete_event", mainquit) main_box = GtkVBox(FALSE, 5) main_window.add(main_box) main_frame = GtkFrame("Select Function") main_box.pack_start(main_frame) table = GtkTable(7, 4, FALSE) table.set_col_spacings(10) table.set_row_spacings(5) table.set_border_width(5) main_frame.add(table) swindow = GtkScrolledWindow() swindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) swindow.set_usize(120, 100) table.attach(swindow, 0, 1, 0, 6) clist = GtkCList(1) swindow.add(clist) table.attach(GtkVSeparator(), 1, 2, 0, 6) text = map(lambda i: str(i), range(20)) k = functions.keys() k.sort() for i in k: text[0] = i clist.append(text) label = GtkLabel("Exp:") label.set_alignment(1., .5) table.attach(label, 2, 3, 0, 1) fentry = GtkEntry() # fentry.set_editable(FALSE) table.attach(fentry, 3, 4, 0, 1) label = GtkLabel("Number of Param:") label.set_alignment(1., .5) table.attach(label, 2, 3, 1, 2) nspin = GtkSpinButton(GtkAdjustment(0, 0, 8, 1, 8, 0), 0, 0) nspin.set_editable(FALSE) nspin.set_state(STATE_INSENSITIVE) table.attach(nspin, 3, 4, 1, 2) label = GtkLabel("Param:") label.set_alignment(1., .5) table.attach(label, 2, 3, 2, 3) pentry = GtkEntry() pentry.set_editable(FALSE) pentry.set_state(STATE_INSENSITIVE) table.attach(pentry, 3, 4, 2, 3) label = GtkLabel("Independent Var:") label.set_alignment(1., .5) table.attach(label, 2, 3, 3, 4) iventry = GtkEntry() iventry.set_editable(FALSE) iventry.set_state(STATE_INSENSITIVE) table.attach(iventry, 3, 4, 3, 4) label = GtkLabel("Dependent Var:") label.set_alignment(1., .5) table.attach(label, 2, 3, 4, 5) dventry = GtkEntry() dventry.set_editable(FALSE) dventry.set_state(STATE_INSENSITIVE) table.attach(dventry, 3, 4, 4, 5) action_area = GtkHButtonBox() action_area.set_layout(BUTTONBOX_END) action_area.set_spacing(5) main_box.pack_start(action_area) fit_button = GtkButton("Fit") action_area.pack_start(fit_button) close_button = GtkButton("Close") action_area.pack_start(close_button) lframe = GtkFrame() lframe.set_shadow_type(SHADOW_IN) main_box.pack_start(lframe) explabel = GtkLabel("Choose a Fitting Function") lframe.add(explabel) # CALLBACK FUNCTIONS def select_function(_clist, row, col, event, functions = functions, label = explabel, fentry = fentry, pentry = pentry, nspin = nspin, iventry = iventry, dventry = dventry): k = _clist.get_text(row, col) f = functions[k] label.set_text(f["Doc"]) fentry.set_text(f["Exp"]) nspin.set_value(f["NumPar"]) iventry.set_text(f["IVar"]) dventry.set_text(f["DVar"]) s = "" for i in f["Par"]: s = s + i + ", " pentry.set_text(s[:len(s)-2]) def open_fit_dialog(_button, functions = functions, clist = clist, data = data): a = clist.__getattr__("selection") k = clist.get_text(a[0], 0) f = functions[k] param = (1, 1) fit_dialog(f, data) # CONNECT OBJECTS clist.connect("select_row", select_function) fit_button.connect("clicked", open_fit_dialog) close_button.connect("clicked", main_window.destroy) clist.select_row(0, 0) main_window.show_all() mainloop() def fit_dialog(f, data): main_window = GtkWindow() main_window.set_title("Fit") main_window.set_border_width(5) main_window.connect("destroy", mainquit) main_window.connect("delete_event", mainquit) table = GtkTable(len(f["Par"])+3, 2, FALSE) table.set_col_spacings(10) table.set_row_spacings(5) main_window.add(table) table.attach(GtkLabel("Variable"), 0, 1, 0, 1) table.attach(GtkLabel("Value"), 1, 2, 0, 1) table.attach(GtkHSeparator(), 0, 2, 1, 2) r = 2 entries = [] for i in f["Par"]: # check = GtkCheckButton(i+":") # table.attach(check, 0, 1, r, r+1) table.attach(GtkLabel(i+":"), 0, 1, r, r+1) entry = GtkEntry() entries = entries + [entry] entry.set_text("0.0") table.attach(entry, 1, 2, r, r+1) r = r + 1 table.attach(GtkHSeparator(), 0, 2, r, r + 1) r = r + 1 table.attach(GtkLabel("Chi_Sqr:"), 0, 1, r, r + 1) err_entry = GtkEntry() table.attach(err_entry, 1, 2, r, r + 1) r = r + 1 table.attach(GtkHSeparator(), 0, 2, r, r + 1) def run_fit(_button, f = f, data = data, entries = entries, err_entry = err_entry): n = 0 p = () for i in entries: s = entries[n].get_text() p = p + (atof(s),) n = n + 1 fit, error = leastSquaresFit(f["Function"], p, data) n = 0 for i in entries: entries[n].set_text(str(fit[n])) n = n + 1 err_entry.set_text(str(error)) # print "Fitted parameters: ", fit # print "Fit error: ", error return action_area = GtkHButtonBox() action_area.set_layout(BUTTONBOX_SPREAD) action_area.set_spacing(5) run_button = GtkButton("Run") close_button = GtkButton("Close") action_area.pack_start(run_button) action_area.pack_start(close_button) table.attach(action_area, 0, 2, r + 1, r + 2) # CONNECT OBJECTS run_button.connect("clicked", run_fit) close_button.connect("clicked", main_window.destroy) main_window.show_all() mainloop() # Test for linear fit: # # from gtkLeastSquares import * # data = [ (0., 0.), (1., 1.1), (2., 1.98), (3., 3.05) ] # fit(data) |
From: <co...@ph...> - 2001-07-02 02:38:46
|
At some point, Juerg Tschirren <jue...@ui...> wrote: > I did some experimenting with the NumPy C API. I wrote two functions. > One for processing a NumPy array in C++ and the other one for > generating a NumPy array in C++. The processing function work perfectly > fine. But in the array-generating function I get a segmentation fault > whenever I call PyArray_FromDims. I used swig for generating the wrapper > functions. > > The two src-files (numPyExt.i and numPyExt.cc): [code snipped] > Compiled with: > g++ -c -I/usr/local/include/python2.0 -I/usr/local/lib/python2.0/site-packages -O2 numPyExt.cc > swig -python -c++ numPyExt.i > g++ -c -O2 numPyExt_wrap.c -DOS_LINUX -DHAVE_CONFIG_H -I. -I/usr/local/include/python2.0 -I/usr/local/lib/python2.0/site-packages -I/usr/local/lib/python2.0/config > g++ -W1,--heap,50000,--stack,100000 -O2 -shared numPyExt.o numPyExt_wrap.o -lstdc++ -o numPyExt.so > This problem was discussed in April on this list, see http://www.geocrawler.com/mail/thread.php3?subject=%5BNumpy-discussion%5D+Numeric+on+OS+X+-+Anyone+get+it+to+work+%3F&list=1329 I banged my head against this for hours a few weeks ago until I found the above. The problem is that PyArray_FromDims (and all other PyArray_*) are not functions -- they're macros, defined like this: #define PyArray_FromDims \ (*(PyArray_FromDims_RET (*)PyArray_FromDims_PROTO) \ PyArray_API[PyArray_FromDims_NUM]) This means that all the PyArray_* functions are done through a lookup table PyArray_API, which is initialized by import_array(). By default, PyArray_API is defined in arrayobject.h as 'static void **PyArray_API', meaning that it is not accessible outside of the translation unit (i.e. file) that includes it. The relevant part of Numeric/arrayobject.h is this: #if defined(PY_ARRAY_UNIQUE_SYMBOL) #define PyArray_API PY_ARRAY_UNIQUE_SYMBOL #endif /* C API address pointer */ #if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY) extern void **PyArray_API; #else #if defined(PY_ARRAY_UNIQUE_SYMBOL) void **PyArray_API; #else static void **PyArray_API; #endif #endif So, one way to get the behaviour you want is 1) in the file where import_array is called, #define PY_ARRAY_UNIQUE_SYMBOL to be something like Py_Array_API_myext. (Make it unique because it will be exported as part of the .so file.) before including Numeric/arrayobject.h 2) in the other files, #define NO_IMPORT_ARRAY before including Numeric/arrayobject.h Another way is to have your main file (say, main.c) call functions in the other files, passing the value of PyArray_API defined there, so that the other files can set theirs to that value. Hope this helps. -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke |co...@ph... |
From: Juerg T. <jue...@ui...> - 2001-07-01 20:18:40
|
I did some experimenting with the NumPy C API. I wrote two functions. One for processing a NumPy array in C++ and the other one for generating a NumPy array in C++. The processing function work perfectly fine. But in the array-generating function I get a segmentation fault whenever I call PyArray_FromDims. I used swig for generating the wrapper functions. The two src-files (numPyExt.i and numPyExt.cc): --- begin numPyExt.i ------------------------------------------------- %module numPyExt %{ #include <iostream.h> #include <Python.h> #include <Numeric/arrayobject.h> %} %init %{ import_array(); %} %typemap(python,in) double * { PyArrayObject *py_arr; if(!PyArray_Check($source)) { PyErr_SetString(PyExc_TypeError, "Not a NumPy array"); return NULL; } if (PyArray_ObjectType($source,0) != PyArray_DOUBLE) { PyErr_SetString(PyExc_ValueError, "Array must be of type double"); return NULL; } py_arr = (PyArrayObject*) \ (PyArray_ContiguousFromObject($source, PyArray_DOUBLE, 1, 1)); if (py_arr->nd != 1) { PyErr_SetString(PyExc_TypeError, "Array must be 1D"); return NULL; } $target = (double*)(py_arr->data); } extern PyObject* createArray(); extern void processArray(double* pdInArray); --- end numPyExt.i --------------------------------------------------- --- begin numPyExt.cc ------------------------------------------------ #include <iostream.h> #include <Python.h> #include <Numeric/arrayobject.h> //------ PyObject* createArray() { PyArrayObject* retArray; int iDimensions[3] = {10, 10, 10}; cout << "before PyArray_FromDims" << endl << flush; retArray = (PyArrayObject*)PyArray_FromDims(3, iDimensions, PyArray_INT); cout << "after PyArray_FromDims" << endl << flush; return PyArray_Return(retArray); } //------ void processArray(double* pdInArray) { cout << *pdInArray << " " << *(pdInArray+1) << " " << *(pdInArray+2) << endl; } --- end numPyExt.cc -------------------------------------------------- Compiled with: g++ -c -I/usr/local/include/python2.0 -I/usr/local/lib/python2.0/site-packages -O2 numPyExt.cc swig -python -c++ numPyExt.i g++ -c -O2 numPyExt_wrap.c -DOS_LINUX -DHAVE_CONFIG_H -I. -I/usr/local/include/python2.0 -I/usr/local/lib/python2.0/site-packages -I/usr/local/lib/python2.0/config g++ -W1,--heap,50000,--stack,100000 -O2 -shared numPyExt.o numPyExt_wrap.o -lstdc++ -o numPyExt.so The Python test code I am using: import Numeric, numPyExt vec = Numeric.array((1.23, 4.56, 7.89)) numPyExt.processArray(vec) # works fine a = numPyExt.createArray() # seg fault here print a I am using NumPy v20.0.0, Python 2.1, and gcc 2.95.2 on a Linux 2.2.16 sytem. Does anybody have an idea what's causing this problem? Juerg |
From: Joe V. A. <van...@at...> - 2001-06-28 22:41:40
|
I retrieved the latest MA from CVS. I've noticed that assigning to a slice doesn't work the same as Numeric. Here's a simple test program: -------------------------------- from MA import * #from Numeric import * numBeams,numGates = (5,4) result = ones((numBeams, numGates),'f') * -327.68 print 'result = ', result t1 = ones((numGates,),'f') t2 = 2* ones((numGates,),'f') result[0] = t1 result[1][:] = t2 print 'result = ', result ----------------------------------------- Output using 'MA': result = [[-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,]] result = [[ 1. , 1. , 1. , 1. ,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,] [-327.68,-327.68,-327.68,-327.68,]] However, if I use Numeric, rather than MA, I get: result = [[-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68]] result = [[ 1. 1. 1. 1. ] [ 2. 2. 2. 2. ] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68] [-327.68 -327.68 -327.68 -327.68]] So, a[x][:] = my_array doesn't seem to work using 'MA'. -- Joe VanAndel National Center for Atmospheric Research http://www.atd.ucar.edu/~vanandel/ Internet: van...@uc... |
From: Chris B. <chr...@ho...> - 2001-06-19 18:55:56
|
I just took a look at the release notes for version 20 at: http://sourceforge.net/project/shownotes.php?release_id=31875 And it says: Release Name: 20 Notes: Requires Python 2.0 Shouldn't that be 2.1? or 2.0 or greater? -Chris -- Christopher Barker, Ph.D. Chr...@ho... --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ |
From: Tim H. <tim...@ie...> - 2001-06-19 18:29:34
|
Chris Barker writes: [He doesn't get a slowdown with Numeric 20.0.0 on Linux] > So whatever it was may have been fixed (or be a strange platform > dependence). [SNIP] It must just be the cleverness of your platform's qsort. Numeric delegates sorting to qsort and running qsort on Windows 2000 with Numeric 20.0.0 I get similar values to Bethold's. Also some rather naive calculations for the complexity of quicksort on a list of n items with k distinct values gives me O((log(n/k) + (n/k)) * n). That's probably not exactly right, but it matches the timings I get pretty well. -tim |