Hello,
I recently had to get data from a mysql database into a recarray. The result
was not very long but nontrivial to figure out:
def recarray_from_db(db, command):
""" executes a command and turns the results into a numpy recarray
(record array)"""
cursor = db.cursor()
cursor.execu
Here is a fun one...
import numpy as np
a_2d = np.random.random((3, 5))
b_1d = np.random.random(5)
b_2d = np.vstack((b_1d, b_1d, b_1d))
a_ma_2d = np.ma.masked_array(a_2d, mask=(numpy.random.random((3, 5)) <
0.25))
b_ma_1d = np.ma.masked_array(b_1d, mask=(numpy.random.random(5) < 0.25))
b_ma_2d =
Sweet! Guess I need to learn more about numpy indexing: this is pretty
powerful.
On Fri, Sep 3, 2010 at 10:42 AM, Keith Goodman wrote:
> On Fri, Sep 3, 2010 at 9:39 AM, Rick Muller wrote:
> > There just *has* to be a better way of doing this. I want to cut off
> small
> > values of a vector, an
On Fri, Sep 3, 2010 at 9:39 AM, Rick Muller wrote:
> There just *has* to be a better way of doing this. I want to cut off small
> values of a vector, and I'm currently doing something like:
>
for i in xrange(n):
if abs(A[i]) < tol: A[i] = 0
>
> Which is slow, since A can be really lon
There just *has* to be a better way of doing this. I want to cut off small
values of a vector, and I'm currently doing something like:
>>> for i in xrange(n):
>>>if abs(A[i]) < tol: A[i] = 0
Which is slow, since A can be really long. Is there a way to write a Ufunc
that would do something lik
On Fri, Sep 3, 2010 at 8:50 AM, Benjamin Root wrote:
> Why is this function in matplotlib? Wouldn't it be more useful in numpy?
I tend to add stuff I write to matplotlib. mlab was initially a
repository of matlab-like functions that were not available in numpy
(load, save, linspace, psd, coher
2010/9/3 Guillaume Chérel :
> Great, Thank you. I also found out about csv2rec. I've been missing
> these two a lot.
Some other handy rec functions in mlab
http://matplotlib.sourceforge.net/examples/misc/rec_groupby_demo.html
http://matplotlib.sourceforge.net/examples/misc/rec_join_demo.html
JD
Excerpts from Guillaume Chérel's message of Fri Sep 03 09:32:02 -0400 2010:
> Hello,
>
> I'd like to know if there is a convenient routine to write recarrays
> into cvs files, with the first line of the file being the name of the
> fields.
>
> Thanks,
> Guillaume
Yes, you can do this with th
On Fri, Sep 3, 2010 at 8:35 AM, Pierre GM wrote:
>
> On Sep 3, 2010, at 3:32 PM, Guillaume Chérel wrote:
>
> > Hello,
> >
> > I'd like to know if there is a convenient routine to write recarrays
> > into cvs files, with the first line of the file being the name of the
> > fields.
>
> matplotlib.
Great, Thank you. I also found out about csv2rec. I've been missing
these two a lot.
Le 03/09/2010 15:35, Pierre GM a écrit :
> On Sep 3, 2010, at 3:32 PM, Guillaume Chérel wrote:
>
>> Hello,
>>
>> I'd like to know if there is a convenient routine to write recarrays
>> into cvs files, with th
On Sep 3, 2010, at 3:32 PM, Guillaume Chérel wrote:
> Hello,
>
> I'd like to know if there is a convenient routine to write recarrays
> into cvs files, with the first line of the file being the name of the
> fields.
matplotlib.mlab.rec2csv
___
NumP
Hello,
I'd like to know if there is a convenient routine to write recarrays
into cvs files, with the first line of the file being the name of the
fields.
Thanks,
Guillaume
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scip
Josef and Pauli,
Wow, you guys rock! I'm amazed you could pull that out so quickly.
I thank you, and PyQuante thanks you (hopefully this will make for faster
density functional theory grids).
Rick
On Fri, Sep 3, 2010 at 5:59 AM, wrote:
> On Fri, Sep 3, 2010 at 7:48 AM, Rick Muller wrote:
> >
On Fri, Sep 3, 2010 at 7:48 AM, Rick Muller wrote:
> Sorry for the rapid repost, but I thought of a much easier way to ask the
> question I asked a few minutes ago.
>
> I have two matrices, A and B, both of which are n x m. n is big (~10,000),
> and m is small (~10).
>
> I want to take the product
Fri, 03 Sep 2010 05:48:31 -0600, Rick Muller wrote:
[clip]
> I want to take the product AB such that I get a length-n vector, as in:
>
> >>> AB = zeros(n,'d')
> >>> for i in xrange(n):
> >>>AB[i] = dot(A[i,:],B[i,:])
>>> AB = np.sum(A*B, axis=1)
It does create an intermediate (n, d) matrix,
Sorry for the rapid repost, but I thought of a much easier way to ask the
question I asked a few minutes ago.
I have two matrices, A and B, both of which are n x m. n is big (~10,000),
and m is small (~10).
I want to take the product AB such that I get a length-n vector, as in:
>>> AB = zeros(n,
Can someone help me replace a slow expression with a faster one based on
tensordot? I've read the documentation and I'm still confused.
I have two matrices b and d. b is n x m and d is m x m. I want to replace
the expression
>>> bdb = zeros(n,'d')
>>> for i in xrange(n):
>>> bdb[i,:] = dot(b[
Fri, 03 Sep 2010 08:53:00 +0300, Åsmund Hjulstad wrote:
> I have a f2py wrapped fortran extension, compiled using gcc-mingw32
> (v.4.5.0), numpy 1.5, Python 2.7, where I am experiencing the strangest
> behaviour. It appears that loading pygtk breaks my fortran extension.
Be aware that "import gtk"
18 matches
Mail list logo