Re: [Numpy-discussion] Would a patch with a function for incrementing an array with advanced indexing be accepted?

2012-07-06 Thread John Salvatier
((5,5)) > x[[0,2,4]]+=numpy.random.rand(3,5) > print x > > This won't work if in the list [0,2,4], there is index duplication, > but with your new code, it will. I think it is the most used case of > advanced indexing. At least, for our lab:) > > Fred > > On Mon, Jul 2,

Re: [Numpy-discussion] Would a patch with a function for incrementing an array with advanced indexing be accepted?

2012-07-02 Thread John Salvatier
> I personnaly can't review this as this is too much in NumPy internal. > > My only comments is that you could add a test and an example in the > doc for matrix[list]. I think it will be the most used case. > > Fred > > On Wed, Jun 27, 2012 at 7:47 PM, John Salvatier &

Re: [Numpy-discussion] Would a patch with a function for incrementing an array with advanced indexing be accepted?

2012-06-27 Thread John Salvatier
larifying. > > -Travis > > > > > Fred > > > > On Tue, Jun 26, 2012 at 1:27 PM, John Salvatier > > wrote: > >> Can you clarify why it would be super hard? I just reused the code for > >> advanced indexing (a modification of PyArray_SetMap). Am

Re: [Numpy-discussion] What's the most numpythonic way to support multiple types in a C extension?

2012-06-27 Thread John Salvatier
Thanks nathaniel, that does tricky... On Wed, Jun 27, 2012 at 9:25 AM, Nathaniel Smith wrote: > On Tue, Jun 26, 2012 at 10:53 PM, John Salvatier > wrote: > > I want to support multiple types in the index_increment function that > I've > > written here: > > >

[Numpy-discussion] What's the most numpythonic way to support multiple types in a C extension?

2012-06-26 Thread John Salvatier
I want to support multiple types in the index_increment function that I've written here: https://github.com/jsalvatier/numpy/blob/master/numpy/core/src/multiarray/mapping.c I need to check that the first argument's type can support addition, cast the dataptr to the appropriate type and do the addi

Re: [Numpy-discussion] Would a patch with a function for incrementing an array with advanced indexing be accepted?

2012-06-26 Thread John Salvatier
ted as you said. > > Fred > > On Tue, Jun 26, 2012 at 1:27 PM, John Salvatier > wrote: > > Can you clarify why it would be super hard? I just reused the code for > > advanced indexing (a modification of PyArray_SetMap). Am I missing > something > > crucial? > > >

Re: [Numpy-discussion] Would a patch with a function for incrementing an array with advanced indexing be accepted?

2012-06-26 Thread John Salvatier
Can you clarify why it would be super hard? I just reused the code for advanced indexing (a modification of PyArray_SetMap). Am I missing something crucial? On Tue, Jun 26, 2012 at 9:57 AM, Travis Oliphant wrote: > > On Jun 26, 2012, at 11:46 AM, John Salvatier wrote: > > Hello

[Numpy-discussion] Would a patch with a function for incrementing an array with advanced indexing be accepted?

2012-06-26 Thread John Salvatier
Hello, If you increment an array using advanced indexing and have repeated indexes, the array doesn't get repeatedly incremented, http://comments.gmane.org/gmane.comp.python.numeric.general/50291. I wrote a C function that does incrementing with repeated indexes correctly. The branch is here (http

[Numpy-discussion] PyArray_MapIter{Reset, Next, New, Bind} not exposed?

2012-06-20 Thread John Salvatier
Hello, I wanted to create a function that visits elements in an array using the same rules as advanced indexing (with integer and boolean arrays) but does addition instead of assignment (discussed more here http://mail.scipy.org/pipermail/numpy-discussion/2012-June/062687.html). I looked at the c

Re: [Numpy-discussion] Incrementing with advanced indexing: why don't repeated indexes repeatedly increment?

2012-06-06 Thread John Salvatier
That does seem like it should work well if len(unique(idx)) is close to len(x). Thanks! On Wed, Jun 6, 2012 at 9:35 AM, Robert Kern wrote: > On Wed, Jun 6, 2012 at 4:52 PM, Robert Cimrman > wrote: > > > Yes (in that thread), but it applies also adding/assembling vectors into > a > > global vect

Re: [Numpy-discussion] Incrementing with advanced indexing: why don't repeated indexes repeatedly increment?

2012-06-06 Thread John Salvatier
py.put.html > > On Wed, Jun 6, 2012 at 4:48 AM, John Salvatier > wrote: > > Hello, > > > > I've noticed that If you try to increment elements of an array with > advanced > > indexing, repeated indexes don't get repeatedly incremented. For example: >

[Numpy-discussion] Incrementing with advanced indexing: why don't repeated indexes repeatedly increment?

2012-06-06 Thread John Salvatier
Hello, I've noticed that If you try to increment elements of an array with advanced indexing, repeated indexes don't get repeatedly incremented. For example: In [30]: x = zeros(5) In [31]: idx = array([1,1,1,3,4]) In [32]: x[idx] += [2,4,8,10,30] In [33]: x Out[33]: array([ 0., 8., 0., 1

Re: [Numpy-discussion] just the date part of a datetime64[s]?

2012-02-09 Thread John Salvatier
take a timezone > parameter, so the code explicitly specifies how the conversion takes place. > A crude replacement for now is: > > x = datetime64('2012-02-02 22:00:00', 's') > > np.datetime64(np.datetime_as_string(x, timezone='local')[:10]) > Out[21]

[Numpy-discussion] just the date part of a datetime64[s]?

2012-02-08 Thread John Salvatier
Hello, is there a good way to get just the date part of a datetime64? Frequently datetime datatypes have month(), date(), hour(), etc functions that pull out part of the datetime, but I didn't see those mentioned in the datetime64 docs. Casting to a 'D' dtype didn't work as I would have hoped: In

Re: [Numpy-discussion] datetime64 format parameter?

2012-02-06 Thread John Salvatier
mplementation unfortunately > hadn't followed that part of the spec. > > Cheers, > Mark > > On Mon, Feb 6, 2012 at 12:40 PM, John Salvatier > wrote: > >> Hello, >> >> Is there a way to specify a format for the datetime64 constructor? The >> cons

[Numpy-discussion] datetime64 format parameter?

2012-02-06 Thread John Salvatier
Hello, Is there a way to specify a format for the datetime64 constructor? The constructor doesn't have a doc. I have dates in a file with the format "MM/dd/YY". datetime64 used to be able to parse these in 1.6.1 but the dev version throws an error. Cheers, John ___

Re: [Numpy-discussion] Cross-covariance function

2012-01-21 Thread John Salvatier
I ran into this a while ago and was confused why cov did not behave the way pierre suggested. On Jan 21, 2012 12:48 PM, "Elliot Saba" wrote: > Thank you Sturla, that's exactly what I want. > > I'm sorry that I was not able to reply for so long, but Pierre's code is > similar to what I have alread

[Numpy-discussion] "Symbol table not found" compiling numpy from git repository on Windows

2012-01-05 Thread John Salvatier
Hello, I'm trying to compile numpy on Windows 7 using the command: "python setup.py config --compiler=mingw32 build" but I get an error about a symbol table not found. Anyone know how to work around this or what to look into? building library "npymath" sources Building msvcr library: "C:\Python26

[Numpy-discussion] nested_iters does not accept length zero nest (also doesn't have documentation)

2012-01-03 Thread John Salvatier
Hellow, while using the nested_iters function, I've noticed that it does not accept length zero nestings. For example, the following fails: nested_iters([ones(3),ones(3)], [[], [0]]) with "ValueError: If 'op_axes' or 'itershape' is not NULL in theiterator constructor, 'oa_ndim' must be greater th

[Numpy-discussion] Problem with changes to f2py

2011-12-29 Thread John Salvatier
Hi Numpy users! I maintain the boundary value problem solver package scikits.bvp_solver. It's had problems with f2py for a while, and I am not sure where they are coming from. I made this stackoverflow post

Re: [Numpy-discussion] wanted: decent matplotlib alternative

2011-10-13 Thread John Salvatier
Thank you John, those are looking useful. On Thu, Oct 13, 2011 at 2:39 PM, John Hunter wrote: > > > > > On Oct 13, 2011, at 4:21 PM, Zachary Pincus > wrote: > > > I keep meaning to use matplotlib as well, but every time I try I also get > really turned off by the matlabish interface in the exam

Re: [Numpy-discussion] wanted: decent matplotlib alternative

2011-10-13 Thread John Salvatier
I second that request. On Thu, Oct 13, 2011 at 2:21 PM, Zachary Pincus wrote: > I keep meaning to use matplotlib as well, but every time I try I also get > really turned off by the matlabish interface in the examples. I get that > it's a selling point for matlab refugees, but I find it counterint

Re: [Numpy-discussion] nditer: possible to manually handle dimensions with different lengths?

2011-10-06 Thread John Salvatier
im -1) oaxes.insert(axis, out.ndim-1) oaxes = oaxes[:-1] #remove the now reduced original given axis out = np.transpose(out, oaxes) return out On Mon, Oct 3, 2011 at 2:03 PM, John Salvatier wrote: > Some observations and questions about nested_iters. Nested_iters seems to > require that

Re: [Numpy-discussion] nditer: possible to manually handle dimensions with different lengths?

2011-10-03 Thread John Salvatier
do a "grouped" calculation (the group specified by the group argument) on the values along the given axis. I try to use nested_iter to iterate over the specified axis and a new axis (the length of the number of groups) separately so I can do my calculation. On Mon, Oct 3, 2011 at 9:03 AM,

Re: [Numpy-discussion] nditer: possible to manually handle dimensions with different lengths?

2011-10-03 Thread John Salvatier
. John On Sat, Oct 1, 2011 at 2:53 PM, Mark Wiebe wrote: > On Sat, Oct 1, 2011 at 1:45 PM, John Salvatier > wrote: > >> I apologize, I picked a poor example of what I want to do. Your suggestion >> would work for the example I provided, but not for a more complex example. &

Re: [Numpy-discussion] nditer: possible to manually handle dimensions with different lengths?

2011-10-01 Thread John Salvatier
nctions that operate on arrays and support broadcasting. Is clearer? On Fri, Sep 30, 2011 at 5:04 PM, Mark Wiebe wrote: > On Fri, Sep 30, 2011 at 8:03 AM, John Salvatier > wrote: > >> Using nditer, is it possible to manually handle dimensions with different >> lengths? >

[Numpy-discussion] nditer: possible to manually handle dimensions with different lengths?

2011-09-30 Thread John Salvatier
Using nditer, is it possible to manually handle dimensions with different lengths? For example, lets say I had an array A[5, 100] and I wanted to sample every 10 along the second axis so I would end up with an array B[5,10]. Is it possible to do this with nditer, handling the iteration over the s

Re: [Numpy-discussion] labeled axes

2011-05-26 Thread John Salvatier
I'm glad datarray is still active. :) On Thu, May 26, 2011 at 6:36 PM, Craig Yoshioka wrote: > Thanks, I will. I was just seeing if there was any intention of adding this > to type of support to numpy directly. It would be faster, and I'm sure it > would make projects like dataarray much simple

Re: [Numpy-discussion] Mapping of dtype to C types

2011-05-08 Thread John Salvatier
I want to add a question: is there a function that returns the name of the corresponding C type given the numpy type? On Sun, May 8, 2011 at 2:45 PM, Keith Goodman wrote: > I'm writing a function that accepts four possible dtypes: int32, > int64, float32, float64. The function will call a C exte

Re: [Numpy-discussion] convert dictionary of arrays into single array

2011-03-16 Thread John Salvatier
I think he wants to stack them (same widths) so stacking them should be fine. On Wed, Mar 16, 2011 at 7:30 AM, Bruce Southey wrote: > On 03/16/2011 08:56 AM, John Salvatier wrote: > > Loop through to build a list of arrays, then use vstack on the list. > > On Wed, Mar 16, 2011 a

Re: [Numpy-discussion] convert dictionary of arrays into single array

2011-03-16 Thread John Salvatier
Loop through to build a list of arrays, then use vstack on the list. On Wed, Mar 16, 2011 at 1:36 AM, John wrote: > Hello, > > I have a dictionary with structured arrays, keyed by integers 0...n. > There are no other keys in the dictionary. > > What is the most efficient way to convert the dicti

Re: [Numpy-discussion] Add New Functionality for Indexing Along an Axis to Numpy?

2011-03-14 Thread John Salvatier
The new iteration functionality will be providing this in the near future (along with many other things). See https://github.com/numpy/numpy/blob/master/doc/neps/new-iterator-ufunc.rst On Mon, Mar 14, 2011 at 6:30 PM, Jonathan Taylor < jonathan.tay...@utoronto.ca> wrote: > Please excuse the doubl

Re: [Numpy-discussion] 1.6: branching and release notes

2011-03-14 Thread John Salvatier
If they return a tuple of indexes I think 'mulitiindex' sounds quite good. That is exactly what a multiindex is ( http://en.wikipedia.org/wiki/Multi-index_notation). On Mon, Mar 14, 2011 at 1:14 AM, Mark Wiebe wrote: > On Sun, Mar 13, 2011 at 11:59 PM, Ralf Gommers < > ralf.gomm...@googlemail.co

Re: [Numpy-discussion] ragged array implimentation

2011-03-07 Thread John Salvatier
@Jeff I need to work with ragged arrays too. Are object arrays of 1d numpy arrays slower than lists of 1d numpy arrays? @ Christopher I'd be interested in hearing if you come up with any better solutions. On Mon, Mar 7, 2011 at 9:37 AM, Jeff Whitaker wrote: > On 3/7/11 10:28 AM, Christopher Bar

Re: [Numpy-discussion] Numpy 2.0 schedule

2011-02-28 Thread John Salvatier
I just want to say that I am looking forward to np.newiter, and I am impressed at how quickly it's being released. On Mon, Feb 28, 2011 at 2:49 AM, Pauli Virtanen wrote: > Mon, 28 Feb 2011 16:50:59 +0800, Ralf Gommers wrote: > > On Mon, Feb 28, 2011 at 4:00 PM, Ralf Gommers > > wrote: > > > >>

[Numpy-discussion] Example of PyArray_RemoveSmallest use?

2011-02-27 Thread John Salvatier
Does anyone have or know of an example of how to use PyArray_RemoveSmallest(multiiterator) to make the inner loop fast (how to get the right strides etc.)? I am finding it a bit confusing. Best Regards, John ___ NumPy-Discussion mailing list NumPy-Discus

Re: [Numpy-discussion] Vectorize or rewrite function to work with array inputs?

2011-02-01 Thread John Salvatier
Good things to know. On Tue, Feb 1, 2011 at 1:10 PM, Sturla Molden wrote: > Den 01.02.2011 20:50, skrev John Salvatier: > > I am curious: why you recommend against this? Using the C-API through > > cython seems more attractive than using the Cython-specific numpy > > featu

Re: [Numpy-discussion] Vectorize or rewrite function to work with array inputs?

2011-02-01 Thread John Salvatier
antages to using the C-API? Have I misunderstood something? John On Tue, Feb 1, 2011 at 11:41 AM, Sturla Molden wrote: > Den 01.02.2011 20:30, skrev John Salvatier: > > Have you thought about using cython to work with the numpy C-API > > (http://wiki.cython.org/tutorials/numpy#Usin

Re: [Numpy-discussion] Vectorize or rewrite function to work with array inputs?

2011-02-01 Thread John Salvatier
Have you thought about using cython to work with the numpy C-API ( http://wiki.cython.org/tutorials/numpy#UsingtheNumpyCAPI)? This will be fast, simple (you can mix and match Python and Cython). As for your specific issue: you can simply cast to all the inputs to numpy arrays (using asarray http:/

Re: [Numpy-discussion] Numexpr giving randomized results on arrays larger than 2047 elements

2011-01-24 Thread John Salvatier
You're right, I got the same behavior. Interesting. On Mon, Jan 24, 2011 at 11:35 AM, Warren Weckesser < warren.weckes...@enthought.com> wrote: > > > On Mon, Jan 24, 2011 at 1:13 PM, John Salvatier > wrote: > >> Looks like this is related to issue 41 ( >> h

Re: [Numpy-discussion] Numexpr giving randomized results on arrays larger than 2047 elements

2011-01-24 Thread John Salvatier
Looks like this is related to issue 41 ( http://code.google.com/p/numexpr/issues/detail?id=41&can=1). On Mon, Jan 24, 2011 at 10:29 AM, John Salvatier wrote: > I also get the same issue with prod() > > > On Mon, Jan 24, 2011 at 10:23 AM, Warren Weckesser < > warren.weckes..

Re: [Numpy-discussion] Numexpr giving randomized results on arrays larger than 2047 elements

2011-01-24 Thread John Salvatier
81.93 > > In [34]: x = zeros(8191)+0.01 > > In [35]: print evaluate('sum(x, axis=0)') > 81.91 > > In [36]: print evaluate('sum(x, axis=0)') > 81.91 > > > Warren > > > > On Mon, Jan 24, 2011 at 12:19 PM, John Salvatier < > jsalv

Re: [Numpy-discussion] Numexpr giving randomized results on arrays larger than 2047 elements

2011-01-24 Thread John Salvatier
Forgot to mention that I am using numexpr 1.4.1 and numpy 1.5.1 On Mon, Jan 24, 2011 at 9:47 AM, John Salvatier wrote: > Hello, > > I have discovered a strange bug with numexpr. numexpr.evaluate gives > randomized results on arrays larger than 2047 elements. The following > progr

[Numpy-discussion] Numexpr giving randomized results on arrays larger than 2047 elements

2011-01-24 Thread John Salvatier
Hello, I have discovered a strange bug with numexpr. numexpr.evaluate gives randomized results on arrays larger than 2047 elements. The following program demonstrates this: from numpy import * from numexpr import evaluate def func(x): return evaluate("sum(x, axis = 0)") x = zeros(2048)+.0

[Numpy-discussion] adding numexpr user-provided ufunc evaluation

2011-01-19 Thread John Salvatier
d sense of how developed it is. Best Regards, John Salvatier ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] numexpr with the new iterator

2011-01-09 Thread John Salvatier
Is evaluate_iter basically numpexpr but using your numpy branch or are there other changes? On Sun, Jan 9, 2011 at 2:45 PM, Mark Wiebe wrote: > As a benchmark of C-based iterator usage and to make it work properly in a > multi-threaded context, I've updated numexpr to use the new iterator. In >

Re: [Numpy-discussion] speed of numpy.ndarray compared to Numeric.array

2011-01-07 Thread John Salvatier
Did you try larger arrays/tuples? I would guess that makes a significant difference. On Fri, Jan 7, 2011 at 7:58 AM, EMMEL Thomas wrote: > Hi, > > There are some discussions on the speed of numpy compared to Numeric in > this list, however I have a topic > I don't understand in detail, maybe so

Re: [Numpy-discussion] Giving numpy the ability to multi-iterate excluding an axis

2011-01-04 Thread John Salvatier
essing the iterator values creates new array > objects. > > -Mark > > > On Tue, Jan 4, 2011 at 12:59 PM, Mark Wiebe wrote: > >> On Tue, Jan 4, 2011 at 12:15 PM, John Salvatier < >> jsalv...@u.washington.edu> wrote: >> >>> Wow, great! I'm excited

Re: [Numpy-discussion] Giving numpy the ability to multi-iterate excluding an axis

2011-01-04 Thread John Salvatier
11 at 11:23 AM, John Salvatier > wrote: > >> This thread is a bit old, but since it's not possible to use the C-API is >> possible to accomplish this same thing with the Python API? >> > > I've committed Python exposure for nested iteration to the new_ite

Re: [Numpy-discussion] Giving numpy the ability to multi-iterate excluding an axis

2011-01-01 Thread John Salvatier
This thread is a bit old, but since it's not possible to use the C-API is possible to accomplish this same thing with the Python API? On Tue, Dec 21, 2010 at 5:12 PM, Mark Wiebe wrote: > On Mon, Dec 20, 2010 at 1:42 PM, John Salvatier > wrote: > >> A while ago, I as

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-28 Thread John Salvatier
Wouldn't that be a cast? You do casts in Cython with (expression) and that should be the equivalent of float64 I think. On Tue, Dec 28, 2010 at 3:32 PM, Keith Goodman wrote: > I'm looking for the C-API equivalent of the np.float64 function, > something that I could use inline in a Cython functio

Re: [Numpy-discussion] numpy for jython

2010-12-23 Thread John Salvatier
I'm curious whether this kind of thing is expected to be relatively easy after the numpy refactor. On Thu, Dec 23, 2010 at 2:24 PM, Thunemann, Paul Z < paul.z.thunem...@boeing.com> wrote: > I'd be very interested in hearing more about a numpy port to Java and > Jython. If anyone has more info ab

Re: [Numpy-discussion] Giving numpy the ability to multi-iterate excluding an axis

2010-12-22 Thread John Salvatier
o not totally clear to me how offsetting works. What are the offsets measured from? It seems like they are measured from another iterator, but I'm not sure and I don't see how it gets that information. John On Tue, Dec 21, 2010 at 5:12 PM, Mark Wiebe wrote: > On Mon, Dec 20, 20

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-21 Thread John Salvatier
I applaud you on your vision. I only have one small suggestion: I suggest you put a table of contents at the beginning of your NEP so people may skip to the part that most interests them. On Tue, Dec 21, 2010 at 4:59 PM, John Salvatier wrote: > That is an amazing christmas present. > &g

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-21 Thread John Salvatier
That is an amazing christmas present. On Tue, Dec 21, 2010 at 4:53 PM, Mark Wiebe wrote: > Hello NumPy-ers, > > After some performance analysis, I've designed and implemented a new > iterator designed to speed up ufuncs and allow for easier multi-dimensional > iteration. The new code is fairly

[Numpy-discussion] Giving numpy the ability to multi-iterate excluding an axis

2010-12-20 Thread John Salvatier
A while ago, I asked a whether it was possible to multi-iterate over several ndarrays but exclude a certain axis( http://www.mail-archive.com/numpy-discussion@scipy.org/msg29204.html), sort of a combination of PyArray_IterAllButAxis and PyArray_MultiIterNew. My goal was to allow creation of relativ

Re: [Numpy-discussion] sample without replacement

2010-12-20 Thread John Salvatier
I think this is not possible to do efficiently with just numpy. If you want to do this efficiently, I wrote a no-replacement sampler in Cython some time ago (below). I hearby release it to the public domain. ''' Created on Oct 24, 2009 http://stackoverflow.com/questions/311703/algorithm-for-sampl

Re: [Numpy-discussion] MultiIter version of PyArray_IterAllButAxis ?

2010-12-01 Thread John Salvatier
On Wed, Dec 1, 2010 at 7:56 PM, David wrote: > On 12/02/2010 12:35 PM, John Salvatier wrote: > > Hello, > > > > I am writing a UFunc creation utility, and I would like to know: is > > there a way to mimic the behavior ofPyArray_IterAllButAxis for multiple > >

[Numpy-discussion] MultiIter version of PyArray_IterAllButAxis ?

2010-12-01 Thread John Salvatier
Hello, I am writing a UFunc creation utility, and I would like to know: is there a way to mimic the behavior ofPyArray_IterAllButAxis for multiple arrays at a time? I would like to be able to write UFuncs that take an axis argument and also take multiple array arguments, for example I want to be a

Re: [Numpy-discussion] A Cython apply_along_axis function

2010-12-01 Thread John Salvatier
On Wed, Dec 1, 2010 at 6:07 PM, Keith Goodman wrote: > On Wed, Dec 1, 2010 at 5:53 PM, David wrote: > > > On 12/02/2010 04:47 AM, Keith Goodman wrote: > >> It's hard to write Cython code that can handle all dtypes and > >> arbitrary number of dimensions. The former is typically dealt with > >> u

Re: [Numpy-discussion] A faster median (Wirth's method)

2010-12-01 Thread John Salvatier
@Keith Goodman I think I figured it out. I believe something like the following will do what you want, iterating across one axis specially, so it can apply a median function along an axis. This code in particular is for calculating a moving average and seems to work (though I haven't checked my ma

Re: [Numpy-discussion] A faster median (Wirth's method)

2010-11-30 Thread John Salvatier
se it. On Tue, Nov 30, 2010 at 12:06 PM, Keith Goodman wrote: > On Tue, Nov 30, 2010 at 11:58 AM, Matthew Brett > wrote: > > Hi, > > > > On Tue, Nov 30, 2010 at 11:35 AM, Keith Goodman > wrote: > >> On Tue, Nov 30, 2010 at 11:25 AM, John Salvatier > &

Re: [Numpy-discussion] A faster median (Wirth's method)

2010-11-30 Thread John Salvatier
I am very interested in this result. I have wanted to know how to do an apply_along_axis function for a while now. On Tue, Nov 30, 2010 at 11:21 AM, Keith Goodman wrote: > On Tue, Sep 1, 2009 at 2:37 PM, Sturla Molden wrote: > > Dag Sverre Seljebotn skrev: > >> > >> Nitpick: This will fail on l

Re: [Numpy-discussion] indexing question

2010-11-22 Thread John Salvatier
I think that the only speedup you will get is defining an index only once and reusing it. 2010/11/22 Ernest Adrogué : > 22/11/10 @ 14:04 (-0600), thus spake Robert Kern: >> > This way, I get the elements (0,1) and (1,1) which is what >> > I wanted. The question is: is it possible to omit the [0,1]

Re: [Numpy-discussion] indexing question

2010-11-22 Thread John Salvatier
I didn't realize the x's and y's were varying the first time around. There's probably a way to omit it, but I think the conceptually simplest way is probably what you had to begin with. Build an index by saying i = numpy.arange(0, t.shape[0]) then you can do t[i, x,y] On Mon, Nov 22, 2010 at 11:0

Re: [Numpy-discussion] indexing question

2010-11-21 Thread John Salvatier
yes use the symbol ':' so you want t[:,x,y] 2010/11/21 Ernest Adrogué : > Hi, > > Suppose an array of shape (N,2,2), that is N arrays of > shape (2,2). I want to select an element (x,y) from each one > of the subarrays, so I get a 1-dimensional array of length > N. For instance: > > In [228]: t=

Re: [Numpy-discussion] indexing question

2010-11-21 Thread John Salvatier
read about basic slicing : http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html On Sun, Nov 21, 2010 at 11:28 AM, John Salvatier wrote: > yes use the symbol ':' > > so you want > > t[:,x,y] > > 2010/11/21 Ernest Adrogué : >> Hi, >> >> Su

Re: [Numpy-discussion] Optimize Floyd-Wallshall algorithm with Numpy

2010-11-06 Thread John Salvatier
The difference is that dis[k,:] eliminates the first dimension since you are using a single number as an index, but dis[k:k+1,:] does not eliminate that dimension. On Sat, Nov 6, 2010 at 1:24 PM, wrote: > On Sat, Nov 6, 2010 at 4:14 PM, K. Sun wrote: >> Thanks a lot. It works! I modify the code

Re: [Numpy-discussion] datarray lightning talk at NYC Python group

2010-10-18 Thread John Salvatier
Maybe put it up on youtube? Or write down your pitch? As someone who dislikes R but thinks data.frames are good for something, I'd be interested in hearing the pitch, what the developers think the strengths and weaknesses of DatArray are. On Mon, Oct 18, 2010 at 2:18 PM, Fernando Perez wrote: > O

Re: [Numpy-discussion] Trying out datarray

2010-09-28 Thread John Salvatier
OK, that makes sense. Thanks guys! On Tue, Sep 28, 2010 at 5:43 PM, Fernando Perez wrote: > On Tue, Sep 28, 2010 at 11:19 AM, John Salvatier > wrote: > > My other question is whether datarray will be able to handle multiple > data > > types in the same object;

[Numpy-discussion] Trying out datarray

2010-09-28 Thread John Salvatier
I am not sure if this is the correct place for such questions, but here goes: I am curious about datarray, but I haven't been able to get it to work. The module datarray does not appear to have a class DataArray (or DatArray). So I am confused how I am supposed to use it. Can anyone advise? My ot

Re: [Numpy-discussion] restrictions on fancy indexing

2010-09-17 Thread John Salvatier
There's a tutorial here: http://www.scipy.org/Cookbook/Indexing Look down for the section on Fancy Indexing. On Fri, Sep 17, 2010 at 10:47 AM, Neal Becker wrote: > It's nice I can do: > > f = np.linspace (0, 1, 100) > u[f<.1] = 0 > > cool, this seems to work also: > > u[np.abs(f)<.1] = 0 > > co

Re: [Numpy-discussion] dot() performance depends on data?

2010-09-10 Thread John Salvatier
Perhaps the ndarrays have different ordering (C vs Fortran order)? On Fri, Sep 10, 2010 at 10:36 AM, Hagen Fürstenau wrote: > Hi, > > I'm multiplying two 1000x1000 arrays with numpy.dot() and seeing > significant performance differences depending on the data. It seems to > take much longer on mat

[Numpy-discussion] Add function for creating recarray from database query?

2010-09-03 Thread John Salvatier
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

[Numpy-discussion] Where is the dev version of numpydoc?

2010-08-31 Thread John Salvatier
Hello, I would like to update my numpydoc so it works with sphinx 1.0, but I am not sure where the dev version is; can someone point me in the right direction? John ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailm

Re: [Numpy-discussion] max value of an array of lists

2010-08-19 Thread John Salvatier
It sounds like you should just have a higher dimensional array. A 2 or 3 dimensional array instead of an object array. On Thu, Aug 19, 2010 at 2:44 PM, John Salvatier wrote: > You have an object array of lists? Why? > > On Thu, Aug 19, 2010 at 2:41 PM, sm lkd wrote: > >

Re: [Numpy-discussion] max value of an array of lists

2010-08-19 Thread John Salvatier
You have an object array of lists? Why? On Thu, Aug 19, 2010 at 2:41 PM, sm lkd wrote: > Hello again, > > Here's a simple one. I have an array/matrix of lists (floats). array.max() > or max(array) returns list (!) and not an individual value. Of course, it is > possible to loop, but maybe someo

Re: [Numpy-discussion] vectorization of vectorization

2010-08-19 Thread John Salvatier
This seems simple, so perhaps I am missing something, but what about this: special.iv(orders[:, newaxis], arange(1e6)[newaxis, : ], powers[:, newaxis]).prod(axis = 2) This will probably use up a bit slow/memoryintensive, so you probably want to use numexpr to speed it up a bit. On Thu, Aug 19, 2

Re: [Numpy-discussion] loading database data into numpy arrays

2010-08-19 Thread John Salvatier
at)]) On Thu, Aug 19, 2010 at 10:23 AM, John Salvatier wrote: > That worked! Thanks! > > > On Thu, Aug 19, 2010 at 10:18 AM, Keith Goodman wrote: > >> On Thu, Aug 19, 2010 at 10:00 AM, John Salvatier >> wrote: >> > Hello, >> > >> > I am try

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread John Salvatier
Precise in what sense? Numerical accuracy? If so, why is that? On Thu, Aug 19, 2010 at 12:13 PM, wrote: > On Thu, Aug 19, 2010 at 11:29 AM, Joe Harrington > wrote: > > On Thu, 19 Aug 2010 09:06:32 -0500, G?khan Sever > wrote: > > > >>On Thu, Aug 19, 2010 at 9:01 AM, greg whittier wrote: > >>

Re: [Numpy-discussion] loading database data into numpy arrays

2010-08-19 Thread John Salvatier
That worked! Thanks! On Thu, Aug 19, 2010 at 10:18 AM, Keith Goodman wrote: > On Thu, Aug 19, 2010 at 10:00 AM, John Salvatier > wrote: > > Hello, > > > > I am trying to load some time series data into numpy arrays from a MySQL > > database using pyodbc, but I

[Numpy-discussion] loading database data into numpy arrays

2010-08-19 Thread John Salvatier
Hello, I am trying to load some time series data into numpy arrays from a MySQL database using pyodbc, but I am not sure what the standard way to do this is. I found the following: http://www.aidanfindlater.com/python-db-api-to-numpy but when I tried after doing a select (I made sure the cursor ha

Re: [Numpy-discussion] set operation

2010-08-17 Thread John Salvatier
It should be noted that the 'set' type is a basic Python type, and not a NumPy specific type. On Tue, Aug 17, 2010 at 7:30 AM, Benjamin Root wrote: > On Tue, Aug 17, 2010 at 9:11 AM, gerardob wrote: > >> >> I would like to create a set composed of the numbers 2,3,4,...49,50,51. >> How >> do i d

Re: [Numpy-discussion] basic question about numpy arrays

2010-08-16 Thread John Salvatier
You can also do: y = x[:,0] On Mon, Aug 16, 2010 at 11:28 AM, Skipper Seabold wrote: > On Mon, Aug 16, 2010 at 2:25 PM, gerardob wrote: > > > > I have a numpy array A , such that when i print A it appears: > > > > [[ 10.] > > [ 20.]] > > > > I would like to have a one dimensional array B (obta

[Numpy-discussion] Numpy datetime support

2010-08-11 Thread John Salvatier
Hello, I am an eager for numpy datetime support, but I have not heard about it recently. Last I heard it was taken out of 1.4 because of some compatibility issues. When will datetime be a full numpy feature? Best Regards, John ___ NumPy-Discussion maili

Re: [Numpy-discussion] use index array of len n to select columns of n x m array

2010-08-05 Thread John Salvatier
choose might be slower if you weren't doing an "arange(N)" each time. On Thu, Aug 5, 2010 at 1:51 PM, Keith Goodman wrote: > On Thu, Aug 5, 2010 at 1:32 PM, wrote: > > On Thu, Aug 5, 2010 at 4:07 PM, Martin Spacek > wrote: > >> josef.pkt wrote: > > a = np.array([[0, 1], > >>

Re: [Numpy-discussion] use index array of len n to select columns of n x m array

2010-08-05 Thread John Salvatier
You may also use the choose function: http://docs.scipy.org/doc/numpy/reference/generated/numpy.choose.html choose(i, (a[:,0], a[:,1]) On Thu, Aug 5, 2010 at 10:31 AM, Keith Goodman wrote: > On Thu, Aug 5, 2010 at 10:26 AM, wrote: > > On Thu, Aug 5, 2010 at 1:12 PM, Martin Spacek > wrote: >

Re: [Numpy-discussion] Quick array value assignment based on common values

2010-08-04 Thread John Salvatier
ort A by the sorting used to sort y and then index into x using the unsorted A. use http://docs.scipy.org/doc/numpy/reference/generated/numpy.argsort.html#numpy.argsort On Wed, Aug 4, 2010 at 6:09 PM, John Salvatier wrote: > How exactly are you looping? That sounds absurdly slow. > > What

Re: [Numpy-discussion] Quick array value assignment based on common values

2010-08-04 Thread John Salvatier
How exactly are you looping? That sounds absurdly slow. What you need is a fast dictionary. On Wed, Aug 4, 2010 at 6:00 PM, Gökhan Sever wrote: > > > On Wed, Aug 4, 2010 at 6:59 PM, wrote: > >> Hey folks, >> >> I've one array, x, that you could define as follows: >> [[1, 2.25], >> [2, 2.50],

Re: [Numpy-discussion] Quick array value assignment based on common values

2010-08-04 Thread John Salvatier
Are they numbered like that? If so you can index into the first array by the second one. x[y[:,0], 1] if you can't get them into an indexable format, I think it's going to be slow no matter how you do it. On Wed, Aug 4, 2010 at 4:59 PM, wrote: > Hey folks, > > I've one array, x, that you could d

Re: [Numpy-discussion] [ANN] ALGOPY 0.21, algorithmic differentiation in Python

2010-08-01 Thread John Salvatier
Holy cow! I was looking for this exact package for extending pymc! Now I've found two packages that do basically exactly what I want (Theano and ALGOPY). Does ALYGOPY handle derivatives of operations on higher order ndimensional arrays well (efficiently and including broadcasting and such)? John

[Numpy-discussion] Mathematical language for reasoning about numpy like arrays?

2010-08-01 Thread John Salvatier
Is anyone aware of a good mathematical language to describe and reason about how numpy arrays work (broadcastable ndarrays)? I am particularly interested in reasoning about linear maps from one ndarray to another. Clearly ndarrays can be thought of as regular vectors and you can reason about them u

Re: [Numpy-discussion] str == int puzzlement

2010-07-28 Thread John Salvatier
I think this is just Python behavior; comparing python ints and strs also gives False: In [45]: 8 == 'L' Out[45]: False On Wed, Jul 28, 2010 at 6:42 PM, Matthew Brett wrote: > Hi, > > Please forgive me if this is obvious, but this surprised me: > > In [15]: x = np.array(['a', 'b']) > > In [16]:

Re: [Numpy-discussion] Help w/ indexing, please

2010-07-27 Thread John Salvatier
I am pretty sure you should be able to do R = C[L, :] and get the array you want. Try it with a small matrix where you know the result you want. You may need to transpose some axes afterwards, but I don't think you should. On Tue, Jul 27, 2010 at 9:10 AM, David Goldsmith wrote: > Hi! I have

Re: [Numpy-discussion] Custom ufuncs with Axis argument

2010-07-22 Thread John Salvatier
I should add that it is for ufuncs with number of arguments larger than 2. On Thu, Jul 22, 2010 at 2:47 PM, John Salvatier wrote: > What is the easiest way to give a custom ufunc an axis argument? I have > looked around the UFunc API, but I have not seen anything related t

[Numpy-discussion] Custom ufuncs with Axis argument

2010-07-22 Thread John Salvatier
What is the easiest way to give a custom ufunc an axis argument? I have looked around the UFunc API, but I have not seen anything related to this. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-di

Re: [Numpy-discussion] subtract.reduce behavior

2010-07-22 Thread John Salvatier
I get the same result on 1.4.1 On Thu, Jul 22, 2010 at 1:00 PM, Johann Hibschman < jhibschman+nu...@gmail.com > wrote: > I'm trying to understand numpy.subtract.reduce. The documentation > doesn't seem to match the behavior. The documentation claims > > For a one-dimensional array, reduce prod

Re: [Numpy-discussion] Can't get ufunc to work for integers

2010-07-22 Thread John Salvatier
This did end up solving my problem. Thanks! On Thu, Jul 22, 2010 at 9:25 AM, John Salvatier wrote: > Oh, ok. That makes sense. Thanks for the speedy help. > > John > > > On Thu, Jul 22, 2010 at 9:14 AM, Pauli Virtanen wrote: > >> Thu, 22 Jul 2010 08:49:09 -0700, John

Re: [Numpy-discussion] Can't get ufunc to work for integers

2010-07-22 Thread John Salvatier
Oh, ok. That makes sense. Thanks for the speedy help. John On Thu, Jul 22, 2010 at 9:14 AM, Pauli Virtanen wrote: > Thu, 22 Jul 2010 08:49:09 -0700, John Salvatier wrote: > > I am trying to learn how to create ufuncs, and I got a ufunc to compile > > correctly with the signatur

[Numpy-discussion] Can't get ufunc to work for integers

2010-07-22 Thread John Salvatier
Hello, I am trying to learn how to create ufuncs, and I got a ufunc to compile correctly with the signature int -> double, but I can't get it to accept any arguments. My function is testfunc and I used NPY_INT as the first signature and NPY_DOUBLE as the second signature. What should I look at to

  1   2   >