[Numpy-discussion] Fwd: Advice for grouping recarrays

2010-04-28 Thread Tom Denniston
(ind)).compress(numpy.hstack([[1], >>> ind[1:]!=ind[:-1]])) >>> numpy.add.reduceat(data, borders) array([ 6, 15, 24]) On Tue, Jul 18, 2006 at 8:49 AM, Tom Denniston wrote: > I suggest > > lexsort > itertools.groupby of the indices > take > > I think it would

[Numpy-discussion] Is there anyway to seed random numbers without global state?

2009-01-12 Thread Tom Denniston
I know how to seed and generate random numbers using: numpy.random.seed and numpy.random.rand The problem is the seeding of the random numbers is global which I would think would make it non-thread safe as well as having all the other annoyances of global state like having so set the seed and set

Re: [Numpy-discussion] inserting indexes into an array

2008-09-24 Thread Tom Denniston
You could try something like: In [15]: arr = numpy.array([100,200,300]) In [16]: arr2 = numpy.empty((len(arr)*2,)) In [17]: arr2[::2]=arr In [18]: arr2[1::2]=numpy.arange(len(arr)) In [20]: arr2 Out[20]: array([ 100.,0., 200.,1., 300.,2.]) 2008/9/24 Nadav Horesh <[EMAIL PROTECTE

Re: [Numpy-discussion] Cython/NumPy syntax

2008-08-06 Thread Tom Denniston
I think the square brackets are very confusing as a numpy user not familiar with CPython. On 8/6/08, Christopher Barker <[EMAIL PROTECTED]> wrote: > Dag Sverre Seljebotn wrote: > > cdef numpy.ndarray[numpy.int64, ndim=2] > > +1 it's very clear what this means. I think the keyword should be require

Re: [Numpy-discussion] The date/time dtype and the casting issue

2008-07-30 Thread Tom Denniston
Yes this all makes a lot of sense. I would propose changing the name from business days to weekdays though. Does anyone object wih that? On 7/30/08, Ivan Vilata i Balaguer <[EMAIL PROTECTED]> wrote: > Tom Denniston (el 2008-07-30 a les 13:12:45 -0500) va dir:: > > > If it'

Re: [Numpy-discussion] The date/time dtype and the casting issue

2008-07-30 Thread Tom Denniston
--Tom On 7/30/08, Francesc Alted <[EMAIL PROTECTED]> wrote: > A Wednesday 30 July 2008, Tom Denniston escrigué: > > When people are refering to busienss days are you talking about > > weekdays or are you saying weekday non-holidays? > > Plain weekdays. Taking in account

Re: [Numpy-discussion] The date/time dtype and the casting issue

2008-07-30 Thread Tom Denniston
When people are refering to busienss days are you talking about weekdays or are you saying weekday non-holidays? On 7/30/08, Francesc Alted <[EMAIL PROTECTED]> wrote: > A Wednesday 30 July 2008, Pierre GM escrigué: > > > > Now, what format do you consider for this reference ? > > > > > > Whatever

Re: [Numpy-discussion] The date/time dtype and the casting issue

2008-07-29 Thread Tom Denniston
Francesc, The datetime proposal is very impressive in its depth and thought. For me as well as many other people this would be a massive improvement to numpy and allow numpy to get a foothold in areas like econometrics where R/S is now dominant. I had one question regarding casting of strings: I

[Numpy-discussion] interesect1d bug?

2007-09-20 Thread Tom Denniston
Is this the expected behavior of the numpy.intersect1d funciton: In [8]: numpy.intersect1d([3766, 9583, 17220, 40048, 50909, 52241, 62494, 828525, 20548728, 14874, 320256, 12795, 2223137, 16554, 27901, 2031774, 13610, 1592688, 13585, 16205, 1181652, 37177, 828525, 52241, 113826, 285236, 19475, 933

Re: [Numpy-discussion] NotImplementedType

2007-09-14 Thread Tom Denniston
t set breakpoints and dig. --Tom On 9/14/07, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Tom Denniston wrote: > > Sometimes numpy operationrs result in NotImplementedType. It makes it > > a little hard to debug because the problem then crops up later when > > yo

[Numpy-discussion] NotImplementedType

2007-09-14 Thread Tom Denniston
Sometimes numpy operationrs result in NotImplementedType. It makes it a little hard to debug because the problem then crops up later when you try to do an operation with the NotImplementedType. Does anyone know of a way to get numpy to raise instead of returning not implemented type? (Pydb) othe

Re: [Numpy-discussion] Dict of lists to numpy recarray

2007-08-24 Thread Tom Denniston
Try itertools.izipping the lists and then use numpy.fromiter. On 8/24/07, Sean Davis <[EMAIL PROTECTED]> wrote: > > > On 8/24/07, Sean Davis <[EMAIL PROTECTED]> wrote: > > I have a simple question (I assume), but I can't quite get a handle on the > answer. I have a dict with each member a list ha

Re: [Numpy-discussion] segfault caused by incorrect Py_DECREF in ufunc

2007-07-06 Thread Tom Denniston
Thanks! On 7/6/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Tom Denniston wrote: > > >Below is the code around line 900 for ufuncobject.c > >(http://svn.scipy.org/svn/numpy/trunk/numpy/core/src/ufuncobject.c) > > > >There is a decref labeled with ">

Re: [Numpy-discussion] bug in lexsort with two different dtypes?

2007-06-30 Thread Tom Denniston
thanks On 6/30/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On 6/26/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > > > > > > > On 6/26/07, Charles R Harris < [EMAIL PROTECTED]> wrote: > > > > > > > &

Re: [Numpy-discussion] How is NumPy implemented?

2007-06-28 Thread Tom Denniston
That is normal python syntax. It works with lists. What is slightly unusual is the multi-dimensional slicing as in arr[:,10:20]. However, this is governed by the way python translates bracket[] index calls to the __getitem__ and __getslice__ methods. You can try it out yourself in ipython or yo

[Numpy-discussion] segfault caused by incorrect Py_DECREF in ufunc

2007-06-28 Thread Tom Denniston
Below is the code around line 900 for ufuncobject.c (http://svn.scipy.org/svn/numpy/trunk/numpy/core/src/ufuncobject.c) There is a decref labeled with ">>>" below that is incorrect. As per the python documentation (http://docs.python.org/api/dictObjects.html): #PyObject* PyDict_GetItem( PyObject

[Numpy-discussion] bug in lexsort with two different dtypes?

2007-06-26 Thread Tom Denniston
In [1]: intArr1 = numpy.array([ 0, 1, 2,-2,-1, 5,-5,-5]) In [2]: intArr2 = numpy.array([1,1,1,2,2,2,3,4]) In [3]: charArr = numpy.array(['a','a','a','b','b','b','c','d']) Here I sort two int arrays. As expected intArr2 dominates intArr1 but the items with the same intArr2 values are sorted forwar

Re: [Numpy-discussion] attribute names on record arrays

2007-06-15 Thread Tom Denniston
One thing I've done in situations like this where you want names of dynamic fields to be available for tab completion but the object has other methods and instance variables that might conflict is to use a proxy object that just contains the fields. So for instance you have a property called F tha

[Numpy-discussion] Memory Error in Search Sorted

2007-05-09 Thread Tom Denniston
So searchsorted is supposed to take a list. The arguments I am using are not correct. But it still seems strange to me that these incorrect params trigger a memory error. Is a check simply missing or is this possibly a sign of a larger bug? I can simply correct my params so this is no big deal,

Re: [Numpy-discussion] Complex 'where' expression

2007-03-27 Thread Tom Denniston
You need to use numpy.logical_and. The and and or operators do not work elementwise on arrays to the best of my understanding. I think it is a limitation on the way logical operators are applied in python or maybe it is an intentional numpy limitation. I'm sure others on the list could explain be

[Numpy-discussion] problems with auto detection and broadcasting for userdefined numpy types

2007-02-15 Thread Tom Denniston
I have a userdefined numpy type for mx.DateTime and one for mx.DateTimeDelta. Info on these packages is available here (http://www.egenix.com/files/python/eGenix-mx-Extensions.html). In any case most things work. What I am left with is three problems: 1. I cannot figure out how to cleanly or e

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Tom Denniston
I don't know if this helps but you could use where to do the dispatch between the two different formulas. I don't know the answer to your original question however. On 2/14/07, Wojciech Śmigaj <[EMAIL PROTECTED]> wrote: > Timothy Hochberg wrote: > > On 2/14/07, *Wojciech Śmigaj* <[EMAIL PROTECTED

Re: [Numpy-discussion] Bug in numpy user-define types mechanism causes segfault on multiple calls to a ufunc

2007-02-07 Thread Tom Denniston
Many thanks, Travis. I'll test the new version tonight. --Tom On 2/7/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Tom Denniston wrote: > > >I am trying to register a custom type to numpy. When I do so it works > >and the ufuncs work but then when I invoke any u

[Numpy-discussion] Bug in numpy user-define types mechanism causes segfault on multiple calls to a ufunc

2007-02-07 Thread Tom Denniston
I am trying to register a custom type to numpy. When I do so it works and the ufuncs work but then when I invoke any ufunc twice the second time my python interpretter segfaults. I think i know what the problem is. In the select_types method in ufuncobject.c in numpy/core/src/ numpy gets a refer

Re: [Numpy-discussion] bug in numpy.equal?

2007-02-07 Thread Tom Denniston
got it. thanks. On 2/7/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Tom Denniston wrote: > > >The behavior below seems strange to me. The string array is type S3 > >yet it says that comparison with 'abc' is not implemented. The == > >operator seems

[Numpy-discussion] bug in numpy.equal?

2007-02-06 Thread Tom Denniston
The behavior below seems strange to me. The string array is type S3 yet it says that comparison with 'abc' is not implemented. The == operator seems to work though. Is there a subtlty I am missing or is it simply a bug? In [1]: import numpy In [2]: numpy.equal(numpy.array(['abc', 'def']), 'a

Re: [Numpy-discussion] query to array

2007-01-31 Thread Tom Denniston
or 10 character wide string. Others might know of a more elegant way to express this. --Tom On 1/31/07, Keith Goodman <[EMAIL PROTECTED]> wrote: > On 1/31/07, Tom Denniston <[EMAIL PROTECTED]> wrote: > > i would do something like the following. I don't have your o

Re: [Numpy-discussion] query to array

2007-01-31 Thread Tom Denniston
i would do something like the following. I don't have your odbc library so I mocked it up with a fake iterator called "it". This example would be for a two column result where the first is an int and the second a string. Note it creates a recarray which you can have match you database column nam

Re: [Numpy-discussion] A question about argmax and argsort

2006-12-20 Thread Tom Denniston
If you want the n largest item i would recommend quicksort but at each partition you only recurse into the side of the pivot that has the values you care about. This is easy to determine because you know how many items are on either side of the pivot and you know that you want the nth item. This