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 [
Hello all.
I'm not sure that this is the correct mailing list to post to: please excuse
me if it's not.
I've been using bvp (http://www.elisanet.fi/ptvirtan/software/bvp/index.html)
by Pauli Virtanen happily on 32 bits machines.
When I used it on 64 bits machines I found a bug that I think I've s
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(
> a) Can you guys tell me briefly about the kind of problems you are
> > tackling with numpy and scipy?
>
>
> Electromagnetic problems: eigenvalues finding, linear systems,
> optimizations...
>
> b) Have you ever felt that numpy/scipy was slow and had to switch to
> > C/C++/Fortran?
>
>
>
> I come
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 think I get it.
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/lis
hi all,
I'm using f2py to compile a f90 function, parallelized with openmp, into a
shared object, that I can import in python.
the question is: when I call the function from python, how can I specify the
number of threads to use?
the usual way of doing it, with a common fortran executable, is sett
hi all.
I'm trying to compile an F90 source file with f2py, but it fails with the
construct "type ... end type".
here is an example:
! file test19.f90
module
basic
implicit
none
save
integer, parameter :: ciao =
17
end module
basic
module
basic2
implicit
none
save
hi all.
I'm trying to compile an F90 source file with f2py, but it fails with the
construct "type ... end type".
here is an example:
! file test19.f90
module
basic
implicit
none
save
integer, parameter :: ciao =
17
end module
basic
module
basic2
implicit
n
Hi all,
I've got an easy question for you. I looked in Travis' book, but I couldn't
figure out the answer...
If I have an array1D (obtained reading a stream of numbers with
numpy.fromfile) like that:
In [150]: data
Out[150]: array([ 2., 3., 4., 3., 4., 5., 4., 5., 6., 5., 6.,
7.], dtyp
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 (
I tried to write my own prova2.pyf and this is it:
!-*- f90 -*-
! Note: the context of this file is case sensitive.
python module prova
interface
function incr(x)
real, dimension(2), intent(c) :: incr
real, dimensi
Hi all,
I hope this is the right mailing list to post my question to.
I'm trying to make some easy C code working with Python by using f2py.
For example, take the test.c file:
--
typedef struct data {
int a;
double b;
} DATA;
/*function with struct*/
DAT
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 call last):
File "
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
code expression - as near as I
can tell, you're going to have to implement an if/else if you need to
allow for the invtan of two complex arguments - you need to handle
arctan2(z,w), implement it as arctan(w/z):
>>> import numpy
>>> numpy.arctan(1j/1j)
(0.78539816339744828
Weird behaviour with arctan2(complex,complex).
Take a look at this:
In [11]: numpy.arctan2(1.,1.)
Out[11]: 0.785398163397
In [12]: numpy.arctan2(1j,1j)
---
exceptions.AttributeErrorTraceback (mos
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
dear all,
I've some problems with numpy.roots.
take a look at the following code:
import numpy
OK = numpy.roots([1, 1, 1])
OK = numpy.roots([1j, 1])
KO = numpy.roots([1, 1j, 1])
it fails with this error message, t
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 numpy using Intel's M
nj() * x).real.ravel()))
else:
raise ValueError, "Invalid norm order for matrices."
else:
raise ValueError, "Improper number of dimensions to norm."
--bb
On 3/14/07, lorenzo bolla <[EMAIL PROTECTED]> wrote:
> Hi all,
> just a quick (and easy?) q
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))
?
thanks in advance,
Lorenzo.
___
Hi all, I'm not sure if I am slightly out of topic, but I can't find
information anywhere else.
Can someone tell me where the Python EM Project has gone? The website
www.pythonemproject.com that used to host it is now a bunch of ads, property
of DomainDrop. Also Robert Lytle, who seemed to be "res
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
rris <[EMAIL PROTECTED]> wrote:
On 1/8/07, Charles R Harris <[EMAIL PROTECTED]> wrote:
>
>
>
> On 1/8/07, lorenzo bolla < [EMAIL PROTECTED]> wrote:
> >
> > Hello all!
> > I'm fairly new to Numpy and, while experimenting, I found a strange (
>
Hello all!
I'm fairly new to Numpy and, while experimenting, I found a strange (i.e.
not expected by me!) behaviour of arrays.
I tried this (in comment what I get):
x = arange(4) # x = array([0,1,2,3])
def myadd(x,y):# re-define the binary sum function
return x + y
reduce(myadd, x)
63 matches
Mail list logo