I haven't checked correctness, but how about
np.tensordot(rotation, data, axes=1)
Gary R
On 24 February 2012 23:11, Bob Dowling rjd4+nu...@cam.ac.uk wrote:
Conceptually, I have a 2-d grid of 2-d vectors. I am representing this
as an ndarray of shape (2,M,N). I want to apply a 2x2 matrix
Hi Ben,
based on this example
https://bitbucket.org/lannybroo/numpyio/src/a6191c989804/numpyIO.py
I suspect the way to do it is with numpy.byteswap() and numpy.tofile()
From
http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.byteswap.html
we can do
A = np.array([1, 256, 8755],
convert only the second
column, because your converters dictionary contains a single key (1).
If you have it contain keys from 0 to 3 associated to the same function, it
should work.
-=- Olivier
2011/6/17 gary ruben gru...@bigpond.net.au
I'm trying to read a file containing data formatted
)[:,:-1]
b = np.vectorize(lambda x: complex(*eval(x)))(b)
print b
On Sat, Jun 18, 2011 at 12:31 AM, Bruce Southey bsout...@gmail.com wrote:
On 06/17/2011 08:51 AM, Olivier Delalleau wrote:
2011/6/17 Bruce Southey bsout...@gmail.com
On 06/17/2011 08:22 AM, gary ruben wrote:
Thanks Olivier,
Your
Thanks guys - I'm happy with the solution for now. FYI, Derek's
suggestion doesn't work in numpy 1.5.1 either.
For any developers following this thread, I think this might be a nice
use case for genfromtxt to handle in future.
As a corollary of this problem, I wonder whether there's a
I'm trying to read a file containing data formatted as in the
following example using genfromtxt and I'm doing something wrong. It
almost works. Can someone point out my error, or suggest a simpler
solution to the ugly converter function? I thought I'd leave in the
commented-out line for future
You control this with numpy.set_printoptions:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.set_printoptions.html
On Sun, Jun 12, 2011 at 10:10 PM, Chao YUE chaoyue...@gmail.com wrote:
Dear all pythoners,
Does anybody know how I can choose the default display style for the data?
I learn a lot by watching the numpy and scipy lists (today Olivier
taught me about heapq :), but he may not have noticed that Python 2.4
added an nsmallest method)
import heapq
q = list(x)
heapq.heapify(q)
k_smallest = heapq.nsmallest(k,q)
On Mon, Jun 6, 2011 at 10:52 PM, Olivier Delalleau
I think the easiest is to use an intermediate string. If your file is test.txt,
In [22]: a = file('test.txt').read().replace(',','.')
In [23]: import StringIO
In [24]: b=genfromtxt(StringIO.StringIO(a))
In [25]: b
Out[25]:
array([[ 0.e+00, 1.2210e-03, 1.2210e-03,
You're right, they are not equivalent. vstack will happily create an
array of higher rank than the parts it is stacking, whereas
concatenate requires the arrays it is working with to already be at
least 2d, so the equivalent is
np.concatenate((np.arange(5.)[newaxis],np.arange(5.)[newaxis]),
How about
argmin(add.reduce((a*a),axis=1))
In [5]: a
Out[5]:
array([[ 0.24202827, 0.01269182, 0.95162307],
[ 0.02979253, 0.454 , 0.49650111],
[ 0.52626565, 0.08363861, 0.56444878],
[ 0.89639659, 0.54259354, 0.29245881],
[ 0.75301013, 0.6248646 ,
np.setmember1d(a,b)
does the same as your
reduce(np.logical_or, [a == i for i in b])
but it's actually slower on my machine!
Gary R.
Ernest Adrogué wrote:
Hi,
Suppose I have a flat array, and I want to know the
indices corresponding to values contained in a list
of arbitrary lenght.
josef.p...@gmail.com wrote:
Is it really possible to get the same as np.sum(a*a, axis) with
tensordot if a.ndim=2 ?
Any way I try the something_else, I get extra terms as in np.dot(a.T, a)
Just to answer this question, np.dot(a,a) is equivalent to
np.tensordot(a,a, axis=(0,0))
but the
In [1]: a=array([1,2,3])
In [2]: a[::-1]
Out[2]: array([3, 2, 1])
Johannes Bauer wrote:
Hello list,
I have a really simple newbie question: How can I mirror/flip a
numpy.ndarray? I.e. mirror switches the colums (leftmost becomes
rightmost and so on), flip changes the rows (top becomes
I'm trying to work out how to apply a 2x2 transform matrix to a spinor, e.g.
[psi1'] [a b][psi1]
[ ] = [][]
[psi2'] [c d][psi2]
where [[a,b],[c,d]] is a transform matrix and psi1 and psi2 are
i x j x k complex arrays representing complex scalar field data. I
worked that one
I think I've answered my own question - I remembered tensordot, and the
following seems to work:
def transform(tx_matrix, psi1, psi2):
psi = np.tensordot(tx_matrix,
np.concatenate((psi1[newaxis],psi2[newaxis])),axes=1))
return psi[0], psi[1]
sorry for the noise,
Gary
Gary
My friend has used this successfully:
http://www.datathief.org/
Looks like this will do it too:
http://www.datamaster2003.com/
Gary R.
João Luís Silva wrote:
Neal Becker wrote:
Anyone know of software that can assist with reading data points from a pdf
version of a 2-d line graph?
There
The only time I've done this, I used numpy.fromfile exactly as follows.
The file had a header followed by a number of records (one float
followed by 128 complex numbers), requiring separate calls of
numpy.fromfile to read each part. The only strange part about this was
that the Fortran code
Prashant Saxena wrote:
I am seeing all the OSS for this purpose but I would stick to use pure
python and the scene graph I am developing for the application. I
already did some test using pyOpenGL/python/wx.GLcanvas and a large data
set of roughly 4000+ objects consisting nearly 1 million
I don't know what you mean by a 1D vector, but for a 3-vector, you can
do this (also works for N-dimensions)
In [1]: a=r_[1.,2.,3.]
In [2]: a
Out[2]: array([ 1., 2., 3.])
In [3]: b=a/norm(a)
In [4]: b
Out[4]: array([ 0.26726124, 0.53452248, 0.80178373])
Gary R
bit of a newb question, is
You're best off using scipy.
Just Google search for scipy spline:
e.g.
http://www.scipy.org/Cookbook/Interpolation
http://xinqingpeng.blogspot.com/2007/07/scipy-spline-example.html
Gary R.
Gong, Shawn (Contractor) wrote:
hi list,
I am trying to find 1-D cubic spline function. But I am not
Henrik Ronellenfitsch wrote:
snip
Thanks very much for your solution, this is exactly what I needed!
If I'm not mistaken, though, you can achieve the same result with
h = hamming(n)
ham2d = sqrt(outer(h,h))
which is a bit more compact.
Regards,
Henrik
Yes, that's nicer.
regards,
Henrik Ronellenfitsch wrote:
Hello!
I'm looking for a 2D hamming window function.
As far as I can see, numpy only supports 1D windows
and googling didn't show a simple way of extending it
in two dimensions.
Thanks for your help,
Henrik
Hi Henrik,
I haven't looked at the correct way to
I had a chance to look at Anne's suggestion from this thread
http://www.mail-archive.com/numpy-discussion@scipy.org/msg10091.html
and I thought I should post my phase winding finder solution, which is
slightly modified from her idea. Thanks Anne. This is a vast improvement
over my original slow
Hi Anne,
Thanks for the approach ideas - I'll take a look at this soon to try to
understand it. Currently I'm visiting a LabView-based lab who already
have something that works, and works fast, so I'm being encouraged to
use LabView, but I'd like to show them more of the joys of Python. The
Tested fine on my old Classic Athlon 500 (no SSE) under Win98. It
correctly reported installing the non-SSE version when I clicked on the
details button on the last page of the install wizard. Whereas
previously numpy.test() would bring up an illegal operation dialog box,
now all tests pass.
Try using astype. This works:
values = array(wavearray.split()).astype(float)
Gary R.
Adam Mercer wrote:
values = array(wavearray.split())
where wavearray is a string containing a series of floats separated by
white space, it appears that the individual elements of the values
array are
FWIW,
The list comprehension is faster than using map()
In [7]: %timeit map(lambda x:x[0],bounds)
1 loops, best of 3: 49.6 -¦s per loop
In [8]: %timeit [x[0] for x in bounds]
1 loops, best of 3: 20.8 -¦s per loop
Gary R.
Keith Goodman wrote:
On 8/9/07, Nils Wagner [EMAIL PROTECTED]
This is great Perry,
I think this will help to convince our department's astronomer(s) to
learn and maybe use Python for teaching.
By the way, if you do a global search for numarray in your document,
you'll pick up a few pieces of unchanged text and code.
Gary R.
Perry Greenfield wrote:
I
Actually, I just realised; it's not an ipython problem. I think it's a
matplotlib problem. I'll report it there.
Gary R.
Steve Lianoglou wrote:
Thanks Alan Chris,
My apologies. I was trying ones(), zeros() and empty() in ipython
0.7.2
with the -pylab option and getting the wrong
One question, which may be an issue: Should ones, zeros and empty be
generating arrays of floats by default now?
Gary R.
Travis Oliphant wrote:
I think it's time for the 1.0.2 release of NumPy.
What outstanding issues need to be resolved before we do it?
Hopefully, we can do it by the
31 matches
Mail list logo