rn', 'over': 'warn', 'under':
'ignore'}
numpy.divide(1.0,0.0)
Out[1]: inf
numpy.divide(0.0,0.0)
Out[1]: nan
I could not find information on Google: is this a known problem? Is there
a way to suppress this warning?
I'm working on a 64b Win7 m
On Fri, Sep 19, 2008 at 2:50 PM, Arnar Flatberg <[EMAIL PROTECTED]>wrote:
>
>
> I think
> [x*y for x in a for y in b]
> feels pythonic, however it has a surprisingly lousy performance.
>
>
This returns a len(x)*len(y) long list, which is not what you want.
This two methods seem equivalent:
In [1
you can use the 'converters' keyword in numpy.loadtxt.
first define a function to convert a string in a float, that can handle
your 'N/A' entries:
def converter(x):
if x == 'N/A':
return numpy.nan
else:
return float(x)
then use:
>>> numpy.loadtxt('test.dat', converters={1
why not using:
data = loadtxt('18B180.dat', skiprows = 1, usecols = xrange(1,46))
obviously, you need to know how many columns you have.
hth,
L.
On Sat, Jul 12, 2008 at 10:07:06AM -0400, Bryan Fodness wrote:
> i would like to load my data without knowing the length, i have explicitly
> stated the
If a and b are 2d arrays, you can use numpy.dot:
In [36]: a
Out[36]:
array([[1, 2],
[3, 4]])
In [37]: b
Out[37]:
array([[5, 6],
[7, 8]])
In [38]: numpy.dot(a,b)
Out[38]:
array([[19, 22],
[43, 50]])
If a and b are 3d arrays of shape 2x2xN, you can use something like that:
In [
roblem is cause by the fact that _N.int_ is different for 32 and 64
bits machines. Forcing it to be an _N.int32 did the trick.
Pauli, would you like to commit it to your source distribution?
Regards,
Lorenzo.
--
"Whereof one cannot speak, thereof one mu
l instances of an array into another one.
>
> Matthieu
> --
> French PhD student
> Website : http://matthieu-brucher.developpez.com/
> Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
> LinkedIn : http://www.linkedin.com/
__
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
___
I noticed a change in the behaviour of numpy.asfarray between numpy version
1.0.5 and 1.1.0:
1.0.5
In [3]: numpy.asfarray(None)
Out[3]: array(nan)
In [4]: numpy.__version__
Out[4]: '1.0.5.dev4455'
1.1.0
In [16]: numpy.asfarray(None)
Hello,
the latest svn numpy version 1.1.0.dev5061 does not work with matplotlib
0.90.1 (version shipped with enthought distribution), unless a change in
Python25/Lib/site-packages/matplotlib-0.90.1.0003-py2.5-win32.egg/matplotlib/numerix/ma/__init__.py
is done:
$ diff __init__.py.orig __init__.py
; thanks
> gordon
> ___
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
t; of the table.
L.
On Thu, Mar 27, 2008 at 7:59 PM, Christopher Barker <[EMAIL PROTECTED]>
wrote:
> Alan G Isaac wrote:
> > I believe Robert fixed this;
> > update from the SVN repository.
>
> lorenzo bolla wrote:
> > Should I use numpy.fromfile, instead?
>
3
In [33]: numpy.loadtxt('data.txt')
Out[33]: array([ 1., 2., 3.])
Should I use numpy.fromfile, instead?
L.
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http:
)
1 loops, best of 3: 76.8 us per loop
L.
On Wed, Mar 26, 2008 at 4:21 PM, Joris De Ridder <
[EMAIL PROTECTED]> wrote:
>
> On 26 Mar 2008, at 15:36, lorenzo bolla wrote:
>
> > numpy.tri
> >
> > In [31]: T = numpy.tri(m)
> >
> > In [32]: z.T * T
t
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
gt; Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
py-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
me, but I haven't figure any nicer way.
> Could you tell me if what I am doing looks reasonanble or if there are any
> other solutions?
> Do I really need to initiallize coords?
>
> Thanks in advance,
> Dimitrios
>
> ___
> Nump
1 (r251:54863, Oct 30 2007, 13:54:11)
> [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
>
> >>> import numpy
> >>> A = numpy.array(['a','aa','b'])
> >>> B = numpy.array(['d','e'])
> >>> A.searchsort
> B = numpy.array(['d','e'])
> >>> A.searchsorted(B)
> array([3, 0])
> >>>
>
>
> ___
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
the webpage?
>
> James
> ___
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
The answer should be [3,3]. I've come across this while trying to come
> up with an ismember function which works for strings (setmember1d
> doesn't seems to assume numerical arrays).
>
> Thanks,
> James
> ___
> Numpy-
or you can maybe use numpy.ix_:
ax = [1,2]
R[numpy.ix_(ax,ax)] = 100
hth,
L.
On 1/30/08, lorenzo bolla <[EMAIL PROTECTED]> wrote:
>
> you simply need to change the definition of ax:
> ax = slice(1,3)
>
> and all works fine.
> L.
>
> On 1/30/08, Francesc A
9).reshape(3,3)
> In [69]: S = R[1:3,:][:,1:3]
> In [70]: S[:] = 2
> In [71]: R
> Out[71]:
> array([[0, 1, 2],
> [3, 2, 2],
> [6, 2, 2]])
>
> Cheers,
>
> --
> >0,0< Francesc Altet http://www.carabos.com/
> V V Cárabos Co
I'd rather say "arbitrary".
On 1/29/08, Neal Becker <[EMAIL PROTECTED]> wrote:
>
> lorenzo bolla wrote:
>
> > I noticed that:
> >
> > min([1+1j,-1+3j])
> >
> > gives 1+1j in matlab (where for complex, min(abs) is used)
>
I noticed that:
min([1+1j,-1+3j])
gives 1+1j in matlab (where for complex, min(abs) is used)
but gives -1+3j in numpy (where lexicographic order is used)
shouldn't this be mentioned somewhere in "Numpy for Matlab users" webpage?
--
Lorenzo Bolla
[EMAIL
Shouldn't the "axes" argument in tensordot be named "axis"?
L.
--
Lorenzo Bolla
[EMAIL PROTECTED]
http://lorenzobolla.emurse.com/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Yes, 32 bits.
On a 64 bits machine, I get 8 characters long strings like you.
L.
On 1/9/08, David Huard <[EMAIL PROTECTED]> wrote:
>
> Lorenzo,
>
> 2008/1/9, lorenzo bolla <[EMAIL PROTECTED]>:
> >
> > I don't think it's expected: mine are cropp
aa ' , ' bb ', '
> cc ']
> >>> vstrip(s)
> array(['', '', ''],
> dtype='|S8')
>
> where all strings are cropped to 8 characters.
It doesn't work on Windows, either.
In [35]: numpy.sqrt(numpy.array([-1.0], dtype=numpy.complex192))
Out[35]: array([0.0+2.9996087e-305j], dtype=complex192)
In [36]: numpy.sqrt(numpy.array([-1.0], dtype=numpy.complex128))
Out[36]: array([ 0.+1.j])
In [37]: numpy.__version__
Out[37]: '1.0.5.dev45
you can either use matrix multiplication (see resultmatrix2) or tensordot
(see resultmatrix3).
on my computer I have:
1.15.6 sec with your code
2.0.072 sec with resultmatrix2
3.0.040 sec with tensordot (resultmatrix3) (-- which is a 400x speed)
-
or, you can either use fill.
In [53]: M = numpy.matrix(numpy.zeros((3,5)))
In [55]: M.fill(999)
In [56]: M
Out[56]:
matrix([[ 999., 999., 999., 999., 999.],
[ 999., 999., 999., 999., 999.],
[ 999., 999., 999., 999., 999.]])
L.
On 12/21/07, [EMAIL PROTECTED] <[EMAIL PR
use '+' instead of 'or' for bool arrays.
In [8]: numpy.where((a<1) + (b<3), b, c)
Out[8]: array([4, 2, 2, 1])
hth,
L.
On Dec 16, 2007 8:10 PM, Ross Harder <[EMAIL PROTECTED]> wrote:
>
> What's the correct way to do something like this?
>
> a=array( (0,1,1,0) )
> b=array( (4,3,2,1) )
> c=array(
braries like blas, lapack, fftw, umfpack, arpack
> and so on (which are mainly written in Fortran/C).
>
>
> c) Do you use any form of parallel processing? Multicores? SMPs?
> > Clusters? If yes how did u utilize them?
>
>
> I use MPI (mpi4py) on a shared memory multiproce
Matthieu Brucher <[EMAIL PROTECTED]> wrote:
>
> I'd like to have the '2.', because if the number is negative, only '-' is
> returned, not the real value.
>
> Matthieu
>
> 2007/10/5, lorenzo bolla < [EMAIL PROTECTED]>:
> >
> > wha
what's wrong with astype?
In [3]: x = numpy.array([[2.,3.],[4.,5.]])
In [4]: x.astype(str)
Out[4]:
array([['2', '3'],
['4', '5']],
dtype='|S1')
and if you want a list:
In [5]: x.astype(str).tolist()
Out[5]: [['2', '3'], ['4', '5']]
L.
On 10/5/07, Matthieu Brucher <[EMAIL PROTEC
what about astype?
a.astype(t) -> Copy of array cast to type t.
Cast array m to type t. t can be either a string representing a
typecode,
or a python type object of type int, float, or complex.
L.
On 10/5/07, dmitrey <[EMAIL PROTECTED]> wrote:
>
> hi all,
> I have an array like
> arra
this is really annoying.
Matlab handles the "ceil" weirdness quite well, though.
--
>> ceil(0.6/0.1)
ans =
6
>> ceil((0.4+0.2)/0.1)
ans =
7
>> 0:0.1:0.6
ans =
01.000e-001
2.0
maybe numpy.vdot is good for you.
In [3]: x = numpy.random.rand(4)
In [4]: x
Out[4]: array([ 0.45426898, 0.22369238, 0.98731244, 0.7758774 ])
In [5]: numpy.sqrt(numpy.vdot(x,x))
Out[5]: 1.35394615117
hth,
lorenzo
On 9/5/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
>
> Oh I th
sorry for the silly question: have you done
"python setup.py install"
from the numpy src directory, after untarring?
then cd out from the src directory and try to import numpy from python.
L.
On 7/31/07, kingshuk ghosh <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I downloaded numpy1.0.3-2.tar and unzippe
hi all.
is there a function in numpy to compute the exp of a matrix, similar to expm
in matlab?
for example:
expm([[0,0],[0,0]]) = eye(2)
thanks,
lorenzo.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman
e, is setting the
enviroment variable OMP_NUM_THREADS to the desired value.
using os.environ to set it from python does not seem to work: the function
is always executed using 4 processors (that is quite strange in itself:
where does "4" comes from?).
any hints?
thank you all in a
t.py",
line 994, in run_command
cmd_obj.run()
[...]
KeyError: 'void'
Exit 1
module basic gives no problems, but module basic2 yes, because of the type
construct.
it seems that f2py doesn't support "type" construct. am I right? is there a
workaround?
thank you very much,
lorenzo.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
py/rules.py",
line 1130, in buildmodule
mr,wrap = f90mod_rules.buildhooks(m)
File
"/xlv1/labsoi_devices/bollalo001/lib/python2.5/site-packages/numpy/f2py/f90mod_rules.py",
line 127, in buildhooks
at = capi_maps.c2capi_map[ct]
KeyError: 'void'
Exit 1
module basic gives no problems, but module basic2 yes, because of the type
construct.
what am I doing wrong?
thank you very much,
lorenzo.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
[ 4., 5., 4., 5.],
[ 6., 5., 6., 7.]], dtype=float32)
How can I do that?
(I know I could do data.reshape(4,3).T, but it's not very "elegant" and
reshaping in ND becomes a mess!).
(I tried with numpy.array(data, order = 'Fotran'
Hi all.
I have to work with floating point arithmetics and I found a module called
"double module" (http://symptotic.com/mj/double/public/double-module.html)
that does what I'd like. Basically, I would like to find the nearest smaller
and bigger floating point numbers, given a "real" real number (
would...
any hints?
thank you!
L.
On 5/24/07, Pierre GM <[EMAIL PROTECTED]> wrote:
Lorenzo,
you can indeed use f2py to write extensions around some C code:
http://cens.ioc.ee/projects/f2py2e/usersguide/index.html
http://www.scipy.org/Cookbook/f2py_and_NumPy
I think you should also b
t? Or giving me a good
tutorial to read? I found only very few information on www.scipy.org.
Thank you in advance,
Lorenzo.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Hi all,
I need to know the libraries (BLAS and LAPACK) which numpy has been linked
to, when I compiled it.
I can't remember which ones I used (ATLAS, MKL, etc...)...
Is there an easy way to find it out?
Thanks in advance,
Lorenzo Bolla.
___
hold on, david. the formula I posted previously from wolfram is ArcTan[x,y]
with x or y complex: its the same of arctan2(x,y). arctan is another
function (even though arctan2(y,x) should be "a better" arctan(y/x)).
the correct formula for y = arctan(x), with any x (real or complex), should
be (if
it looks like repmat is not there anymore... why?
use numpy.repeat and numpy.tile, instead!
hth,
lorenzo.
On 4/30/07, dmitrey <[EMAIL PROTECTED]> wrote:
What's wrong?
start python shell;
from numpy import sin => all ok
from numpy import repmat =>
Traceback (most recent c
me!
I have two cases.
1. I need that arctan2(1+0.0001j,1-0.01j) gives something
close to arctan2(1,1): any decent analytic prolungation will do!
2. if someone of you is familiar with electromagnetic problems, in
particular with Snell's law, will recognize that in case of total
i
You make your point, but I would expect a behaviour similar to Mathematica
or Matlab.
From http://documents.wolfram.com/mathematica/functions/ArcTan
"If x or y is complex, then ArcTan[x, y] gives . When , ArcTan[x, y] gives
the number such that and ."
Lorenzo.
On 4/29/07, David
ave:8> atan2(1j,1j)
ans = 0
octave:9> atan2(1j,1)
ans = 0
octave:10> atan2(1,1j)
ans = 1.5708
bug or wanted behaviour?
Lorenzo.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
updated.
now it works. many thanks.
L.
On 4/19/07, Nils Wagner <[EMAIL PROTECTED]> wrote:
lorenzo bolla wrote:
> dear all,
> I've some problems with numpy.roots.
> take a look at the following code:
>
>
> import numpy
return res
70 elif len(s)==2:
TypeError: can't convert complex to float; use abs(z)
any ideas?
thanks,
Lorenzo
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
your numbers, I can tell that compiling numpy with gcc or icc
makes no big difference.
Am I correct?
If yes, let me know if I can add this info to the scipy wiki: I'm preparing
an extention to this page http://www.scipy.org/PerformancePython.
cheers,
lorenzo
On 4/17/07, rex <[EMAIL
as soon as you do it, I'd like to compare them with the benchmarks I posted
here few days ago (compiled with gcc):
http://lbolla.wordpress.com/2007/04/11/numerical-computing-matlab-vs-pythonnumpyweave/
lorenzo.
On 4/17/07, rex <[EMAIL PROTECTED]> wrote:
I'm about to build num
thanks. I hadn't seen it.
anyway, from very rough benchmarks I did, the quickest and easiest way of
computing the euclidean norm of a 1D array is:
n = sqrt(dot(x,x.conj()))
much faster than:
n = sqrt(sum(abs(x)**2))
and much much faster than:
n = scipy.linalg.norm(x)
regards,
lorenzo.
On
Hi all,
just a quick (and easy?) question.
what is the best (fastest) way to implement the euclidean norm of a vector,
i.e. the function:
import scipy as S
def norm(x):
"""normalize a vector."""
return S.sqrt(S.sum(S.absolute(x)**2))
emed to be "responsible" for the
project, cannot be contacted via e-mail.
Thank you!
Lorenzo
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
ops. I did it, too.
should I delete it?? how??
thanks!
On 1/8/07, Charles R Harris <[EMAIL PROTECTED]> wrote:
On 1/8/07, Charles R Harris <[EMAIL PROTECTED]> wrote:
>
>
>
> On 1/8/07, lorenzo bolla < [EMAIL PROTECTED]> wrote:
> >
> > Well, I don
oh, I forgot. It happens with "divide", too.
lorenzo.
On 1/8/07, Charles R Harris <[EMAIL PROTECTED]> wrote:
On 1/8/07, Charles R Harris <[EMAIL PROTECTED]> wrote:
>
>
>
> On 1/8/07, lorenzo bolla < [EMAIL PROTECTED]> wrote:
> >
> &g
Well, I don't know if we should consider it a bug, but it definetely behaves
not as expected by the standard "reduce", right?
I'm very happy to help: just tell me how to "file a ticket"! (what does it
mean, by the way?).
thanks!
lorenzo.
On 1/8/07, Charles R Ha
dd, x) # 6, as expected
add.reduce(x) # 6, as expected
def mysub(x,y): # re-define the binary diff function
return x - y
reduce(mysub, x)# -6, as expected
subtract.reduce(x)# 2 ---> WHY?
Can someone explain me this?
Thank you in advance!
65 matches
Mail list logo