[Numpy-discussion] Merging structured arrays with mixed dtypes including '|O4'

2013-01-28 Thread Alex
Let's say I have two structured arrays with dtypes as per below getdat.dtype dtype([('Tstamp', '|O4'), ('Vf', 'f4'), ('Vq', 'f4'), ('Sf', 'f4'), ('Sq', 'f4'), ('Bt', 'f4'), ('SPL', 'f4')]) out.dtype dtype([('Viscosity_cSt', 'f4'), ('Density_kgm3', 'f4'), ('GVF', 'f4')]) Then merging this per

[Numpy-discussion] Matrix Expontial for differenr t.

2013-01-28 Thread Till Stensitzki
Hi group, is there a faster way to calculate the matrix exponential for different t's than this: def sol_matexp(A, tlist, y0): w, v = np.linalg.eig(A) out = np.zeros((tlist.size, y0.size)) for i, t in enumerate(tlist): sol_t =

Re: [Numpy-discussion] Matrix Expontial for differenr t.

2013-01-28 Thread Robert Kern
On Mon, Jan 28, 2013 at 5:31 PM, Till Stensitzki mail.t...@gmx.de wrote: Hi group, is there a faster way to calculate the matrix exponential for different t's than this: def sol_matexp(A, tlist, y0): w, v = np.linalg.eig(A) out = np.zeros((tlist.size, y0.size)) for i, t in

Re: [Numpy-discussion] Matrix Expontial for differenr t.

2013-01-28 Thread Nadav Horesh
I did not try it, but I assume that you can build a stack of diagonal matrices as a MxNxN array and use tensordot with the matrix v (and it's inverse). The trivial way to accelerate the loop is to calculate in inverse of v before the loop. Nadav

Re: [Numpy-discussion] Matrix Expontial for differenr t.

2013-01-28 Thread Pierre Haessig
Hi, Le 28/01/2013 17:31, Till Stensitzki a écrit : This is the calculates exp(-Kt).dot(y0) for a list a ts. If your time vector ts is *regularly* discretized with a timestep h, you could try an iterative computation I would (roughly) write this as : Ah = np.expm(A*h) # or use the

Re: [Numpy-discussion] Matrix Expontial for differenr t.

2013-01-28 Thread Till Stensitzki
Thanks for hints so far, i am especially searching for a way to get rid of the t loop. Making a NxMxM Matrix is quite memory inefficient in my case (N M). On way would be just use cython, but i think this problem common enough to have a solution into scipy. (Solution of a simple compartment

Re: [Numpy-discussion] Matrix Expontial for differenr t.

2013-01-28 Thread Pierre Haessig
Hi, Le 28/01/2013 18:14, Till Stensitzki a écrit : On way would be just use cython, but i think this problem common enough to have a solution into scipy. (Solution of a simple compartment model.) I see the solution you propose as a specialized ODE solver for linear systems. Then, what about

[Numpy-discussion] Numpy multiple instances

2013-01-28 Thread santhu kumar
Hello, I have embedded python/numpy scripts in an application that runs in parallel. But the python code is always invoked on the master node. So it could be assumed that at some point, there could be multiple instances of script being invoked and run. I have commented out import numpy part to

Re: [Numpy-discussion] Numpy multiple instances

2013-01-28 Thread santhu kumar
Please ignore the previous message. I have done some testing and found it to be running on a client node instead of the master node. The problem might be because node2, does not have numpy installed. Thanks. ___ NumPy-Discussion mailing list

[Numpy-discussion] numpythonically getting elements with the minimum sum

2013-01-28 Thread Lluís
Hi, I have a somewhat convoluted N-dimensional array that contains information of a set of experiments. The last dimension has as many entries as iterations in the experiment (an iterative application), and the penultimate dimension has as many entries as times I have run that experiment; the

[Numpy-discussion] PyArray_FromAny silently converts None to a singleton nan

2013-01-28 Thread Geoffrey Irving
I discovered this from C via the PyArray_FromAny function, but here it is in Python: asarray(None,dtype=float) array(nan) Is this expected or documented behavior? It seems quite unintuitive and surprising that this wouldn't throw an exception. Is there a way to disable this behavior

Re: [Numpy-discussion] PyArray_FromAny silently converts None to a singleton nan

2013-01-28 Thread Bradley M. Froehle
import numpy as np np.double(None) nan On Mon, Jan 28, 2013 at 3:48 PM, Geoffrey Irving irv...@naml.us wrote: I discovered this from C via the PyArray_FromAny function, but here it is in Python: asarray(None,dtype=float) array(nan) Is this expected or documented behavior?

Re: [Numpy-discussion] PyArray_FromAny silently converts None to a singleton nan

2013-01-28 Thread Geoffrey Irving
For comparison: float32(None) nan float(None) Traceback (most recent call last): File stdin, line 1, in module TypeError: float() argument must be a string or a number On Mon, Jan 28, 2013 at 5:09 PM, Bradley M. Froehle brad.froe...@gmail.com wrote: import numpy as np np.double(None) nan