From: Anderl <And...@dl...> - 2000-11-20 17:11:50
|
Hello, I'm quite new to numpy, trying to migrate from IDL. I'm not able to find any 'shift' function in numpy, i.e. a function that shifts the content of an array by a certain number of elements. a = [1,2,3,4,5,6] shift(a,2) = [3,4,5,6,1,2] In IDL this works even on multidemiensional arrays, b=shift(a,4,7,5) shifts by 4 in the first, 7 in the second and 5 in the third component. Is there some similar module existing? Thanks & best regards, Andreas ------------------------------------------------------------------- Andreas Reigber Institut fuer Hochfrequenztechnik DLR - Oberpfaffenhofen Tel. : ++49-8153-282367 Postfach 1116 eMail: And...@dl... D-82230 Wessling ------------------------------------------------------------------- |
From: <sz...@ru...> - 2000-11-30 18:09:14
|
> I had another look at the definition of \"ones\" and of another routine > > I frequently use: arange. It appears that even without rewriting them > > in C, some speedup can be achieved: > > > > - in ones(), the + 1 should be done \"in place\", saving about 15%, more > > if you run out of processor cache: > > I\'d also try assignment in place: > > def ones(shape, typecode=\'l\', savespace=0): > a = zeros(shape, typecode, savespace) > a[len(shape)*[slice(0, None)]] = 1 > return a > > Konrad. Is the following definition faster or not? def ones(shape, typecode=\'l\', savespace=0): a = zeros( (product(shape),), typecode, savespace) a[:] = 1 a.shape = shape return a Zaur |
From: <ro...@ho...> - 2000-12-01 07:15:06
|
>>>>> "s" == szport <sz...@ru...> writes: s> Is the following definition faster or not? s> def ones(shape, typecode=\'l\', savespace=0): s> a = zeros( (product(shape),), typecode, savespace) s> a[:] = 1 s> a.shape = shape s> return a This is yet another way to write a[...]=1 manually via a small detour. For small arrays (size 10...1000) it is about twice slower than writing [...] (0.1ms slower per call on my workstation). Rob -- ===== ro...@ho... http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= |
From: Leonardo S. <re...@te...> - 2002-09-27 17:16:05
|
confirm 498554 |
From: kevin l. <lke...@ya...> - 2004-11-27 02:19:23
|
Hi Alan, Yes, thank you. Shared elements is the out come I need. The problem I have now is how to return the shared elements back into the numarray.array([]) constructor. Numarray doesn't recognize the sets.Set([]) constructor as a python numeric type. I actually don't see any functionality/methodology to convert a sets.Set([]) back into any of the sequence types. I am also don't understand why this ability, to retrieve shared elements of two unequal arrays, is not an inherent numarry function/method. Thank you for your initial direction to the sets module, Kevin __________________________________ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com |
From: Alan G I. <ai...@am...> - 2004-11-27 12:30:04
|
On Fri, 26 Nov 2004, kevin lester apparently wrote: > I actually don't > see any functionality/methodology to convert a > sets.Set([]) back into any of the sequence types. a=list(a) a=array(a) hth, Alan |
From: <Fer...@eu...> - 2006-07-05 12:53:02
|
Hi, how could i get the name of an array in a string ? (info command ?!) thanks f.= |
From: Robert K. <rob...@gm...> - 2006-07-05 15:54:10
|
Fer...@eu... wrote: > > Hi, > > how could i get the name of an array in a string ? > (info command ?!) You can't. http://mail.python.org/pipermail/python-list/2005-June/286574.html -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: ferenc p. <fer...@st...> - 2006-07-05 15:11:12
|
Hi, how could i get the name of an array in a string ? thanks f. |
From: Alexandre F. <ale...@lo...> - 2006-07-05 15:49:35
|
On Wed, Jul 05, 2006 at 02:51:36PM +0200, ferenc pintye wrote: > Hi, >=20 > how could i get the name of an array in a string ? if by this you mean "the name of an identifier refering to [whatever]", this is a FAQ, and the answer is 1. you don't want to do that 2. your problem is not well behaved (there can be many answers to the questions) 3. you can use something along the lines of for name, item in locals().iteritems(): if item is my_array: break else: name =3D "anonymous object" --=20 Alexandre Fayolle LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations D=E9veloppement logiciel sur mesure: http://www.logilab.fr/services Informatique scientifique: http://www.logilab.fr/science |
From: <kor...@id...> - 2006-08-24 20:10:41
|
>On Thursday 24 August 2006 09:50, kor...@id... wrote: >> Sorry for my ignorance, but I have not ever heard of or used mingw32. I >> am also using python 2.3. >http://en.wikipedia.org/wiki/Mingw explains in detail. >> >> Is there any way someone could possibly send me a brief walk through of >> how to install 1.0b3 on windows32? >do you know about the ("awesome" wiki website at scipy.org) >try your luck at >http://www.scipy.org/Build_for_Windows >> >> Also I am not sure that I know how to manipulate the code that you guys >> said that you have to so that it will work so if that is needed could you >> post a walk through of that also? >> >To my knowledge there is no need to "manipulate code" .... >Maybe you should try getting per-build versions first. >Sebastian Haase Thank you for all of that. I followed the directions carefully. created a numpy folder, checked out the svn via http://svn.scipy.org/svn/numpy/trunk changed to the numpy directory and typed python setup.py config --compiler=mingw32 build --compiler=mingw32 install and then reinstalled sci py because it says to install sci py after numpy. And then I recieved this after trying to run my program. Any Ideas anyone? $HOME=C:\Documents and Settings\Administrator CONFIGDIR=C:\Documents and Settings\Administrator\.matplotlib loaded ttfcache file C:\Documents and Settings\Administrator\.matplotlib\ttffont .cache matplotlib data path c:\python23\lib\site-packages\matplotlib\mpl-data backend WXAgg version 2.6.3.2 Overwriting info=<function info at 0x01FAF3F0> from scipy.misc.helpmod (was <fun ction info at 0x01F896F0> from numpy.lib.utils) Overwriting who=<function who at 0x01FA46B0> from scipy.misc.common (was <functi on who at 0x01F895F0> from numpy.lib.utils) Overwriting source=<function source at 0x01FB2530> from scipy.misc.helpmod (was <function source at 0x01F89730> from numpy.lib.utils) RuntimeError: module compiled against version 1000000 of C-API but this version of numpy is 1000002 Fatal Python error: numpy.core.multiarray failed to import... exiting. abnormal program termination |
From: Travis O. <oli...@ee...> - 2006-08-24 20:17:46
|
kor...@id... wrote: >>On Thursday 24 August 2006 09:50, kor...@id... wrote: >> >> >>>Sorry for my ignorance, but I have not ever heard of or used mingw32. I >>>am also using python 2.3. >>> >>> >>http://en.wikipedia.org/wiki/Mingw explains in detail. >> >> > >$HOME=C:\Documents and Settings\Administrator >CONFIGDIR=C:\Documents and Settings\Administrator\.matplotlib >loaded ttfcache file C:\Documents and >Settings\Administrator\.matplotlib\ttffont >.cache >matplotlib data path c:\python23\lib\site-packages\matplotlib\mpl-data >backend WXAgg version 2.6.3.2 >Overwriting info=<function info at 0x01FAF3F0> from scipy.misc.helpmod >(was <fun >ction info at 0x01F896F0> from numpy.lib.utils) >Overwriting who=<function who at 0x01FA46B0> from scipy.misc.common (was ><functi >on who at 0x01F895F0> from numpy.lib.utils) >Overwriting source=<function source at 0x01FB2530> from scipy.misc.helpmod >(was ><function source at 0x01F89730> from numpy.lib.utils) >RuntimeError: module compiled against version 1000000 of C-API but this >version >of numpy is 1000002 >Fatal Python error: numpy.core.multiarray failed to import... exiting. > > >abnormal program termination > > You have a module built against an older version of NumPy. What modules are being loaded? Perhaps it is matplotlib or SciPy -Travis |
From: Thilo W. <thi...@gm...> - 2006-08-30 21:14:30
|
Hi, currently I´m trying to compile the latest numpy version (1.0b4) under an SGI IRIX 6.5 environment. I´m using the gcc 3.4.6 compiler and python 2.4.3 (self compiled). During the compilation of numpy.core I get a nasty error message: ... copying build/src.irix64-6.5-2.4/numpy/__config__.py -> build/lib.irix64-6.5-2.4/numpy copying build/src.irix64-6.5-2.4/numpy/distutils/__config__.py -> build/lib.irix64-6.5-2.4/numpy/distutils running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext customize MipsFCompiler customize MipsFCompiler customize MipsFCompiler using build_ext building 'numpy.core.umath' extension compiling C sources C compiler: gcc -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64 -DHAVE_LARGEFILE_SUPPORT -fmessage-length=0 -Wall -O2 compile options: '-Ibuild/src.irix64-6.5-2.4/numpy/core/src -Inumpy/core/include -Ibuild/src.irix64-6.5-2.4/numpy/core -Inumpy/core/src -Inumpy/core/include -I/usr/local/include/python2.4 -c' gcc: build/src.irix64-6.5-2.4/numpy/core/src/umathmodule.c numpy/core/src/umathmodule.c.src: In function `nc_sqrtf': numpy/core/src/umathmodule.c.src:602: warning: implicit declaration of function `hypotf' numpy/core/src/umathmodule.c.src: In function `nc_sqrtl': numpy/core/src/umathmodule.c.src:602: warning: implicit declaration of function `fabsl' ... ... lots of math functions ... ... numpy/core/src/umathmodule.c.src: In function `LONGDOUBLE_frexp': numpy/core/src/umathmodule.c.src:1940: warning: implicit declaration of function `frexpl' numpy/core/src/umathmodule.c.src: In function `LONGDOUBLE_ldexp': numpy/core/src/umathmodule.c.src:1957: warning: implicit declaration of function `ldexpl' In file included from numpy/core/src/umathmodule.c.src:2011: build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c: At top level: build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:15: error: `acosl' undeclared here (not in a function) build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:15: error: initializer element is not constant build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:15: error: (near initialization for `arccos_data[2]') ... ... lots of math functions ... ... build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:192: error: initializer element is not constant build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:192: error: (near initialization for `tanh_data[2]') numpy/core/include/numpy/ufuncobject.h:328: warning: 'generate_overflow_error' defined but not used numpy/core/src/umathmodule.c.src: In function `nc_sqrtf': numpy/core/src/umathmodule.c.src:602: warning: implicit declaration of function `hypotf' ... ... lots of math functions ... ... numpy/core/src/umathmodule.c.src: In function `FLOAT_frexp': numpy/core/src/umathmodule.c.src:1940: warning: implicit declaration of function `frexpf' numpy/core/src/umathmodule.c.src: In function `FLOAT_ldexp': numpy/core/src/umathmodule.c.src:1957: warning: implicit declaration of function `ldexpf' numpy/core/src/umathmodule.c.src: In function `LONGDOUBLE_frexp': numpy/core/src/umathmodule.c.src:1940: warning: implicit declaration of function `frexpl' numpy/core/src/umathmodule.c.src: In function `LONGDOUBLE_ldexp': numpy/core/src/umathmodule.c.src:1957: warning: implicit declaration of function `ldexpl' In file included from numpy/core/src/umathmodule.c.src:2011: build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c: At top level: build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:15: error: `acosl' undeclared here (not in a function) build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:15: error: initializer element is not constant ... ... lots of math functions ... ... build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:192: error: initializer element is not constant build/src.irix64-6.5-2.4/numpy/core/__umath_generated.c:192: error: (near initialization for `tanh_data[2]') numpy/core/include/numpy/ufuncobject.h:328: warning: 'generate_overflow_error' defined but not used error: Command "gcc -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64 -DHAVE_LARGEFILE_SUPPORT -fmessage-length=0 -Wall -O2 -Ibuild/src.irix64-6.5-2.4/numpy/core/src -Inumpy/core/include -Ibuild/src.irix64-6.5-2.4/numpy/core -Inumpy/core/src -Inumpy/core/include -I/usr/local/include/python2.4 -c build/src.irix64-6.5-2.4/numpy/core/src/umathmodule.c -o build/temp.irix64-6.5-2.4/build/src.irix64-6.5-2.4/numpy/core/src/umathmodule.o" failed with exit status 1 Can somebody explain me, what´s going wrong. It seems there is some header files missing. thanks, thilo -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer |
From: Bill S. <wf...@sa...> - 2006-09-03 04:48:18
|
I think I see a bug in lib.user_array.container class. The __eq__ method is def __eq__(self,other): return self._rc(equal(self.array,other)) the expression equal(self.array,other) will return an ndarray of bools, which is then converted, by way of self._rc(), to whatever the derived class is. In my case, this does not make sense, because an array of bools is not a valid argument to the constructor (actually, the data buffer is accepted, but the results are not reliable). What I want, and it seem most people would want in this situation, is just the array of bools; i.e. don't apply the self._rc() method. Assuming there is agreement that this is the desirable behavior, the same would be true for __lt__, __le__, etc. I will probably override this behavior by defining my own __eq__, etc., in my derived class, just for safety. ** Bill Spotz ** ** Sandia National Laboratories Voice: (505)845-0170 ** ** P.O. Box 5800 Fax: (505)284-5451 ** ** Albuquerque, NM 87185-0370 Email: wf...@sa... ** |
From: Robert K. <rob...@gm...> - 2006-09-03 05:11:11
|
Bill Spotz wrote: > I think I see a bug in lib.user_array.container class. The __eq__ > method is > > def __eq__(self,other): return self._rc(equal(self.array,other)) > > the expression equal(self.array,other) will return an ndarray of > bools, which is then converted, by way of self._rc(), to whatever the > derived class is. In my case, this does not make sense, because an > array of bools is not a valid argument to the constructor (actually, > the data buffer is accepted, but the results are not reliable). What > I want, and it seem most people would want in this situation, is just > the array of bools; i.e. don't apply the self._rc() method. No, it's not a bug. It's just the design of that class: always return the same class of object. Of course, since that class only exists to be subclassed, if you need different behavior from those methods, override them. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: <kor...@id...> - 2006-09-05 18:04:17
|
Hey guys I posted this on matplotlibs mailing list > hey guys i got the subversion from the site and I am trying to install it > on windows. > > I changed dir into the matplotlib dir that includes the setup.py file. > > run python setup.py install, and im getting a wierd error. i left the > topmost lines along with the error. has anyone seen anything like this > before? > > building 'matplotlib.enthought.traits.ctraits' extension > creating build\temp.win32-2.4\Release\lib > creating build\temp.win32-2.4\Release\lib\matplotlib > creating build\temp.win32-2.4\Release\lib\matplotlib\enthought > creating build\temp.win32-2.4\Release\lib\matplotlib\enthought\traits > C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c > /nologo /Ox > /MD /W3 /GX /DNDEBUG -Ic:\Python24\include -Ic:\Python24\PC > /Tclib/matplotlib/e > nthought/traits/ctraits.c > /Fobuild\temp.win32-2.4\Release\lib/matplotlib/enthoug > ht/traits/ctraits.obj > C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL > /nologo > /INCREMENTAL:NO /LIBPATH:c:\Python24\libs /LIBPATH:c:\Python24\PCBuild > /EXPORT: > initctraits > build\temp.win32-2.4\Release\lib/matplotlib/enthought/traits/ctraits > .obj /OUT:build\lib.win32-2.4\matplotlib\enthought\traits\ctraits.pyd > /IMPLIB:bu > ild\temp.win32-2.4\Release\lib/matplotlib/enthought/traits\ctraits.lib > building 'matplotlib.backends._tkagg' extension > C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c > /nologo /Ox > /MD /W3 /GX /DNDEBUG -Iwin32_static/include/tcl84 -I. -Isrc -Iswig > -Iagg23/incl > ude -I. -I. -Iwin32_static/include/tcl84\freetype2 -I.\freetype2 > -Isrc\freetype2 > -Iswig\freetype2 -Iagg23/include\freetype2 -I.\freetype2 -I.\freetype2 > -Ic:\Pyt > hon24\include -Ic:\Python24\PC /Tpsrc/_tkagg.cpp > /Fobuild\temp.win32-2.4\Release > \src/_tkagg.obj > _tkagg.cpp > src\_tkagg.cpp(28) : fatal error C1083: Cannot open include file: 'tk.h': > No suc > h file or directory > error: Command ""C:\Program Files\Microsoft Visual Studio .NET > 2003\Vc7\bin\cl.e > xe" /c /nologo /Ox /MD /W3 /GX /DNDEBUG -Iwin32_static/include/tcl84 -I. > -Isrc - > Iswig -Iagg23/include -I. -I. -Iwin32_static/include/tcl84\freetype2 > -I.\freetyp > e2 -Isrc\freetype2 -Iswig\freetype2 -Iagg23/include\freetype2 > -I.\freetype2 -I.\ > freetype2 -Ic:\Python24\include -Ic:\Python24\PC /Tpsrc/_tkagg.cpp > /Fobuild\temp > .win32-2.4\Release\src/_tkagg.obj" failed with exit status 2 and recieved this response > > You need to install the tcl/tk headers as Darren mentioned. I just > install ActiveTcl and the build should pick up on it no problem. > And then after that I ran into another error that looks like it might be numpy related. So i am posting this here and on Matplotlibs list. The second error is why i am posting here but since some of you use the latest SVN on windows maybe you could offer more general help of how to compile matplotlib on windows I went ahead and installed Active Tcl I removed microsft visual studio 2003 .net from my computer because I never used it, and I did not want it on here in the first place but i had it on here from being an intern over the summer. C:\matplotlib\trunk\matplotlib>c:\Python24\python.exe setup.py install GTK requires pygtk building tkagg 2 4 Building for python24 GTKAgg requires pygtk running install running build running build_py running build_ext No module named msvccompiler in numpy.distutils, trying from distutils.. building 'matplotlib.backends._tkagg' extension C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -Iwin32_static/include/tcl84 -I. -Isrc -Iswig -Iagg23/incl ude -I. -I. -Iwin32_static/include/tcl84\freetype2 -I.\freetype2 -Isrc\freetype2 -Iswig\freetype2 -Iagg23/include\freetype2 -I.\freetype2 -I.\freetype2 -Ic:\Pyt hon24\include -Ic:\Python24\PC /Tpsrc/_tkagg.cpp /Fobuild\temp.win32-2.4\Release \src/_tkagg.obj _tkagg.cpp src\_tkagg.cpp(28) : fatal error C1083: Cannot open include file: 'tk.h': No suc h file or directory error: Command ""C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.e xe" /c /nologo /Ox /MD /W3 /GX /DNDEBUG -Iwin32_static/include/tcl84 -I. -Isrc - Iswig -Iagg23/include -I. -I. -Iwin32_static/include/tcl84\freetype2 -I.\freetyp e2 -Isrc\freetype2 -Iswig\freetype2 -Iagg23/include\freetype2 -I.\freetype2 -I.\ freetype2 -Ic:\Python24\include -Ic:\Python24\PC /Tpsrc/_tkagg.cpp /Fobuild\temp .win32-2.4\Release\src/_tkagg.obj" failed with exit status 2 This is the error i got after my first try at python setup.py install after it did not work is when i uninstalled .net 2003. and i recieve this error currently. C:\matplotlib\trunk\matplotlib>c:\Python24\python.exe setup.py install GTK requires pygtk building tkagg 2 4 Building for python24 GTKAgg requires pygtk running install running build running build_py running build_ext No module named msvccompiler in numpy.distutils, trying from distutils.. error: The .NET Framework SDK needs to be installed before building extensions f or Python. Has anyone seen this one? I would not be so persistent as to trying to install the current SVN except that I need one of the algorithms in numpy version 1.0b2 and above. I am also going to post this on the numpy mailing list because it says the error is in numpy.distutils. |